Default zone only when default=true

This commit is contained in:
Deon George 2021-08-18 00:13:25 +10:00
parent 259ea01fd1
commit e8df6f7103
2 changed files with 6 additions and 4 deletions

View File

@ -27,7 +27,7 @@ class DefaultRoute extends Migration
*/ */
public function down() public function down()
{ {
DB::statement("DROP UNIQUE INDEX default_zone"); DB::statement("DROP INDEX default_zone");
Schema::table('system_zone', function (Blueprint $table) { Schema::table('system_zone', function (Blueprint $table) {
$table->dropColumn('default'); $table->dropColumn('default');

View File

@ -19,8 +19,9 @@ class DefaultZones extends Migration
Schema::table('zones', function (Blueprint $table) { Schema::table('zones', function (Blueprint $table) {
$table->boolean('default')->default(FALSE); $table->boolean('default')->default(FALSE);
$table->unique(['zone_id','default']);
}); });
DB::statement('CREATE UNIQUE INDEX default_zones ON zones (zone_id) WHERE "default" = true');
} }
/** /**
@ -30,12 +31,13 @@ class DefaultZones extends Migration
*/ */
public function down() public function down()
{ {
DB::statement("DROP INDEX default_zones");
Schema::table('zones', function (Blueprint $table) { Schema::table('zones', function (Blueprint $table) {
$table->dropUnique(['zone_id','default']);
$table->dropColumn('default'); $table->dropColumn('default');
}); });
Schema::table('zones', function (Blueprint $table) { Schema::table('domains', function (Blueprint $table) {
$table->boolean('default')->default(FALSE); $table->boolean('default')->default(FALSE);
}); });
} }