From bf448b98b849c8f0b0bb877d5561df4297aaa124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Tue, 10 Oct 2023 17:08:33 +0800 Subject: [PATCH] =?UTF-8?q?build:=E5=8D=87=E7=BA=A7=20topthink/think-migra?= =?UTF-8?q?tion=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/library/crud/Helper.php | 32 +- composer.json | 2 +- .../migrations/20230620180908_install.php | 320 +++++++++--------- .../20230620180916_install_data.php | 8 +- .../migrations/20230622221507_version200.php | 12 +- .../migrations/20230719211338_version201.php | 1 - .../migrations/20230905060702_version202.php | 1 - extend/ba/TableManager.php | 2 +- 8 files changed, 179 insertions(+), 199 deletions(-) diff --git a/app/admin/library/crud/Helper.php b/app/admin/library/crud/Helper.php index 232a3536..644ae77d 100644 --- a/app/admin/library/crud/Helper.php +++ b/app/admin/library/crud/Helper.php @@ -440,22 +440,18 @@ public static function updateFieldOrder(string $tableName, array $fields, array $fieldName = in_array($item['type'], ['add-field', 'change-field-name']) ? $item['newName'] : $item['oldName']; - $field = self::searchArray($fields, function ($field) use ($fieldName) { + $field = self::searchArray($fields, function ($field) use ($fieldName) { return $field['name'] == $fieldName; }); - $dataType = self::analyseFieldDataType($field); - $sql = "ALTER TABLE `$tableName` MODIFY COLUMN `$fieldName` $dataType"; + + $phinxFieldData = self::getPhinxFieldData($field); + + // 字段顺序调整 if ($item['after'] == 'FIRST FIELD') { - // 设为第一个字段 - $sql .= ' FIRST'; + $phinxFieldData['options']['after'] = MysqlAdapter::FIRST; } else { - $sql .= " AFTER `{$item['after']}`"; + $phinxFieldData['options']['after'] = $item['after']; } - Db::execute($sql); - - // 使用 Phinx 再更新一遍字段,不然字段注释等数据丢失 - // think-migration 使用了自行维护的 Phinx,并不支持直接将字段设置为第一个,所以调整排序直接使用 SQL - $phinxFieldData = self::getPhinxFieldData($field); $table->changeColumn($fieldName, $phinxFieldData['type'], $phinxFieldData['options']); } } @@ -489,6 +485,7 @@ public static function handleTableDesign(array $table, array $fields): array $table = TableManager::instance($name, [], false); // 改名和删除操作优先 + $priorityOpt = false; foreach ($designChange as $item) { if (!$item['sync']) continue; @@ -499,18 +496,19 @@ public static function handleTableDesign(array $table, array $fields): array } if ($item['type'] == 'change-field-name') { + $priorityOpt = true; $table->renameColumn($item['oldName'], $item['newName']); - - // 改名后使用 Phinx 再更新一遍字段,不然字段注释等数据丢失 - $phinxFieldData = self::getPhinxFieldData(self::searchArray($fields, function ($field) use ($item) { - return $field['name'] == $item['newName']; - })); - $table->changeColumn($item['newName'], $phinxFieldData['type'], $phinxFieldData['options']); } elseif ($item['type'] == 'del-field') { + $priorityOpt = true; $table->removeColumn($item['oldName']); } } + // 保存需要优先执行的操作,避免先改名再改属性时找不到字段 + if ($priorityOpt) { + $table->update(); + } + // 修改字段属性和添加字段操作 foreach ($designChange as $item) { diff --git a/composer.json b/composer.json index d6734b3a..6007f7bf 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "topthink/think-orm": "^3.0", "topthink/think-multi-app": "^1.0", "topthink/think-throttle": "v2.0.0", - "topthink/think-migration": "3.0.6", + "topthink/think-migration": "3.1.1", "phpmailer/phpmailer": "^6.8", "w7corp/easywechat": "^6.12", "voku/anti-xss": "^4.1", diff --git a/database/migrations/20230620180908_install.php b/database/migrations/20230620180908_install.php index 7049462d..b889ae21 100644 --- a/database/migrations/20230620180908_install.php +++ b/database/migrations/20230620180908_install.php @@ -41,19 +41,19 @@ public function admin() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('username', 'string', ['limit' => 20, 'default' => '', 'comment' => '用户名']) - ->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '昵称']) - ->addColumn('avatar', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像']) - ->addColumn('email', 'string', ['limit' => 50, 'default' => '', 'comment' => '邮箱']) - ->addColumn('mobile', 'string', ['limit' => 11, 'default' => '', 'comment' => '手机']) - ->addColumn('loginfailure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('username', 'string', ['limit' => 20, 'default' => '', 'comment' => '用户名', 'null' => false]) + ->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '昵称', 'null' => false]) + ->addColumn('avatar', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像', 'null' => false]) + ->addColumn('email', 'string', ['limit' => 50, 'default' => '', 'comment' => '邮箱', 'null' => false]) + ->addColumn('mobile', 'string', ['limit' => 11, 'default' => '', 'comment' => '手机', 'null' => false]) + ->addColumn('loginfailure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数', 'null' => false]) ->addColumn('lastlogintime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '上次登录时间']) - ->addColumn('lastloginip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP']) - ->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '密码']) - ->addColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐']) - ->addColumn('motto', 'string', ['limit' => 255, 'default' => '', 'comment' => '签名']) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用']) + ->addColumn('lastloginip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP', 'null' => false]) + ->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '密码', 'null' => false]) + ->addColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐', 'null' => false]) + ->addColumn('motto', 'string', ['limit' => 255, 'default' => '', 'comment' => '签名', 'null' => false]) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false]) ->addColumn('createtime', 'integer', ['limit' => 10, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('updatetime', 'integer', ['limit' => 10, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->addIndex(['username'], [ @@ -73,11 +73,11 @@ public function adminGroup() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('pid', 'integer', ['comment' => '上级分组', 'default' => 0, 'signed' => false]) - ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '组名']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('pid', 'integer', ['comment' => '上级分组', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '组名', 'null' => false]) ->addColumn('rules', 'text', ['null' => true, 'default' => null, 'comment' => '权限规则ID']) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用']) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false]) ->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); @@ -93,8 +93,8 @@ public function adminGroupAccess() 'row_format' => 'DYNAMIC', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('uid', 'integer', ['comment' => '管理员ID', 'signed' => false]) - ->addColumn('group_id', 'integer', ['comment' => '分组ID', 'signed' => false]) + $table->addColumn('uid', 'integer', ['comment' => '管理员ID', 'signed' => false, 'null' => false]) + ->addColumn('group_id', 'integer', ['comment' => '分组ID', 'signed' => false, 'null' => false]) ->addIndex(['uid'], [ 'type' => 'BTREE', ]) @@ -115,14 +115,14 @@ public function adminLog() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('admin_id', 'integer', ['comment' => '管理员ID', 'default' => 0, 'signed' => false]) - ->addColumn('username', 'string', ['limit' => 20, 'default' => '', 'comment' => '管理员用户名']) - ->addColumn('url', 'string', ['limit' => 1500, 'default' => '', 'comment' => '操作Url']) - ->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '日志标题']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('admin_id', 'integer', ['comment' => '管理员ID', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('username', 'string', ['limit' => 20, 'default' => '', 'comment' => '管理员用户名', 'null' => false]) + ->addColumn('url', 'string', ['limit' => 1500, 'default' => '', 'comment' => '操作Url', 'null' => false]) + ->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '日志标题', 'null' => false]) ->addColumn('data', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '请求数据']) - ->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => 'IP']) - ->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent']) + ->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => 'IP', 'null' => false]) + ->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent', 'null' => false]) ->addColumn('createtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); } @@ -138,7 +138,7 @@ public function area() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) ->addColumn('pid', 'integer', ['comment' => '父id', 'null' => true, 'default' => null, 'signed' => false]) ->addColumn('shortname', 'string', ['limit' => 100, 'null' => true, 'default' => null, 'comment' => '简称']) ->addColumn('name', 'string', ['limit' => 100, 'null' => true, 'default' => null, 'comment' => '名称']) @@ -167,19 +167,19 @@ public function attachment() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('topic', 'string', ['limit' => 20, 'default' => '', 'comment' => '细目']) - ->addColumn('admin_id', 'integer', ['comment' => '上传管理员ID', 'default' => 0, 'signed' => false]) - ->addColumn('user_id', 'integer', ['comment' => '上传用户ID', 'default' => 0, 'signed' => false]) - ->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => '物理路径']) - ->addColumn('width', 'integer', ['comment' => '宽度', 'default' => 0, 'signed' => false]) - ->addColumn('height', 'integer', ['comment' => '高度', 'default' => 0, 'signed' => false]) - ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '原始名称']) - ->addColumn('size', 'integer', ['comment' => '大小', 'default' => 0, 'signed' => false]) - ->addColumn('mimetype', 'string', ['limit' => 100, 'default' => '', 'comment' => 'mime类型']) - ->addColumn('quote', 'integer', ['comment' => '上传(引用)次数', 'default' => 0, 'signed' => false]) - ->addColumn('storage', 'string', ['limit' => 50, 'default' => '', 'comment' => '存储方式']) - ->addColumn('sha1', 'string', ['limit' => 40, 'default' => '', 'comment' => 'sha1编码']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('topic', 'string', ['limit' => 20, 'default' => '', 'comment' => '细目', 'null' => false]) + ->addColumn('admin_id', 'integer', ['comment' => '上传管理员ID', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('user_id', 'integer', ['comment' => '上传用户ID', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => '物理路径', 'null' => false]) + ->addColumn('width', 'integer', ['comment' => '宽度', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('height', 'integer', ['comment' => '高度', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'comment' => '原始名称', 'null' => false]) + ->addColumn('size', 'integer', ['comment' => '大小', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('mimetype', 'string', ['limit' => 100, 'default' => '', 'comment' => 'mime类型', 'null' => false]) + ->addColumn('quote', 'integer', ['comment' => '上传(引用)次数', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('storage', 'string', ['limit' => 50, 'default' => '', 'comment' => '存储方式', 'null' => false]) + ->addColumn('sha1', 'string', ['limit' => 40, 'default' => '', 'comment' => 'sha1编码', 'null' => false]) ->addColumn('createtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->addColumn('lastuploadtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '最后上传时间']) ->create(); @@ -196,8 +196,8 @@ public function captcha() 'primary_key' => 'key', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('key', 'string', ['limit' => 32, 'default' => '', 'comment' => '验证码Key']) - ->addColumn('code', 'string', ['limit' => 32, 'default' => '', 'comment' => '验证码(加密后)']) + $table->addColumn('key', 'string', ['limit' => 32, 'default' => '', 'comment' => '验证码Key', 'null' => false]) + ->addColumn('code', 'string', ['limit' => 32, 'default' => '', 'comment' => '验证码(加密后)', 'null' => false]) ->addColumn('captcha', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '验证码数据']) ->addColumn('createtime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->addColumn('expiretime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间']) @@ -215,18 +215,18 @@ public function config() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('name', 'string', ['limit' => 30, 'default' => '', 'comment' => '变量名']) - ->addColumn('group', 'string', ['limit' => 30, 'default' => '', 'comment' => '分组']) - ->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '变量标题']) - ->addColumn('tip', 'string', ['limit' => 100, 'default' => '', 'comment' => '变量描述']) - ->addColumn('type', 'string', ['limit' => 30, 'default' => '', 'comment' => '变量输入组件类型']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('name', 'string', ['limit' => 30, 'default' => '', 'comment' => '变量名', 'null' => false]) + ->addColumn('group', 'string', ['limit' => 30, 'default' => '', 'comment' => '分组', 'null' => false]) + ->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '变量标题', 'null' => false]) + ->addColumn('tip', 'string', ['limit' => 100, 'default' => '', 'comment' => '变量描述', 'null' => false]) + ->addColumn('type', 'string', ['limit' => 30, 'default' => '', 'comment' => '变量输入组件类型', 'null' => false]) ->addColumn('value', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '变量值']) ->addColumn('content', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '字典数据']) - ->addColumn('rule', 'string', ['limit' => 100, 'default' => '', 'comment' => '验证规则']) - ->addColumn('extend', 'string', ['limit' => 255, 'default' => '', 'comment' => '扩展属性']) - ->addColumn('allow_del', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '允许删除:0=否,1=是']) - ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0]) + ->addColumn('rule', 'string', ['limit' => 100, 'default' => '', 'comment' => '验证规则', 'null' => false]) + ->addColumn('extend', 'string', ['limit' => 255, 'default' => '', 'comment' => '扩展属性', 'null' => false]) + ->addColumn('allow_del', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '允许删除:0=否,1=是', 'null' => false]) + ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false]) ->addIndex(['name'], [ 'unique' => true, ]) @@ -244,21 +244,21 @@ public function menuRule() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('pid', 'integer', ['comment' => '上级菜单', 'default' => 0, 'signed' => false]) - ->addColumn('type', 'enum', ['values' => 'menu_dir,menu,button', 'default' => 'menu', 'comment' => '类型:menu_dir=菜单目录,menu=菜单项,button=页面按钮']) - ->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '标题']) - ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称']) - ->addColumn('path', 'string', ['limit' => 100, 'default' => '', 'comment' => '路由路径']) - ->addColumn('icon', 'string', ['limit' => 50, 'default' => '', 'comment' => '图标']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('pid', 'integer', ['comment' => '上级菜单', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('type', 'enum', ['values' => 'menu_dir,menu,button', 'default' => 'menu', 'comment' => '类型:menu_dir=菜单目录,menu=菜单项,button=页面按钮', 'null' => false]) + ->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '标题', 'null' => false]) + ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false]) + ->addColumn('path', 'string', ['limit' => 100, 'default' => '', 'comment' => '路由路径', 'null' => false]) + ->addColumn('icon', 'string', ['limit' => 50, 'default' => '', 'comment' => '图标', 'null' => false]) ->addColumn('menu_type', 'enum', ['values' => 'tab,link,iframe', 'null' => true, 'default' => null, 'comment' => '菜单类型:tab=选项卡,link=链接,iframe=Iframe']) - ->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => 'Url']) - ->addColumn('component', 'string', ['limit' => 100, 'default' => '', 'comment' => '组件路径']) - ->addColumn('keepalive', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '缓存:0=关闭,1=开启']) - ->addColumn('extend', 'enum', ['values' => 'none,add_rules_only,add_menu_only', 'default' => 'none', 'comment' => '扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单']) - ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注']) - ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0]) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用']) + ->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => 'Url', 'null' => false]) + ->addColumn('component', 'string', ['limit' => 100, 'default' => '', 'comment' => '组件路径', 'null' => false]) + ->addColumn('keepalive', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '缓存:0=关闭,1=开启', 'null' => false]) + ->addColumn('extend', 'enum', ['values' => 'none,add_rules_only,add_menu_only', 'default' => 'none', 'comment' => '扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单', 'null' => false]) + ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false]) + ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false]) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false]) ->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->addIndex(['pid'], [ @@ -278,13 +278,13 @@ public function securityDataRecycle() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称']) - ->addColumn('controller', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器']) - ->addColumn('controller_as', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器别名']) - ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '对应数据表']) - ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键']) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false]) + ->addColumn('controller', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器', 'null' => false]) + ->addColumn('controller_as', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器别名', 'null' => false]) + ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '对应数据表', 'null' => false]) + ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false]) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false]) ->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); @@ -301,15 +301,15 @@ public function securityDataRecycleLog() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('admin_id', 'integer', ['comment' => '操作管理员', 'default' => 0, 'signed' => false]) - ->addColumn('recycle_id', 'integer', ['comment' => '回收规则ID', 'default' => 0, 'signed' => false]) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('admin_id', 'integer', ['comment' => '操作管理员', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('recycle_id', 'integer', ['comment' => '回收规则ID', 'default' => 0, 'signed' => false, 'null' => false]) ->addColumn('data', 'text', ['null' => true, 'default' => null, 'comment' => '回收的数据']) - ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据表']) - ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键']) - ->addColumn('is_restore', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '是否已还原:0=否,1=是']) - ->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '操作者IP']) - ->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent']) + ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据表', 'null' => false]) + ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false]) + ->addColumn('is_restore', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '是否已还原:0=否,1=是', 'null' => false]) + ->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '操作者IP', 'null' => false]) + ->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent', 'null' => false]) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); } @@ -325,14 +325,14 @@ public function securitySensitiveData() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称']) - ->addColumn('controller', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器']) - ->addColumn('controller_as', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器别名']) - ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '对应数据表']) - ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false]) + ->addColumn('controller', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器', 'null' => false]) + ->addColumn('controller_as', 'string', ['limit' => 100, 'default' => '', 'comment' => '控制器别名', 'null' => false]) + ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '对应数据表', 'null' => false]) + ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false]) ->addColumn('data_fields', 'text', ['null' => true, 'default' => null, 'comment' => '敏感数据字段']) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用']) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false]) ->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); @@ -349,19 +349,19 @@ public function securitySensitiveDataLog() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('admin_id', 'integer', ['comment' => '操作管理员', 'default' => 0, 'signed' => false]) - ->addColumn('sensitive_id', 'integer', ['comment' => '敏感数据规则ID', 'default' => 0, 'signed' => false]) - ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据表']) - ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键']) - ->addColumn('data_field', 'string', ['limit' => 50, 'default' => '', 'comment' => '被修改字段']) - ->addColumn('data_comment', 'string', ['limit' => 50, 'default' => '', 'comment' => '被修改项']) - ->addColumn('id_value', 'integer', ['comment' => '被修改项主键值', 'default' => 0]) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('admin_id', 'integer', ['comment' => '操作管理员', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('sensitive_id', 'integer', ['comment' => '敏感数据规则ID', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('data_table', 'string', ['limit' => 100, 'default' => '', 'comment' => '数据表', 'null' => false]) + ->addColumn('primary_key', 'string', ['limit' => 50, 'default' => '', 'comment' => '数据表主键', 'null' => false]) + ->addColumn('data_field', 'string', ['limit' => 50, 'default' => '', 'comment' => '被修改字段', 'null' => false]) + ->addColumn('data_comment', 'string', ['limit' => 50, 'default' => '', 'comment' => '被修改项', 'null' => false]) + ->addColumn('id_value', 'integer', ['comment' => '被修改项主键值', 'default' => 0, 'null' => false]) ->addColumn('before', 'text', ['null' => true, 'default' => null, 'comment' => '修改前']) ->addColumn('after', 'text', ['null' => true, 'default' => null, 'comment' => '修改后']) - ->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '操作者IP']) - ->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent']) - ->addColumn('is_rollback', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '是否已回滚:0=否,1=是']) + ->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '操作者IP', 'null' => false]) + ->addColumn('useragent', 'string', ['limit' => 255, 'default' => '', 'comment' => 'User-Agent', 'null' => false]) + ->addColumn('is_rollback', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '是否已回滚:0=否,1=是', 'null' => false]) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); } @@ -377,16 +377,16 @@ public function testBuild() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '标题']) - ->addColumn('keyword_rows', 'string', ['limit' => 100, 'default' => '', 'comment' => '关键词']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('title', 'string', ['limit' => 100, 'default' => '', 'comment' => '标题', 'null' => false]) + ->addColumn('keyword_rows', 'string', ['limit' => 100, 'default' => '', 'comment' => '关键词', 'null' => false]) ->addColumn('content', 'text', ['null' => true, 'default' => null, 'comment' => '内容']) - ->addColumn('views', 'integer', ['comment' => '浏览量', 'default' => 0, 'signed' => false]) - ->addColumn('likes', 'integer', ['comment' => '有帮助数', 'default' => 0, 'signed' => false]) - ->addColumn('dislikes', 'integer', ['comment' => '无帮助数', 'default' => 0, 'signed' => false]) - ->addColumn('note_textarea', 'string', ['limit' => 100, 'default' => '', 'comment' => '备注']) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=隐藏,1=正常']) - ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0]) + ->addColumn('views', 'integer', ['comment' => '浏览量', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('likes', 'integer', ['comment' => '有帮助数', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('dislikes', 'integer', ['comment' => '无帮助数', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('note_textarea', 'string', ['limit' => 100, 'default' => '', 'comment' => '备注', 'null' => false]) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=隐藏,1=正常', 'null' => false]) + ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false]) ->addColumn('update_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('create_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); @@ -403,9 +403,9 @@ public function token() 'primary_key' => 'token', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('token', 'string', ['limit' => 50, 'default' => '', 'comment' => 'Token']) - ->addColumn('type', 'string', ['limit' => 15, 'default' => '', 'comment' => '类型']) - ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'default' => 0, 'signed' => false]) + $table->addColumn('token', 'string', ['limit' => 50, 'default' => '', 'comment' => 'Token', 'null' => false]) + ->addColumn('type', 'string', ['limit' => 15, 'default' => '', 'comment' => '类型', 'null' => false]) + ->addColumn('user_id', 'integer', ['comment' => '用户ID', 'default' => 0, 'signed' => false, 'null' => false]) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->addColumn('expiretime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间']) ->create(); @@ -422,26 +422,26 @@ public function user() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('group_id', 'integer', ['comment' => '分组ID', 'default' => 0, 'signed' => false]) - ->addColumn('username', 'string', ['limit' => 32, 'default' => '', 'comment' => '用户名']) - ->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '昵称']) - ->addColumn('email', 'string', ['limit' => 50, 'default' => '', 'comment' => '邮箱']) - ->addColumn('mobile', 'string', ['limit' => 11, 'default' => '', 'comment' => '手机']) - ->addColumn('avatar', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像']) - ->addColumn('gender', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '性别:0=未知,1=男,2=女']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('group_id', 'integer', ['comment' => '分组ID', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('username', 'string', ['limit' => 32, 'default' => '', 'comment' => '用户名', 'null' => false]) + ->addColumn('nickname', 'string', ['limit' => 50, 'default' => '', 'comment' => '昵称', 'null' => false]) + ->addColumn('email', 'string', ['limit' => 50, 'default' => '', 'comment' => '邮箱', 'null' => false]) + ->addColumn('mobile', 'string', ['limit' => 11, 'default' => '', 'comment' => '手机', 'null' => false]) + ->addColumn('avatar', 'string', ['limit' => 255, 'default' => '', 'comment' => '头像', 'null' => false]) + ->addColumn('gender', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '性别:0=未知,1=男,2=女', 'null' => false]) ->addColumn('birthday', 'date', ['null' => true, 'default' => null, 'comment' => '生日']) - ->addColumn('money', 'integer', ['comment' => '余额', 'default' => 0, 'signed' => false]) - ->addColumn('score', 'integer', ['comment' => '积分', 'default' => 0, 'signed' => false]) + ->addColumn('money', 'integer', ['comment' => '余额', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('score', 'integer', ['comment' => '积分', 'default' => 0, 'signed' => false, 'null' => false]) ->addColumn('lastlogintime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '上次登录时间']) - ->addColumn('lastloginip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP']) - ->addColumn('loginfailure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数']) - ->addColumn('joinip', 'string', ['limit' => 50, 'default' => '', 'comment' => '加入IP']) + ->addColumn('lastloginip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP', 'null' => false]) + ->addColumn('loginfailure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数', 'null' => false]) + ->addColumn('joinip', 'string', ['limit' => 50, 'default' => '', 'comment' => '加入IP', 'null' => false]) ->addColumn('jointime', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '加入时间']) - ->addColumn('motto', 'string', ['limit' => 255, 'default' => '', 'comment' => '签名']) - ->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '密码']) - ->addColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐']) - ->addColumn('status', 'string', ['limit' => 30, 'default' => '', 'comment' => '状态']) + ->addColumn('motto', 'string', ['limit' => 255, 'default' => '', 'comment' => '签名', 'null' => false]) + ->addColumn('password', 'string', ['limit' => 32, 'default' => '', 'comment' => '密码', 'null' => false]) + ->addColumn('salt', 'string', ['limit' => 30, 'default' => '', 'comment' => '密码盐', 'null' => false]) + ->addColumn('status', 'string', ['limit' => 30, 'default' => '', 'comment' => '状态', 'null' => false]) ->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->addIndex(['username'], [ @@ -467,10 +467,10 @@ public function userGroup() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '组名']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '组名', 'null' => false]) ->addColumn('rules', 'text', ['null' => true, 'default' => null, 'comment' => '权限节点']) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用']) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false]) ->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); @@ -487,12 +487,12 @@ public function userMoneyLog() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('user_id', 'integer', ['comment' => '会员ID', 'default' => 0, 'signed' => false]) - ->addColumn('money', 'integer', ['comment' => '变更余额', 'default' => 0]) - ->addColumn('before', 'integer', ['comment' => '变更前余额', 'default' => 0]) - ->addColumn('after', 'integer', ['comment' => '变更后余额', 'default' => 0]) - ->addColumn('memo', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('user_id', 'integer', ['comment' => '会员ID', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('money', 'integer', ['comment' => '变更余额', 'default' => 0, 'null' => false]) + ->addColumn('before', 'integer', ['comment' => '变更前余额', 'default' => 0, 'null' => false]) + ->addColumn('after', 'integer', ['comment' => '变更后余额', 'default' => 0, 'null' => false]) + ->addColumn('memo', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false]) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); } @@ -508,21 +508,21 @@ public function userRule() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('pid', 'integer', ['comment' => '上级菜单', 'default' => 0, 'signed' => false]) - ->addColumn('type', 'enum', ['values' => 'route,menu_dir,menu,nav_user_menu,nav,button', 'default' => 'menu', 'comment' => '类型:route=路由,menu_dir=菜单目录,menu=菜单项,nav_user_menu=顶栏会员菜单下拉项,nav=顶栏菜单项,button=页面按钮']) - ->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '标题']) - ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称']) - ->addColumn('path', 'string', ['limit' => 100, 'default' => '', 'comment' => '路由路径']) - ->addColumn('icon', 'string', ['limit' => 50, 'default' => '', 'comment' => '图标']) - ->addColumn('menu_type', 'enum', ['values' => 'tab,link,iframe', 'default' => 'tab', 'comment' => '菜单类型:tab=选项卡,link=链接,iframe=Iframe']) - ->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => 'Url']) - ->addColumn('component', 'string', ['limit' => 100, 'default' => '', 'comment' => '组件路径']) - ->addColumn('no_login_valid', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '未登录有效:0=否,1=是']) - ->addColumn('extend', 'enum', ['values' => 'none,add_rules_only,add_menu_only', 'default' => 'none', 'comment' => '扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单']) - ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注']) - ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0]) - ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('pid', 'integer', ['comment' => '上级菜单', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('type', 'enum', ['values' => 'route,menu_dir,menu,nav_user_menu,nav,button', 'default' => 'menu', 'comment' => '类型:route=路由,menu_dir=菜单目录,menu=菜单项,nav_user_menu=顶栏会员菜单下拉项,nav=顶栏菜单项,button=页面按钮', 'null' => false]) + ->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '标题', 'null' => false]) + ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '规则名称', 'null' => false]) + ->addColumn('path', 'string', ['limit' => 100, 'default' => '', 'comment' => '路由路径', 'null' => false]) + ->addColumn('icon', 'string', ['limit' => 50, 'default' => '', 'comment' => '图标', 'null' => false]) + ->addColumn('menu_type', 'enum', ['values' => 'tab,link,iframe', 'default' => 'tab', 'comment' => '菜单类型:tab=选项卡,link=链接,iframe=Iframe', 'null' => false]) + ->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => 'Url', 'null' => false]) + ->addColumn('component', 'string', ['limit' => 100, 'default' => '', 'comment' => '组件路径', 'null' => false]) + ->addColumn('no_login_valid', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '未登录有效:0=否,1=是', 'null' => false]) + ->addColumn('extend', 'enum', ['values' => 'none,add_rules_only,add_menu_only', 'default' => 'none', 'comment' => '扩展属性:none=无,add_rules_only=只添加为路由,add_menu_only=只添加为菜单', 'null' => false]) + ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false]) + ->addColumn('weigh', 'integer', ['comment' => '权重', 'default' => 0, 'null' => false]) + ->addColumn('status', 'enum', ['values' => '0,1', 'default' => '1', 'comment' => '状态:0=禁用,1=启用', 'null' => false]) ->addColumn('updatetime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->addIndex(['pid'], [ @@ -542,12 +542,12 @@ public function userScoreLog() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('user_id', 'integer', ['comment' => '会员ID', 'default' => 0, 'signed' => false]) - ->addColumn('score', 'integer', ['comment' => '变更积分', 'default' => 0]) - ->addColumn('before', 'integer', ['comment' => '变更前积分', 'default' => 0]) - ->addColumn('after', 'integer', ['comment' => '变更后积分', 'default' => 0]) - ->addColumn('memo', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('user_id', 'integer', ['comment' => '会员ID', 'default' => 0, 'signed' => false, 'null' => false]) + ->addColumn('score', 'integer', ['comment' => '变更积分', 'default' => 0, 'null' => false]) + ->addColumn('before', 'integer', ['comment' => '变更前积分', 'default' => 0, 'null' => false]) + ->addColumn('after', 'integer', ['comment' => '变更后积分', 'default' => 0, 'null' => false]) + ->addColumn('memo', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'null' => false]) ->addColumn('createtime', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); } @@ -563,11 +563,11 @@ public function crudLog() 'primary_key' => 'id', 'collation' => 'utf8mb4_unicode_ci', ]); - $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true]) - ->addColumn('table_name', 'string', ['limit' => 200, 'default' => '', 'comment' => '数据表名']) + $table->addColumn('id', 'integer', ['comment' => 'ID', 'signed' => false, 'identity' => true, 'null' => false]) + ->addColumn('table_name', 'string', ['limit' => 200, 'default' => '', 'comment' => '数据表名', 'null' => false]) ->addColumn('table', 'text', ['null' => true, 'default' => null, 'comment' => '数据表数据']) ->addColumn('fields', 'text', ['null' => true, 'default' => null, 'comment' => '字段数据']) - ->addColumn('status', 'enum', ['values' => 'delete,success,error,start', 'default' => 'start', 'comment' => '状态:delete=已删除,success=成功,error=失败,start=生成中']) + ->addColumn('status', 'enum', ['values' => 'delete,success,error,start', 'default' => 'start', 'comment' => '状态:delete=已删除,success=成功,error=失败,start=生成中', 'null' => false]) ->addColumn('create_time', 'biginteger', ['signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->create(); } diff --git a/database/migrations/20230620180916_install_data.php b/database/migrations/20230620180916_install_data.php index 6c85e073..0136836b 100644 --- a/database/migrations/20230620180916_install_data.php +++ b/database/migrations/20230620180916_install_data.php @@ -7,15 +7,9 @@ class InstallData extends Migrator { public string $nowTime = ''; - protected function init() - { - parent::init(); - $this->nowTime = time(); - } - public function up() { - parent::up(); + $this->nowTime = time(); $this->admin(); $this->adminGroup(); $this->adminGroupAccess(); diff --git a/database/migrations/20230622221507_version200.php b/database/migrations/20230622221507_version200.php index 20ba6c91..0db9f10e 100644 --- a/database/migrations/20230622221507_version200.php +++ b/database/migrations/20230622221507_version200.php @@ -8,7 +8,6 @@ class Version200 extends Migrator { public function up() { - parent::up(); $admin = $this->table('admin'); if ($admin->hasColumn('loginfailure')) { // 字段改名 @@ -17,10 +16,6 @@ public function up() ->renameColumn('lastloginip', 'last_login_ip') ->renameColumn('updatetime', 'update_time') ->renameColumn('createtime', 'create_time') - // 改名后需要重设属性以免部分属性丢失 - ->changeColumn('login_failure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数']) - ->changeColumn('last_login_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '上次登录时间']) - ->changeColumn('last_login_ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP']) ->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->changeColumn('create_time', 'biginteger', ['after' => 'update_time', 'limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->save(); @@ -153,7 +148,7 @@ public function up() ->renameColumn('createtime', 'create_time') ->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) - ->changeColumn('type', 'enum', ['values' => 'route,menu_dir,menu,nav_user_menu,nav,button', 'default' => 'menu', 'comment' => '类型:route=路由,menu_dir=菜单目录,menu=菜单项,nav_user_menu=顶栏会员菜单下拉项,nav=顶栏菜单项,button=页面按钮']); + ->changeColumn('type', 'enum', ['values' => 'route,menu_dir,menu,nav_user_menu,nav,button', 'default' => 'menu', 'comment' => '类型:route=路由,menu_dir=菜单目录,menu=菜单项,nav_user_menu=顶栏会员菜单下拉项,nav=顶栏菜单项,button=页面按钮', 'null' => false]); if (!$userRule->hasColumn('no_login_valid')) { $userRule->addColumn('no_login_valid', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '未登录有效:0=否,1=是']); } @@ -176,11 +171,6 @@ public function up() ->renameColumn('jointime', 'join_time') ->renameColumn('updatetime', 'update_time') ->renameColumn('createtime', 'create_time') - ->changeColumn('last_login_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '上次登录时间']) - ->changeColumn('last_login_ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '上次登录IP']) - ->changeColumn('login_failure', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '登录失败次数']) - ->changeColumn('join_ip', 'string', ['limit' => 50, 'default' => '', 'comment' => '加入IP']) - ->changeColumn('join_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '加入时间']) ->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间']) ->changeColumn('create_time', 'biginteger', ['after' => 'update_time', 'limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间']) ->save(); diff --git a/database/migrations/20230719211338_version201.php b/database/migrations/20230719211338_version201.php index eae38802..f17c57ab 100644 --- a/database/migrations/20230719211338_version201.php +++ b/database/migrations/20230719211338_version201.php @@ -6,7 +6,6 @@ class Version201 extends Migrator { public function up() { - parent::up(); $user = $this->table('user'); if ($user->hasIndex('email')) { $user->removeIndexByName('email') diff --git a/database/migrations/20230905060702_version202.php b/database/migrations/20230905060702_version202.php index 16973681..5585a738 100644 --- a/database/migrations/20230905060702_version202.php +++ b/database/migrations/20230905060702_version202.php @@ -11,7 +11,6 @@ class Version202 extends Migrator */ public function up() { - parent::up(); Db::startTrans(); try { $dashboardId = Db::name('admin_rule') diff --git a/extend/ba/TableManager.php b/extend/ba/TableManager.php index a5dff43f..d7274d70 100644 --- a/extend/ba/TableManager.php +++ b/extend/ba/TableManager.php @@ -123,7 +123,7 @@ protected static function getDbConfig(): array $table = Config::get('database.migration_table', 'migrations'); - $dbConfig['default_migration_table'] = $dbConfig['table_prefix'] . $table; + $dbConfig['migration_table'] = $dbConfig['table_prefix'] . $table; return $dbConfig; }