1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-10 10:40:03 +08:00

整理migration

This commit is contained in:
koogua 2021-03-03 17:29:27 +08:00
parent da1d35399d
commit 9d4225f663
12 changed files with 54 additions and 123 deletions

View File

@ -2,8 +2,6 @@
namespace App\Models;
use Phalcon\Mvc\Model\Behavior\SoftDelete;
class ImNotice extends Model
{
@ -59,13 +57,6 @@ class ImNotice extends Model
*/
public $item_info = '';
/**
* 优先级
*
* @var int
*/
public $priority = 0;
/**
* 阅读标识
*
@ -73,13 +64,6 @@ class ImNotice extends Model
*/
public $viewed = 0;
/**
* 删除标识
*
* @var int
*/
public $deleted = 0;
/**
* 创建时间
*
@ -99,18 +83,6 @@ class ImNotice extends Model
return 'kg_im_notice';
}
public function initialize()
{
parent::initialize();
$this->addBehavior(
new SoftDelete([
'field' => 'deleted',
'value' => 1,
])
);
}
public function beforeCreate()
{
if (!empty($this->item_info)) {

View File

@ -28,10 +28,6 @@ class Connect extends Repository
$query->andWhere('provider = :provider:', ['provider' => $where['provider']]);
}
if (isset($where['deleted'])) {
$query->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
}
$query->orderBy('id DESC');
return $query->execute();

View File

@ -25,10 +25,6 @@ class CourseFavorite extends Repository
$builder->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]);
}
if (isset($where['deleted'])) {
$builder->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
}
switch ($sort) {
default:
$orderBy = 'id DESC';

View File

@ -25,10 +25,6 @@ class ImFriendUser extends Repository
$builder->andWhere('friend_id = :friend_id:', ['friend_id' => $where['friend_id']]);
}
if (isset($where['blocked'])) {
$builder->andWhere('blocked = :blocked:', ['blocked' => $where['blocked']]);
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';

View File

@ -27,10 +27,6 @@ class ImNotice extends Repository
$builder->andWhere('receiver_id = :receiver_id:', ['receiver_id' => $where['receiver_id']]);
}
if (isset($where['deleted'])) {
$builder->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
}
switch ($sort) {
case 'oldest':
$orderBy = 'id ASC';

View File

@ -17,7 +17,6 @@ class UserSession extends Repository
{
return UserSessionModel::query()
->where('user_id = :user_id:', ['user_id' => $userId])
->andWhere('deleted = 0')
->execute();
}

View File

@ -17,7 +17,6 @@ class UserToken extends Repository
{
return UserTokenModel::query()
->where('user_id = :user_id:', ['user_id' => $userId])
->andWhere('deleted = 0')
->execute();
}

View File

@ -81,35 +81,6 @@ class CreateOnlineTable extends Phinx\Migration\AbstractMigration
'unique' => false,
])
->create();
$this->table('kg_task', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '',
'row_format' => 'DYNAMIC',
])
->save();
$this->table('kg_trade', [
'id' => false,
'primary_key' => ['id'],
'engine' => 'InnoDB',
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'comment' => '主键编号',
'row_format' => 'DYNAMIC',
])
->changeColumn('channel_sn', 'string', [
'null' => false,
'default' => '',
'limit' => 64,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '平台序号',
'after' => 'channel',
])
->save();
}
}

View File

@ -80,9 +80,20 @@ final class InsertOauthSettingData extends AbstractMigration
public function down()
{
$this->execute("DELETE FROM kg_setting WHERE section = 'oauth.qq'");
$this->execute("DELETE FROM kg_setting WHERE section = 'oauth.weixin'");
$this->execute("DELETE FROM kg_setting WHERE section = 'oauth.weibo'");
$this->getQueryBuilder()
->delete('kg_setting')
->where(['section' => 'oauth.qq'])
->execute();
$this->getQueryBuilder()
->delete('kg_setting')
->where(['section' => 'oauth.weixin'])
->execute();
$this->getQueryBuilder()
->delete('kg_setting')
->where(['section' => 'oauth.weibo'])
->execute();
}
}

View File

@ -60,30 +60,27 @@ final class Data202012121830 extends AbstractMigration
protected function updateSmsTemplate()
{
$table = 'kg_setting';
$where = ['section' => 'sms', 'item_key' => 'template'];
$setting = $this->getQueryBuilder()
->select('*')
->from($table)
->where($where)
->execute()
->fetch('assoc');
->from('kg_setting')
->where(['section' => 'sms', 'item_key' => 'template'])
->execute()->fetch('assoc');
if (!$setting) return;
$itemValue = json_decode($setting['item_value'], true);
$newItemValue = json_encode([
'verify' => $itemValue['verify'],
'order_finish' => $itemValue['order'],
'refund_finish' => $itemValue['refund'],
'live_begin' => $itemValue['live'],
'consult_reply' => '',
'verify' => $itemValue['verify'] ?? '',
'order_finish' => $itemValue['order'] ?? '',
'refund_finish' => $itemValue['refund'] ?? '',
'live_begin' => $itemValue['live'] ?? '',
'consult_reply' => $itemValue['consult'] ?? '',
]);
$this->getQueryBuilder()
->update($table)
->where($where)
->update('kg_setting')
->where(['id' => $setting['id']])
->set('item_value', $newItemValue)
->execute();
}

View File

@ -13,27 +13,24 @@ final class Data202102280351 extends AbstractMigration
protected function updateSmsNoticeTemplate()
{
$table = 'kg_setting';
$where = [
'section' => 'sms',
'item_key' => 'template',
];
$setting = $this->getQueryBuilder()
->select('*')
->from($table)
->where($where)
->execute()
->fetch('assoc');
->from('kg_setting')
->where(['section' => 'sms', 'item_key' => 'template'])
->execute()->fetch('assoc');
if (!$setting) return;
$itemValue = json_decode($setting['item_value'], true);
$newItemValue = [];
/**
* 更改数据结构
*/
foreach ($itemValue as $key => $value) {
$newItemValue[$key]['id'] = $value;
$newItemValue[$key]['enabled'] = 1;
$newItemValue[$key]['id'] = $value['id'] ?? $value;
$newItemValue[$key]['enabled'] = $value['enabled'] ?? 1;
}
/**
@ -44,35 +41,30 @@ final class Data202102280351 extends AbstractMigration
$itemValue = json_encode($newItemValue);
$this->getQueryBuilder()
->update($table)
->where($where)
->update('kg_setting')
->where(['id' => $setting['id']])
->set('item_value', $itemValue)
->execute();
}
protected function updateWechatNoticeTemplate()
{
$table = 'kg_setting';
$where = [
'section' => 'wechat.oa',
'item_key' => 'notice_template',
];
$setting = $this->getQueryBuilder()
->select('*')
->from($table)
->where($where)
->execute()
->fetch('assoc');
->from('kg_setting')
->where(['section' => 'wechat.oa', 'item_key' => 'notice_template'])
->execute()->fetch('assoc');
$itemValue = json_decode($setting['item_value'], true);
$newItemValue = [];
/**
* 更改数据结构
*/
foreach ($itemValue as $key => $value) {
$newItemValue[$key]['id'] = $value;
$newItemValue[$key]['enabled'] = 1;
$newItemValue[$key]['id'] = $value['id'] ?? $value;
$newItemValue[$key]['enabled'] = $value['enabled'] ?? 1;
}
/**
@ -83,8 +75,8 @@ final class Data202102280351 extends AbstractMigration
$itemValue = json_encode($newItemValue);
$this->getQueryBuilder()
->update($table)
->where($where)
->update('kg_setting')
->where(['id' => $setting['id']])
->set('item_value', $itemValue)
->execute();
}

View File

@ -33,6 +33,12 @@ class Schema202103021010 extends Phinx\Migration\AbstractMigration
$table->removeColumn('deleted')->save();
}
$table = $this->table('kg_im_notice');
if ($table->hasColumn('deleted')) {
$table->removeColumn('deleted')->save();
}
$table = $this->table('kg_learning');
if ($table->hasColumn('deleted')) {