作者 ZhengBing He

合并分支 'workorder' 到 'master'

添加外键约束



查看合并请求 !2082
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class WorkOrderLogsAddForeignId extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('gl_work_order_logs', function (Blueprint $table) {
// 字段已存在,给字段添加外键约束
$table->foreign('work_order_id')
->references('id')->on('gl_work_orders')
->onDelete('cascade'); // 设置级联删除
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('gl_work_order_logs', function (Blueprint $table) {
// 删除外键约束
$table->dropForeign(['work_order_id']);
});
}
}
... ...