1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 20:52:44 +08:00

整理migrations

This commit is contained in:
koogua 2022-08-19 17:10:30 +08:00
parent 290fda610b
commit 21f79dad80
15 changed files with 178 additions and 721 deletions

View File

@ -3268,619 +3268,6 @@ final class V20210324064239 extends AbstractMigration
'after' => 'create_time',
])
->create();
$this->table('kg_im_friend_group', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'identity' => 'enable',
'comment' => '主键编号',
])
->addColumn('user_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '用户编号',
'after' => 'id',
])
->addColumn('name', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '名称',
'after' => 'user_id',
])
->addColumn('priority', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '优先级',
'after' => 'name',
])
->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'priority',
])
->addColumn('user_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '成员数',
'after' => 'deleted',
])
->addColumn('create_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '创建时间',
'after' => 'user_count',
])
->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
])
->addIndex(['user_id'], [
'name' => 'user_id',
'unique' => true,
])
->create();
$this->table('kg_im_friend_user', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'identity' => 'enable',
'comment' => '主键编号',
])
->addColumn('user_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '用户编号',
'after' => 'id',
])
->addColumn('friend_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '目标编号',
'after' => 'user_id',
])
->addColumn('group_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '分组编号',
'after' => 'friend_id',
])
->addColumn('msg_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '消息数',
'after' => 'group_id',
])
->addColumn('create_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '创建时间',
'after' => 'msg_count',
])
->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
])
->addIndex(['user_id', 'friend_id'], [
'name' => 'user_friend',
'unique' => false,
])
->create();
$this->table('kg_im_group', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'identity' => 'enable',
'comment' => '主键编号',
])
->addColumn('owner_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '群主编号',
'after' => 'id',
])
->addColumn('course_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '课程编号',
'after' => 'owner_id',
])
->addColumn('type', 'integer', [
'null' => false,
'default' => '1',
'limit' => MysqlAdapter::INT_REGULAR,
'comment' => '类型',
'after' => 'course_id',
])
->addColumn('name', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '名称',
'after' => 'type',
])
->addColumn('avatar', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '头像',
'after' => 'name',
])
->addColumn('about', 'string', [
'null' => false,
'default' => '',
'limit' => 255,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '简介',
'after' => 'avatar',
])
->addColumn('published', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '发布标识',
'after' => 'about',
])
->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'published',
])
->addColumn('user_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '成员数',
'after' => 'deleted',
])
->addColumn('msg_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '消息数',
'after' => 'user_count',
])
->addColumn('create_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '创建时间',
'after' => 'msg_count',
])
->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
])
->create();
$this->table('kg_im_group_user', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'identity' => 'enable',
'comment' => '主键编号',
])
->addColumn('group_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '群组编号',
'after' => 'id',
])
->addColumn('user_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '用户编号',
'after' => 'group_id',
])
->addColumn('priority', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '优先级',
'after' => 'user_id',
])
->addColumn('create_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '创建时间',
'after' => 'priority',
])
->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
])
->addIndex(['group_id'], [
'name' => 'group_id',
'unique' => false,
])
->addIndex(['group_id', 'user_id'], [
'name' => 'group_user',
'unique' => false,
])
->addIndex(['user_id'], [
'name' => 'user_id',
'unique' => false,
])
->create();
$this->table('kg_im_message', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'identity' => 'enable',
'comment' => '主键编号',
])
->addColumn('chat_id', 'string', [
'null' => false,
'default' => '',
'limit' => 30,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '对话编号',
'after' => 'id',
])
->addColumn('sender_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '发送方',
'after' => 'chat_id',
])
->addColumn('receiver_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '接收方',
'after' => 'sender_id',
])
->addColumn('receiver_type', 'integer', [
'null' => false,
'default' => '1',
'limit' => MysqlAdapter::INT_REGULAR,
'comment' => '接收方类型',
'after' => 'receiver_id',
])
->addColumn('content', 'string', [
'null' => false,
'default' => '',
'limit' => 3000,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '内容',
'after' => 'receiver_type',
])
->addColumn('viewed', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '已读标识',
'after' => 'content',
])
->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'viewed',
])
->addColumn('create_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '创建时间',
'after' => 'deleted',
])
->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
])
->addIndex(['chat_id'], [
'name' => 'chat_id',
'unique' => false,
])
->addIndex(['receiver_id', 'receiver_type'], [
'name' => 'receiver',
'unique' => false,
])
->create();
$this->table('kg_im_notice', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'identity' => 'enable',
'comment' => '主键编号',
])
->addColumn('sender_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '发送方',
'after' => 'id',
])
->addColumn('receiver_id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '接收方',
'after' => 'sender_id',
])
->addColumn('item_type', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '条目类型',
'after' => 'receiver_id',
])
->addColumn('item_info', 'string', [
'null' => false,
'default' => '',
'limit' => 1500,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '条目内容',
'after' => 'item_type',
])
->addColumn('viewed', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '已读标识',
'after' => 'item_info',
])
->addColumn('create_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '创建时间',
'after' => 'viewed',
])
->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
])
->addIndex(['receiver_id'], [
'name' => 'receiver_id',
'unique' => false,
])
->addIndex(['sender_id'], [
'name' => 'sender_id',
'unique' => false,
])
->create();
$this->table('kg_im_user', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->addColumn('id', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '主键编号',
])
->addColumn('name', 'string', [
'null' => false,
'default' => '',
'limit' => 30,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '名称',
'after' => 'id',
])
->addColumn('avatar', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '头像',
'after' => 'name',
])
->addColumn('sign', 'string', [
'null' => false,
'default' => '',
'limit' => 30,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '签名',
'after' => 'avatar',
])
->addColumn('skin', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '皮肤',
'after' => 'sign',
])
->addColumn('status', 'string', [
'null' => false,
'default' => 'hide',
'limit' => 15,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '在线状态',
'after' => 'skin',
])
->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'status',
])
->addColumn('friend_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '好友数',
'after' => 'deleted',
])
->addColumn('group_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '群组数',
'after' => 'friend_count',
])
->addColumn('create_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '创建时间',
'after' => 'group_count',
])
->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
])
->create();
$this->table('kg_learning', [
'id' => false,
'primary_key' => ['id'],

View File

@ -46,15 +46,6 @@ final class V20210403184518 extends AbstractMigration
];
$this->table('kg_user')->insert($user)->saveData();
$imUser = [
'id' => $user['id'],
'name' => $user['name'],
'avatar' => $user['avatar'],
'create_time' => $now,
];
$this->table('kg_im_user')->insert($imUser)->saveData();
}
protected function initRoleData()
@ -949,7 +940,6 @@ final class V20210403184518 extends AbstractMigration
'course_review' => ['enabled' => 1, 'point' => 50],
'chapter_study' => ['enabled' => 1, 'point' => 10],
'site_visit' => ['enabled' => 1, 'point' => 10],
'im_discuss' => ['enabled' => 1, 'point' => 10],
'article_post' => ['enabled' => 1, 'point' => 20, 'limit' => 50],
'question_post' => ['enabled' => 1, 'point' => 5, 'limit' => 50],
'answer_post' => ['enabled' => 1, 'point' => 5, 'limit' => 50],

View File

@ -27,7 +27,13 @@ final class V20210720153027 extends AbstractMigration
protected function createCourseTagTable()
{
$this->table('kg_course_tag', [
$tableName = 'kg_course_tag';
if ($this->table($tableName)->exists()) {
return;
}
$this->table($tableName, [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
@ -80,8 +86,10 @@ final class V20210720153027 extends AbstractMigration
protected function alterCourseTable()
{
$this->table('kg_course')
->addColumn('tags', 'string', [
$table = $this->table('kg_course');
if ($table->hasColumn('tags') == false) {
$table->addColumn('tags', 'string', [
'null' => false,
'default' => '',
'limit' => 255,
@ -89,13 +97,18 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '标签',
'after' => 'summary',
])->save();
]);
}
$table->save();
}
protected function alterCategoryTable()
{
$this->table('kg_category')
->addColumn('alias', 'string', [
$table = $this->table('kg_category');
if ($table->hasColumn('alias') == false) {
$table->addColumn('alias', 'string', [
'null' => false,
'default' => '',
'limit' => 30,
@ -103,7 +116,11 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '别名',
'after' => 'name',
])->addColumn('icon', 'string', [
]);
}
if ($table->hasColumn('icon') == false) {
$table->addColumn('icon', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
@ -111,13 +128,19 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '图标',
'after' => 'name',
])->save();
]);
}
$table->save();
}
protected function alterTagTable()
{
$this->table('kg_tag')
->addColumn('scopes', 'string', [
$table = $this->table('kg_tag');
if ($table->hasColumn('scopes') == false) {
$table->addColumn('scopes', 'string', [
'null' => false,
'default' => '',
'limit' => 100,
@ -125,32 +148,43 @@ final class V20210720153027 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '范围',
'after' => 'icon',
])
->addColumn('course_count', 'integer', [
]);
}
if ($table->hasColumn('course_count') == false) {
$table->addColumn('course_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '课程数',
'after' => 'follow_count',
])
->addColumn('article_count', 'integer', [
]);
}
if ($table->hasColumn('article_count') == false) {
$table->addColumn('article_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '文章数',
'after' => 'course_count',
])
->addColumn('question_count', 'integer', [
]);
}
if ($table->hasColumn('question_count') == false) {
$table->addColumn('question_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '问题数',
'after' => 'article_count',
])
->save();
]);
}
$table->save();
}
protected function handleCourseTags()

View File

@ -17,8 +17,10 @@ final class V20210802021814 extends AbstractMigration
protected function alterPageTable()
{
$this->table('kg_page')
->addColumn('alias', 'string', [
$table = $this->table('kg_page');
if ($table->hasColumn('alias') == false) {
$table->addColumn('alias', 'string', [
'null' => false,
'default' => '',
'limit' => 50,
@ -26,7 +28,10 @@ final class V20210802021814 extends AbstractMigration
'encoding' => 'utf8mb4',
'comment' => '别名',
'after' => 'title',
])->save();
]);
}
$table->save();
}
}

View File

@ -5,19 +5,22 @@
* @link https://www.koogua.com
*/
require_once 'SettingTrait.php';
use Phinx\Migration\AbstractMigration;
final class V20210809153030 extends AbstractMigration
{
use SettingTrait;
public function up()
{
$this->handleVodSetting();
$this->handleImSetting();
$this->handleVodSettings();
$this->handleRemotePlayUrl();
}
protected function handleVodSetting()
protected function handleVodSettings()
{
$rows = [
[
@ -32,18 +35,7 @@ final class V20210809153030 extends AbstractMigration
],
];
$this->table('kg_setting')->insert($rows)->save();
}
protected function handleImSetting()
{
$row = [
'section' => 'im.main',
'item_key' => 'enabled',
'item_value' => '1',
];
$this->table('kg_setting')->insert($row)->saveData();
$this->insertSettings($rows);
}
protected function handleRemotePlayUrl()

View File

@ -5,17 +5,21 @@
* @link https://www.koogua.com
*/
require_once 'SettingTrait.php';
use Phinx\Migration\AbstractMigration;
final class V20210820064755 extends AbstractMigration
{
use SettingTrait;
public function up()
{
$this->handleContactSetting();
$this->handleContactSettings();
}
protected function handleContactSetting()
protected function handleContactSettings()
{
$rows = [
[
@ -65,7 +69,7 @@ final class V20210820064755 extends AbstractMigration
],
];
$this->table('kg_setting')->insert($rows)->save();
$this->insertSettings($rows);
}
}

View File

@ -19,9 +19,11 @@ final class V20210825111618 extends AbstractMigration
{
$table = $this->table('kg_upload');
$table->removeIndexByName('md5')->save();
if ($table->hasIndexByName('md5')) {
$table->removeIndexByName('md5')->save();
$table->addIndex('md5')->save();
}
$table->addIndex('md5')->save();
}
}

View File

@ -5,17 +5,21 @@
* @link https://www.koogua.com
*/
require_once 'SettingTrait.php';
use Phinx\Migration\AbstractMigration;
final class V20210903040558 extends AbstractMigration
{
use SettingTrait;
public function up()
{
$this->handleVodSetting();
$this->handleVodSettings();
}
protected function handleVodSetting()
protected function handleVodSettings()
{
$row = $this->getQueryBuilder()
->select('*')

View File

@ -7,15 +7,19 @@
use Phinx\Migration\AbstractMigration;
require_once 'SettingTrait.php';
final class V20210916072842 extends AbstractMigration
{
use SettingTrait;
public function up()
{
$this->handleLocalAuthSetting();
$this->handleLocalAuthSettings();
}
protected function handleLocalAuthSetting()
protected function handleLocalAuthSettings()
{
$rows = [
[
@ -30,7 +34,7 @@ final class V20210916072842 extends AbstractMigration
]
];
$this->table('kg_setting')->insert($rows)->save();
$this->insertSettings($rows);
}
}

View File

@ -5,16 +5,20 @@
* @link https://www.koogua.com
*/
require_once 'SettingTrait.php';
use Phinx\Db\Adapter\MysqlAdapter;
class V20210917093354 extends Phinx\Migration\AbstractMigration
{
use SettingTrait;
public function up()
{
$this->alterConnectTable();
$this->alterWechatSubscribeTable();
$this->handleLocalAuthSetting();
$this->handleLocalAuthSettings();
}
protected function alterConnectTable()
@ -92,7 +96,7 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
$table->save();
}
protected function handleLocalAuthSetting()
protected function handleLocalAuthSettings()
{
$rows = [
[
@ -107,7 +111,7 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
]
];
$this->table('kg_setting')->insert($rows)->save();
$this->insertSettings($rows);
}
}

View File

@ -18,15 +18,20 @@ final class V20211017085325 extends AbstractMigration
protected function alterCourseTable()
{
$this->table('kg_course')
->addColumn('fake_user_count', 'integer', [
$table = $this->table('kg_course');
if ($table->hasColumn('fake_user_count') == false) {
$table->addColumn('fake_user_count', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '伪造用户数',
'after' => 'user_count',
])->save();
]);
}
$table->save();
}
}

View File

@ -19,28 +19,38 @@ final class V20211019093522 extends AbstractMigration
protected function alterUserSessionTable()
{
$this->table('kg_user_session')
->addColumn('deleted', 'integer', [
$table = $this->table('kg_user_session');
if ($table->hasColumn('deleted') == false) {
$table->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'client_ip',
])->save();
]);
}
$table->save();
}
protected function alterUserTokenTable()
{
$this->table('kg_user_token')
->addColumn('deleted', 'integer', [
$table = $this->table('kg_user_token');
if ($table->hasColumn('deleted') == false) {
$table->addColumn('deleted', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '删除标识',
'after' => 'client_ip',
])->save();
]);
}
$table->save();
}
}

View File

@ -2,26 +2,29 @@
use Phinx\Migration\AbstractMigration;
require_once 'SettingTrait.php';
final class V20211231013226 extends AbstractMigration
{
use SettingTrait;
public function up()
{
$this->handleSmsSetting();
$this->handleSmsSettings();
}
protected function handleSmsSetting()
protected function handleSmsSettings()
{
$row =
$rows = [
[
[
'section' => 'sms',
'item_key' => 'region',
'item_value' => 'ap-guangzhou',
]
];
'section' => 'sms',
'item_key' => 'region',
'item_value' => 'ap-guangzhou',
]
];
$this->table('kg_setting')->insert($row)->save();
$this->insertSettings($rows);
}
}

View File

@ -21,29 +21,28 @@ final class V20220607014823 extends AbstractMigration
protected function handleSiteSettings()
{
$rows =
$rows = [
[
[
'section' => 'site',
'item_key' => 'isp_sn',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'isp_link',
'item_value' => 'https://dxzhgl.miit.gov.cn',
],
[
'section' => 'site',
'item_key' => 'company_sn',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'company_sn_link',
'item_value' => '',
],
];
'section' => 'site',
'item_key' => 'isp_sn',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'isp_link',
'item_value' => 'https://dxzhgl.miit.gov.cn',
],
[
'section' => 'site',
'item_key' => 'company_sn',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'company_sn_link',
'item_value' => '',
],
];
$this->insertSettings($rows);
}

View File

@ -20,7 +20,13 @@ class V20220801025747 extends Phinx\Migration\AbstractMigration
protected function createMigrationTaskTable()
{
$this->table('kg_migration_task', [
$tableName = 'kg_migration_task';
if ($this->table($tableName)->exists()) {
return;
}
$this->table($tableName, [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
@ -70,13 +76,21 @@ class V20220801025747 extends Phinx\Migration\AbstractMigration
protected function dropImTables()
{
$this->table('kg_im_friend_group')->drop()->save();
$this->table('kg_im_friend_user')->drop()->save();
$this->table('kg_im_group')->drop()->save();
$this->table('kg_im_group_user')->drop()->save();
$this->table('kg_im_message')->drop()->save();
$this->table('kg_im_notice')->drop()->save();
$this->table('kg_im_user')->drop()->save();
$tableNames = [
'kg_im_friend_group',
'kg_im_friend_user',
'kg_im_group',
'kg_im_group_user',
'kg_im_message',
'kg_im_notice',
'kg_im_user',
];
foreach ($tableNames as $tableName) {
if ($this->table($tableName)->exists()) {
$this->table($tableName)->drop()->save();
}
}
}
protected function deleteImGroupNav()