Skip to content

Commit

Permalink
Default values on attribute_groups
Browse files Browse the repository at this point in the history
and `attributes` table
  • Loading branch information
netzknecht committed Nov 10, 2023
1 parent 5301024 commit ce82562
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
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();
});
}
}
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();
});
}
}

0 comments on commit ce82562

Please sign in to comment.