clrghouz/database/migrations/2021_08_15_134329_default_zones.php

45 lines
952 B
PHP
Raw Normal View History

2021-08-16 12:26:33 +00:00
<?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);
});
2021-08-17 14:13:25 +00:00
DB::statement('CREATE UNIQUE INDEX default_zones ON zones (zone_id) WHERE "default" = true');
2021-08-16 12:26:33 +00:00
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
2021-08-17 14:13:25 +00:00
DB::statement("DROP INDEX default_zones");
2021-08-16 12:26:33 +00:00
Schema::table('zones', function (Blueprint $table) {
$table->dropColumn('default');
});
2021-08-17 14:13:25 +00:00
Schema::table('domains', function (Blueprint $table) {
2021-08-16 12:26:33 +00:00
$table->boolean('default')->default(FALSE);
});
}
}