浏览代码

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

- 为所有迁移文件添加 declare(strict_types=1) 声明
- 移除旧版 Column 类的使用,改用数组配置方式定义字段
- 统一时间戳字段命名为 create_time 和 update_time
- 使用 addColumn 方法替代 addTimestamps 和 addSoftDelete
- 标准化字段定义参数格式,提升代码一致性
runphp 3 月之前
父节点
当前提交
0e32f1b56f
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      database/migrations/20250917093821_notifications_timstamp.php

+ 4 - 3
database/migrations/20250917093821_notifications_timstamp.php

@@ -1,7 +1,8 @@
 <?php
 
+declare(strict_types=1);
+
 use Phinx\Migration\AbstractMigration;
-use think\migration\db\Column;
 
 class NotificationsTimstamp extends AbstractMigration
 {
@@ -33,8 +34,8 @@ class NotificationsTimstamp extends AbstractMigration
             ->removeColumn('update_time')
             ->removeColumn('delete_time')
             ->update();
-        $table->addTimestamps()
-            ->addSoftDelete()
+        $table->addTimestamps('create_time', 'update_time')
+            ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间'])
             ->update();
     }
     public function down()