forked from kuaifan/dootask
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
use App\Models\ProjectTask; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class ProjectTasksUpdateSubtaskArchivedDelete extends Migration | ||
{ | ||
/** | ||
* 子任务同步主任务(归档、删除) | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
// 归档 | ||
ProjectTask::whereParentId(0) | ||
->whereNotNull('archived_at') | ||
->chunkById(100, function ($lists) { | ||
/** @var ProjectTask $task */ | ||
foreach ($lists as $task) { | ||
ProjectTask::whereParentId($task->id)->update([ | ||
'archived_at' => $task->archived_at, | ||
'archived_userid' => $task->archived_userid, | ||
'archived_follow' => $task->archived_follow, | ||
]); | ||
} | ||
}); | ||
|
||
// 删除 | ||
ProjectTask::onlyTrashed() | ||
->whereParentId(0) | ||
->chunkById(100, function ($lists) { | ||
/** @var ProjectTask $task */ | ||
foreach ($lists as $task) { | ||
ProjectTask::whereParentId($task->id)->update([ | ||
'deleted_at' => $task->deleted_at, | ||
]); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
// | ||
} | ||
} |