mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-21 21:48:42 +00:00
chore: add upgrader for #42
This commit is contained in:
parent
098e488fe3
commit
2cd81ab055
8
web/app/upgrade/42_acm_team_account/up.sql
Normal file
8
web/app/upgrade/42_acm_team_account/up.sql
Normal file
@ -0,0 +1,8 @@
|
||||
ALTER TABLE
|
||||
`user_info`
|
||||
MODIFY
|
||||
`usertype` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'student',
|
||||
MODIFY
|
||||
`last_login_time` datetime DEFAULT NULL,
|
||||
MODIFY
|
||||
`last_visit_time` datetime DEFAULT NULL;
|
27
web/app/upgrade/42_acm_team_account/upgrade.php
Normal file
27
web/app/upgrade/42_acm_team_account/upgrade.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
return function ($type) {
|
||||
DB::init();
|
||||
|
||||
if ($type == 'up') {
|
||||
$users = DB::selectAll("select * from user_info");
|
||||
|
||||
foreach ($users as $user) {
|
||||
$extra = UOJUser::getExtra($user);
|
||||
|
||||
$extra['school'] = $user['school'];
|
||||
|
||||
DB::update([
|
||||
"update user_info",
|
||||
"set", [
|
||||
"extra" => json_encode($extra, JSON_UNESCAPED_UNICODE)
|
||||
],
|
||||
"where", [
|
||||
"username" => $user['username']
|
||||
]
|
||||
]);
|
||||
|
||||
echo "Updated user {$user['username']}. \n";
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user