作者 赵彬吉

fix sync_submit_task_distribution

... ... @@ -73,14 +73,21 @@ class SyncSubmitTaskDistribution extends Command
try {
$table = (new SyncSubmitTaskModel())->getTable();
$new_table = $table . '_backup_' . date('Ymd');
if(Schema::hasTable($new_table)){
$new_table = $table . '_backup_' . date('YmdH');
}
//重命名当前表
Schema::rename($table, $new_table);
//克隆表数据
DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table);
//未入队的写到新表
$list = DB::table($new_table)->where('status', 0)->get();
$page = 1;
while (true){
$list = DB::table($new_table)->where('status', 0)->forPage($page, 5000)->get();
if(!count($list)){
break;
}
$data = [];
foreach ($list as $task) {
$data[] = [
... ... @@ -91,6 +98,8 @@ class SyncSubmitTaskDistribution extends Command
];
}
$data && SyncSubmitTaskModel::insert($data);
$page++;
}
DB::commit();
... ...