forked from build-admin/buildadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
20230622221507_version200.php
179 lines (162 loc) · 11 KB
/
20230622221507_version200.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
use think\facade\Db;
use think\migration\Migrator;
use Phinx\Db\Adapter\MysqlAdapter;
class Version200 extends Migrator
{
public function up(): void
{
$admin = $this->table('admin');
if ($admin->hasColumn('loginfailure')) {
// 字段改名
$admin->renameColumn('loginfailure', 'login_failure')
->renameColumn('lastlogintime', 'last_login_time')
->renameColumn('lastloginip', 'last_login_ip')
->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['after' => 'update_time', 'limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$adminGroup = $this->table('admin_group');
if ($adminGroup->hasColumn('updatetime')) {
$adminGroup->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$adminLog = $this->table('admin_log');
if ($adminLog->hasColumn('createtime')) {
$adminLog->renameColumn('createtime', 'create_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->changeColumn('data', 'text', ['limit' => MysqlAdapter::TEXT_LONG, 'null' => true, 'default' => null, 'comment' => '请求数据'])
->save();
}
$attachment = $this->table('attachment');
if ($attachment->hasColumn('createtime')) {
$attachment->renameColumn('createtime', 'create_time')
->renameColumn('lastuploadtime', 'last_upload_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->changeColumn('last_upload_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '最后上传时间'])
->save();
}
$captcha = $this->table('captcha');
if ($captcha->hasColumn('createtime')) {
$captcha->renameColumn('createtime', 'create_time')
->renameColumn('expiretime', 'expire_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->changeColumn('expire_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间'])
->changeColumn('captcha', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR, 'null' => true, 'default' => null, 'comment' => '验证码数据'])
->save();
}
if ($this->hasTable('menu_rule')) {
$menuRule = $this->table('menu_rule');
if ($menuRule->hasColumn('updatetime') && $this->hasTable('menu_rule')) {
$menuRule->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
$menuRule->rename('admin_rule')->save();
Db::name('admin_rule')
->where('name', 'auth/menu')
->update([
'name' => 'auth/rule',
'path' => 'auth/rule',
'component' => '/src/views/backend/auth/rule/index.vue',
]);
Db::name('admin_rule')->where('name', 'auth/menu/index')->update(['name' => 'auth/rule/index']);
Db::name('admin_rule')->where('name', 'auth/menu/add')->update(['name' => 'auth/rule/add']);
Db::name('admin_rule')->where('name', 'auth/menu/edit')->update(['name' => 'auth/rule/edit']);
Db::name('admin_rule')->where('name', 'auth/menu/del')->update(['name' => 'auth/rule/del']);
Db::name('admin_rule')->where('name', 'auth/menu/sortable')->update(['name' => 'auth/rule/sortable']);
Db::name('admin_rule')->whereIn('name', [
'dashboard/dashboard',
'routine/attachment',
])->update(['remark' => 'Remark lang']);
}
}
$securityDataRecycle = $this->table('security_data_recycle');
if ($securityDataRecycle->hasColumn('updatetime')) {
$securityDataRecycle->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$securityDataRecycleLog = $this->table('security_data_recycle_log');
if ($securityDataRecycleLog->hasColumn('createtime')) {
$securityDataRecycleLog->renameColumn('createtime', 'create_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$securitySensitiveData = $this->table('security_sensitive_data');
if ($securitySensitiveData->hasColumn('updatetime')) {
$securitySensitiveData->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$securitySensitiveDataLog = $this->table('security_sensitive_data_log');
if ($securitySensitiveDataLog->hasColumn('createtime')) {
$securitySensitiveDataLog->renameColumn('createtime', 'create_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$token = $this->table('token');
if ($token->hasColumn('createtime')) {
$token->renameColumn('createtime', 'create_time')
->renameColumn('expiretime', 'expire_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->changeColumn('expire_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '过期时间'])
->save();
}
$userGroup = $this->table('user_group');
if ($userGroup->hasColumn('createtime')) {
$userGroup->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$userMoneyLog = $this->table('user_money_log');
if ($userMoneyLog->hasColumn('createtime')) {
$userMoneyLog->renameColumn('createtime', 'create_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$userRule = $this->table('user_rule');
if ($userRule->hasColumn('createtime')) {
$userRule->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->changeColumn('type', 'enum', ['values' => 'route,menu_dir,menu,nav_user_menu,nav,button', 'default' => 'menu', 'comment' => '类型:route=路由,menu_dir=菜单目录,menu=菜单项,nav_user_menu=顶栏会员菜单下拉项,nav=顶栏菜单项,button=页面按钮', 'null' => false]);
if (!$userRule->hasColumn('no_login_valid')) {
$userRule->addColumn('no_login_valid', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '未登录有效:0=否,1=是']);
}
$userRule->save();
}
$userScoreLog = $this->table('user_score_log');
if ($userScoreLog->hasColumn('createtime')) {
$userScoreLog->renameColumn('createtime', 'create_time')
->changeColumn('create_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
$user = $this->table('user');
if ($user->hasColumn('loginfailure')) {
$user->renameColumn('lastlogintime', 'last_login_time')
->renameColumn('lastloginip', 'last_login_ip')
->renameColumn('loginfailure', 'login_failure')
->renameColumn('joinip', 'join_ip')
->renameColumn('jointime', 'join_time')
->renameColumn('updatetime', 'update_time')
->renameColumn('createtime', 'create_time')
->changeColumn('update_time', 'biginteger', ['limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '更新时间'])
->changeColumn('create_time', 'biginteger', ['after' => 'update_time', 'limit' => 16, 'signed' => false, 'null' => true, 'default' => null, 'comment' => '创建时间'])
->save();
}
}
}