Procházet zdrojové kódy

refactor(migrations): 统一数据库迁移文件格式

- 为所有迁移文件添加 declare(strict_types=1) 声明
- 移除旧版 Column 类的使用,改用数组配置方式定义字段
- 统一时间戳字段命名为 create_time 和 update_time
- 使用 addColumn 方法替代 addTimestamps 和 addSoftDelete
- 标准化字段定义参数格式,提升代码一致性
runphp před 3 měsíci
rodič
revize
96a3ecab2e

+ 7 - 7
database/migrations/20250709013140_extension_wechat_user.php

@@ -1,7 +1,7 @@
 <?php
+declare(strict_types=1);
 
 use Phinx\Migration\AbstractMigration;
-use think\migration\db\Column;
 
 class ExtensionWechatUser extends AbstractMigration
 {
@@ -30,13 +30,13 @@ class ExtensionWechatUser extends AbstractMigration
     {
         $table = $this->table('extension_wechat_user', ['engine' => 'InnoDB', 'comment' => '微信用户表']);
         $table
-            ->addColumn(Column::integer('user_id')->setSigned(false)->setComment('用户ID'))
-            ->addColumn(Column::string('openid')->setComment('微信openid'))
-            ->addColumn(Column::string('appid')->setComment('微信appid'))
-            ->addColumn(Column::string('nickname')->setComment('昵称'))
-            ->addColumn(Column::string('avatar')->setComment('头像'))
+            ->addColumn('user_id', 'integer', ['signed' => false, 'comment' => '用户ID'])
+            ->addColumn('openid', 'string', ['comment' => '微信openid'])
+            ->addColumn('appid', 'string', ['comment' => '微信appid'])
+            ->addColumn('nickname', 'string', ['comment' => '昵称'])
+            ->addColumn('avatar', 'string', ['comment' => '头像'])
             ->addTimestamps('create_time', 'update_time')
-            ->addSoftDelete()
+            ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间'])
             ->create();
     }
 }

+ 2 - 1
database/migrations/20250709024603_extension_wechat_user_add_session_key.php

@@ -1,7 +1,8 @@
 <?php
 
+declare(strict_types=1);
+
 use Phinx\Migration\AbstractMigration;
-use think\migration\db\Column;
 
 class ExtensionWechatUserAddSessionKey extends AbstractMigration
 {