Skip to content

Commit

Permalink
[Spring cleaning] Refactor migrations (#1737)
Browse files Browse the repository at this point in the history
  • Loading branch information
adevade authored May 28, 2024
1 parent ea54668 commit c3f5f01
Show file tree
Hide file tree
Showing 102 changed files with 429 additions and 811 deletions.
2 changes: 1 addition & 1 deletion packages/admin/src/Models/Staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(array $attributes = [])

$this->setTable(config('lunar.database.table_prefix').$this->getTable());

if ($connection = config('lunar.database.connection', false)) {
if ($connection = config('lunar.database.connection')) {
$this->setConnection($connection);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [

'connection' => '',
'connection' => null,

'table_prefix' => 'lunar_',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,23 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateChannelsTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'channels', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('handle')->unique();
$table->boolean('default')->default(0)->index();
$table->boolean('default')->default(false)->index();
$table->string('url')->nullable();
$table->timestamps();
$table->softDeletes();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'channels');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,21 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateLanguagesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'languages', function (Blueprint $table) {
$table->id();
$table->string('code')->unique();
$table->string('name');
$table->boolean('default')->default(0)->index();
$table->boolean('default')->default(false)->index();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'languages');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateChannelablesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'channelables', function (Blueprint $table) {
$table->id();
Expand All @@ -23,13 +18,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'channelables');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateCurrenciesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'currencies', function (Blueprint $table) {
$table->id();
Expand All @@ -22,19 +17,14 @@ public function up()
$table->string('decimal_point');
$table->string('thousand_point');
$table->integer('decimal_places')->default(2)->index();
$table->boolean('enabled')->default(0)->index();
$table->boolean('default')->default(0)->index();
$table->boolean('enabled')->default(false)->index();
$table->boolean('default')->default(false)->index();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'currencies');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateAttributeGroupsTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'attribute_groups', function (Blueprint $table) {
$table->id();
Expand All @@ -23,13 +18,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'attribute_groups');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateAttributesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'attributes', function (Blueprint $table) {
$table->id();
Expand All @@ -32,13 +27,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'attributes');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateAttributablesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'attributables', function (Blueprint $table) {
$table->id();
Expand All @@ -21,13 +16,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'attributables');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateProductTypesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'product_types', function (Blueprint $table) {
$table->id();
Expand All @@ -20,13 +15,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'product_types');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateTaxClassesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'tax_classes', function (Blueprint $table) {
$table->id();
Expand All @@ -20,13 +15,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'tax_classes');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateTaxZonesTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'tax_zones', function (Blueprint $table) {
$table->id();
Expand All @@ -24,13 +19,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'tax_zones');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

class CreateProductsTable extends Migration
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
Schema::create($this->prefix.'products', function (Blueprint $table) {
$table->id();
Expand All @@ -24,13 +19,8 @@ public function up()
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists($this->prefix.'products');
}
}
};
Loading

0 comments on commit c3f5f01

Please sign in to comment.