refactor: 修改migration文件

This commit is contained in:
2025-03-15 16:55:32 +08:00
parent d8c38c1d58
commit 9cc9949ecc
4 changed files with 43 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ class CreateProductAttr extends Migrator
{
$table = $this->table('product_attr', ['engine' => 'InnoDB', 'comment' => '商品属性表']);
$table->addColumn('language_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '语言ID'])
->addColumn('attr_type', MysqlAdapter::INT_TINY, ['limit' => 3, 'null' => false, 'default' => 2, 'comment' => '类型:1为选项类型2为文本输入类型'])
->addColumn('attr_type', MysqlAdapter::PHINX_TYPE_TINY_INTEGER, ['limit' => 3, 'null' => false, 'default' => 2, 'comment' => '类型:1为选项类型2为文本输入类型'])
->addColumn('attr_name', 'string', ['limit' => 64, 'signed' => false, 'null' => false, 'comment' => '属性ID'])
->addColumn('is_system', 'boolean', ['null' => false, 'default' => 0, 'comment' => '是否系统属性:1是,0否'])
->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '新增时间'])

View File

@@ -38,7 +38,7 @@ class CreateVideo extends Migrator
->addColumn('link', 'string', ['limit' => 125, 'null' => true, 'default' => null, 'comment' => '外链地址'])
->addColumn('sort', 'integer', ['null' => false, 'default' => 0, 'comment' => '排序'])
->addColumn('recommend', 'boolean', ['null' => false, 'default' => 1, 'comment' => '是否推荐:1是,0否'])
->addColumn('status', MysqlAdapter::INT_TINY, ['null' => false, 'default' => 1, 'comment' => '状态:1启用,-1禁用'])
->addColumn('status', MysqlAdapter::PHINX_TYPE_TINY_INTEGER, ['null' => false, 'default' => 1, 'comment' => '状态:1启用,-1禁用'])
->addColumn('seo_title', 'string', ['limit' => 255, 'default' => null, 'comment' => 'SEO标题'])
->addColumn('seo_keywords', 'string', ['limit' => 255, 'default' => null, 'comment' => 'SEO关键字'])
->addColumn('seo_desc', 'string', ['limit' => 255, 'default' => null, 'comment' => 'SEO描述'])

View File

@@ -43,7 +43,7 @@ class CreateSysMenu extends Migrator
->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
->addColumn('updated_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间'])
->addColumn('deleted_at', 'timestamp', ['null' => true, 'comment' => '删除时间'])
->addIndex(['unique_name'], ['unique' => true])
->addIndex(['name'], ['unique' => true, 'name' => 'idx_unique_name'])
->create();
}
}

View File

@@ -0,0 +1,40 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class CreateSysRestfulApi extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('sys_restful_api', ['engine' => 'MyISAM', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统接口表']);
$table->addColumn('name', 'string', ['limit' => 64, 'default' => '', 'comment' => '接口名称'])
->addColumn('rule', 'string', ['limit' => 128, 'default' => '', 'comment' => '接口路由'])
->addColumn('method', 'string', ['limit' => 8, 'default' => '', 'comment' => '请求方式'])
->addColumn('desc', 'string', ['limit' => 255, 'default' => '', 'comment' => '接口描述'])
->addColumn('created_at', 'timestamp', ['null' => false,'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
->addColumn('updated_at', 'timestamp', ['null' => true,'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'comment' => '更新时间'])
->create();
}
}