Skip to content

Commit

Permalink
Optimized Migration classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MGeurts committed Nov 26, 2024
1 parent e525b9b commit 1f7ab21
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 64 deletions.
12 changes: 8 additions & 4 deletions database/migrations/0001_01_01_000001_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
Expand Down Expand Up @@ -54,8 +56,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('users');
Expand Down
14 changes: 12 additions & 2 deletions database/migrations/0001_01_01_000002_create_userlogs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

return new class extends Migration
{
public function up()
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('userlogs', function (Blueprint $table) {
$table->id();
Expand All @@ -24,7 +29,12 @@ public function up()
DB::statement('ALTER TABLE `userlogs` ADD INDEX `userlogs_country_name_index` (`country_name`)');
}

public function down()
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('userlogs');
}
Expand Down
12 changes: 8 additions & 4 deletions database/migrations/0001_01_01_000003_create_cache_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
Expand All @@ -25,8 +27,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('cache');
Expand Down
12 changes: 8 additions & 4 deletions database/migrations/0001_01_01_000004_create_jobs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
Expand Down Expand Up @@ -46,8 +48,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
Expand All @@ -30,8 +33,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
Expand All @@ -26,8 +28,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
Expand Down
12 changes: 8 additions & 4 deletions database/migrations/2024_01_01_100001_create_teams_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('teams', function (Blueprint $table) {
Expand All @@ -24,8 +26,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('teams');
Expand Down
12 changes: 8 additions & 4 deletions database/migrations/2024_01_01_100002_create_team_user_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('team_user', function (Blueprint $table) {
Expand All @@ -25,8 +27,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('team_user');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('team_invitations', function (Blueprint $table) {
Expand All @@ -25,8 +27,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('team_invitations');
Expand Down
12 changes: 8 additions & 4 deletions database/migrations/2024_03_03_200001_create_genders_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('genders', function (Blueprint $table) {
Expand All @@ -21,8 +23,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('genders');
Expand Down
12 changes: 8 additions & 4 deletions database/migrations/2024_03_03_300001_create_people_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
return new class extends Migration
{
/**
* Run the migrations.
*/
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('people', function (Blueprint $table) {
Expand Down Expand Up @@ -54,8 +56,10 @@ public function up(): void
}

/**
* Reverse the migrations.
*/
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('people');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('person_metadata', function (Blueprint $table) {
$table->id();
Expand All @@ -28,11 +28,11 @@ public function up()
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('person_metadata');
}
Expand Down
20 changes: 10 additions & 10 deletions database/migrations/2024_03_03_300003_create_couples_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('couples', function (Blueprint $table) {
$table->id();
Expand All @@ -34,11 +34,11 @@ public function up()
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('couples');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

return new class extends Migration
{
public function up()
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
Expand All @@ -23,7 +28,12 @@ public function up()
});
}

public function down()
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
}
Expand Down
Loading

0 comments on commit 1f7ab21

Please sign in to comment.