mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
perf: 优化子任务的可见性
This commit is contained in:
parent
94af3822d8
commit
14775e2861
@ -121,5 +121,6 @@ class ProjectTaskObserver
|
|||||||
Deleted::forget('projectTask', $projectTask->id, $forgetUserids);
|
Deleted::forget('projectTask', $projectTask->id, $forgetUserids);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ProjectTask::whereParentId($projectTask->id)->change(['visibility' => $projectTask->visibility]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class UpdateProjectTasksSubtaskVisibility extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$prefix = DB::getTablePrefix();
|
||||||
|
$now = Carbon::now();
|
||||||
|
DB::statement("
|
||||||
|
UPDATE {$prefix}project_tasks AS subtask
|
||||||
|
INNER JOIN {$prefix}project_tasks AS parent ON subtask.parent_id = parent.id
|
||||||
|
SET
|
||||||
|
subtask.visibility = parent.visibility,
|
||||||
|
subtask.updated_at = '{$now}'
|
||||||
|
WHERE subtask.parent_id > 0
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
// No need for down operation as this is a data correction
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user