|
@@ -1,15 +1,13 @@
|
|
|
<?php
|
|
<?php
|
|
|
declare(strict_types=1);
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
-use think\migration\Migrator;
|
|
|
|
|
-use think\migration\db\Column;
|
|
|
|
|
|
|
|
|
|
-class CreateMessageTables extends Migrator
|
|
|
|
|
|
|
+class CreateMessageTables extends \Phinx\Migration\AbstractMigration
|
|
|
{
|
|
{
|
|
|
/**
|
|
/**
|
|
|
* 执行迁移
|
|
* 执行迁移
|
|
|
*/
|
|
*/
|
|
|
- public function up()
|
|
|
|
|
|
|
+ public function change(): void
|
|
|
{
|
|
{
|
|
|
// 创建系统公告表
|
|
// 创建系统公告表
|
|
|
$this->table('message_announcements', [
|
|
$this->table('message_announcements', [
|
|
@@ -103,6 +101,9 @@ class CreateMessageTables extends Migrator
|
|
|
->addIndex(['code'], ['name' => 'idx_code', 'unique' => true])
|
|
->addIndex(['code'], ['name' => 'idx_code', 'unique' => true])
|
|
|
->create();
|
|
->create();
|
|
|
|
|
|
|
|
|
|
+ if (!$this->isMigratingUp()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
// 插入默认消息模板数据
|
|
// 插入默认消息模板数据
|
|
|
$currentTime = time();
|
|
$currentTime = time();
|
|
|
$this->table('message_templates')
|
|
$this->table('message_templates')
|
|
@@ -176,16 +177,4 @@ class CreateMessageTables extends Migrator
|
|
|
])
|
|
])
|
|
|
->save();
|
|
->save();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 回滚迁移
|
|
|
|
|
- */
|
|
|
|
|
- public function down()
|
|
|
|
|
- {
|
|
|
|
|
- $this->table('message_announcements')->drop();
|
|
|
|
|
- $this->table('message_notifications')->drop();
|
|
|
|
|
- $this->table('message_privates')->drop();
|
|
|
|
|
- $this->table('message_settings')->drop();
|
|
|
|
|
- $this->table('message_templates')->drop();
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|