clrghouz/database/migrations/2021_08_15_134329_default_zones.php
2021-08-18 00:13:25 +10:00

45 lines
952 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DefaultZones extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('domains', function (Blueprint $table) {
$table->dropColumn('default');
});
Schema::table('zones', function (Blueprint $table) {
$table->boolean('default')->default(FALSE);
});
DB::statement('CREATE UNIQUE INDEX default_zones ON zones (zone_id) WHERE "default" = true');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::statement("DROP INDEX default_zones");
Schema::table('zones', function (Blueprint $table) {
$table->dropColumn('default');
});
Schema::table('domains', function (Blueprint $table) {
$table->boolean('default')->default(FALSE);
});
}
}