From a05ba6377630cc1dafd3ac8577848d4bf8040dd2 Mon Sep 17 00:00:00 2001 From: shouder <386734307@qq.com> Date: Tue, 27 Aug 2019 00:10:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9A=84=E5=85=B7=E4=BD=93=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index bc92a95..43aa321 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,50 @@ ~~~ composer require topthink/think-migration ~~~ + +## 修改 +* Column的类型报错 + +* PdoAdapter.php中的getColumnTypes方法中添加了smallinteger的数组内容, +这里修改后可以过滤掉Column的类型报错 +* mysql的类型不支持报错 +* AdapterInterface.php中添加常量 const PHINX_TYPE_SMALL_INTEGER = 'smallinteger'; +* MysqlAdapter.php中修改和添加getSqlType方法中的内容 +``` + case static::PHINX_TYPE_INTEGER: + if ($limit && $limit >= static::INT_TINY) { + $sizes = array( + // Order matters! Size must always be tested from longest to shortest! + 'bigint' => static::INT_BIG, + 'int' => static::INT_REGULAR, + 'mediumint' => static::INT_MEDIUM, + 'smallint' => static::INT_SMALL, + 'tinyint' => static::INT_TINY, + ); + $limits = array( + // 修改部分开始######## + 'smallint' => 5, + // 修改部分结束######## + 'int' => 11, + 'bigint' => 20, + ); + foreach ($sizes as $name => $length) { + if ($limit >= $length) { + $def = array('name' => $name); + if (isset($limits[$name])) { + $def['limit'] = $limits[$name]; + } + return $def; + } + } + } elseif (!$limit) { + $limit = 11; + } + return array('name' => 'int', 'limit' => $limit); + break; + // 后面是添加部分 + case static::PHINX_TYPE_SMALL_INTEGER: + return array('name' => 'smallint', 'limit' => 5); + break; + +```