update
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
DB::table('mail')->where('customer_id', 0)->update(['customer_id' => null]);
|
||||
|
||||
// ponytail: raw SQL instead of Blueprint::change() to avoid adding doctrine/dbal just for this
|
||||
DB::statement('ALTER TABLE `mail` MODIFY `customer_id` BIGINT UNSIGNED NULL DEFAULT NULL');
|
||||
|
||||
Schema::table('mail', function (Blueprint $table) {
|
||||
$table->foreign('customer_id')->references('id')->on('customers')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('mail', function (Blueprint $table) {
|
||||
$table->dropForeign(['customer_id']);
|
||||
});
|
||||
|
||||
DB::statement('ALTER TABLE `mail` MODIFY `customer_id` BIGINT NOT NULL DEFAULT 0');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user