-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...re/database/migrations/2023_09_28_100000_set_default_values_on_attribute_groups_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
use Lunar\Base\Migration; | ||
|
||
class SetDefaultValuesOnAttributeGroupsTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::table($this->prefix . 'attribute_groups', function (Blueprint $table) { | ||
$table->boolean('position')->default(0)->change(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::table($this->prefix . 'attribute_groups', function (Blueprint $table) { | ||
// for not nullable fields `default(null)` removes the default value | ||
$table->boolean('position')->default(null)->change(); | ||
}); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ges/core/database/migrations/2023_09_28_100000_set_default_values_on_attributes_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
use Lunar\Base\Migration; | ||
|
||
class SetDefaultValuesOnAttributesTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::table($this->prefix . 'attributes', function (Blueprint $table) { | ||
$table->boolean('required')->default(0)->change(); | ||
$table->boolean('system')->default(0)->change(); | ||
$table->boolean('position')->default(0)->change(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::table($this->prefix . 'attributes', function (Blueprint $table) { | ||
// for not nullable fields `default(null)` removes the default value | ||
$table->boolean('required')->default(null)->change(); | ||
$table->boolean('system')->default(null)->change(); | ||
$table->boolean('position')->default(null)->change(); | ||
}); | ||
} | ||
} |