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() + { + // + } +}