fix:修复子任务可见性字段为null的数据

This commit is contained in:
weifashi 2023-08-10 23:23:45 +08:00
parent 0e12a08076
commit e2a0b7a033

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class repairProjectTasksIsAllVisible extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// 修复子任务可见性字段为null的数据
if (!Schema::hasTable('project_tasks')) {
$prefix = DB::getConfig('prefix');
DB::select(DB::raw(`
UPDATE {$prefix}project_tasks
SET is_all_visible = 1
WHERE is_all_visible is null AND parent_id = 0
`));
DB::select(DB::raw(`
UPDATE {$prefix}project_tasks t1
JOIN {$prefix}project_tasks t2 ON t1.parent_id = t2.id
SET t1.is_all_visible = t2.is_all_visible
WHERE t1.is_all_visible is null AND t1.parent_id > 0
`));
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}