clrghouz/database/migrations/2022_01_24_104549_address_role_notnull.php

31 lines
681 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddressRoleNotnull extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
\App\Models\Address::whereNull('role')->withTrashed()->update(['role'=>\App\Models\Address::NODE_ACTIVE]);
DB::commit();
DB::statement("ALTER TABLE addresses ALTER COLUMN role set NOT NULL");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::statement("ALTER TABLE addresses ALTER COLUMN role drop NOT NULL");
}
}