From e44e77a3a6cb74ad23253cd738728888a86e1380 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 6 Jan 2022 13:28:47 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E5=AD=90=E4=BB=BB=E5=8A=A1=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=B5=B7=E5=A7=8B=E6=97=B6=E9=97=B4=E4=B8=8E=E4=B8=BB?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2023_project_tasks_update_subtask_time.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php diff --git a/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php b/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php new file mode 100644 index 00000000..618e66f3 --- /dev/null +++ b/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php @@ -0,0 +1,39 @@ +', 0) + ->whereNull('end_at') + ->chunkById(100, function ($lists) { + /** @var ProjectTask $task */ + foreach ($lists as $task) { + $parent = ProjectTask::whereNotNull('end_at')->find($task->parent_id); + if ($parent) { + $task->start_at = $parent->start_at; + $task->end_at = $parent->end_at; + $task->save(); + } + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}