From 1f7ab212b8127d8216523300fd95214674e2530b Mon Sep 17 00:00:00 2001 From: MGeurts <5404867+MGeurts@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:58:06 +0100 Subject: [PATCH] Optimized Migration classes --- .../0001_01_01_000001_create_users_table.php | 12 +++++++---- ...001_01_01_000002_create_userlogs_table.php | 14 +++++++++++-- .../0001_01_01_000003_create_cache_table.php | 12 +++++++---- .../0001_01_01_000004_create_jobs_table.php | 12 +++++++---- ..._add_two_factor_columns_to_users_table.php | 13 ++++++++---- ...02_create_personal_access_tokens_table.php | 12 +++++++---- .../2024_01_01_100001_create_teams_table.php | 12 +++++++---- ...24_01_01_100002_create_team_user_table.php | 12 +++++++---- ...1_100003_create_team_invitations_table.php | 12 +++++++---- ...2024_03_03_200001_create_genders_table.php | 12 +++++++---- .../2024_03_03_300001_create_people_table.php | 12 +++++++---- ...03_300002_create_person_metadata_table.php | 20 +++++++++---------- ...2024_03_03_300003_create_couples_table.php | 20 +++++++++---------- ...04_04_100001_create_activity_log_table.php | 14 +++++++++++-- .../2024_05_05_100001_create_media_table.php | 15 ++++++++++++++ 15 files changed, 140 insertions(+), 64 deletions(-) diff --git a/database/migrations/0001_01_01_000001_create_users_table.php b/database/migrations/0001_01_01_000001_create_users_table.php index ab3ef179d..fcfe6d626 100644 --- a/database/migrations/0001_01_01_000001_create_users_table.php +++ b/database/migrations/0001_01_01_000001_create_users_table.php @@ -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) { @@ -54,8 +56,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('users'); diff --git a/database/migrations/0001_01_01_000002_create_userlogs_table.php b/database/migrations/0001_01_01_000002_create_userlogs_table.php index a6cb8c0ad..6bbdd7695 100644 --- a/database/migrations/0001_01_01_000002_create_userlogs_table.php +++ b/database/migrations/0001_01_01_000002_create_userlogs_table.php @@ -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(); @@ -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'); } diff --git a/database/migrations/0001_01_01_000003_create_cache_table.php b/database/migrations/0001_01_01_000003_create_cache_table.php index b9c106be8..841bcc8c4 100644 --- a/database/migrations/0001_01_01_000003_create_cache_table.php +++ b/database/migrations/0001_01_01_000003_create_cache_table.php @@ -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) { @@ -25,8 +27,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('cache'); diff --git a/database/migrations/0001_01_01_000004_create_jobs_table.php b/database/migrations/0001_01_01_000004_create_jobs_table.php index 425e7058f..01f4892b8 100644 --- a/database/migrations/0001_01_01_000004_create_jobs_table.php +++ b/database/migrations/0001_01_01_000004_create_jobs_table.php @@ -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) { @@ -46,8 +48,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('jobs'); diff --git a/database/migrations/2024_01_01_000001_add_two_factor_columns_to_users_table.php b/database/migrations/2024_01_01_000001_add_two_factor_columns_to_users_table.php index b490e24f5..47680159a 100644 --- a/database/migrations/2024_01_01_000001_add_two_factor_columns_to_users_table.php +++ b/database/migrations/2024_01_01_000001_add_two_factor_columns_to_users_table.php @@ -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) { @@ -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) { diff --git a/database/migrations/2024_01_01_000002_create_personal_access_tokens_table.php b/database/migrations/2024_01_01_000002_create_personal_access_tokens_table.php index 36e451761..cb1589aa1 100644 --- a/database/migrations/2024_01_01_000002_create_personal_access_tokens_table.php +++ b/database/migrations/2024_01_01_000002_create_personal_access_tokens_table.php @@ -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) { @@ -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'); diff --git a/database/migrations/2024_01_01_100001_create_teams_table.php b/database/migrations/2024_01_01_100001_create_teams_table.php index f35ad3ef4..9a53ef7bd 100644 --- a/database/migrations/2024_01_01_100001_create_teams_table.php +++ b/database/migrations/2024_01_01_100001_create_teams_table.php @@ -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) { @@ -24,8 +26,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('teams'); diff --git a/database/migrations/2024_01_01_100002_create_team_user_table.php b/database/migrations/2024_01_01_100002_create_team_user_table.php index b89ae6782..85172237a 100644 --- a/database/migrations/2024_01_01_100002_create_team_user_table.php +++ b/database/migrations/2024_01_01_100002_create_team_user_table.php @@ -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) { @@ -25,8 +27,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('team_user'); diff --git a/database/migrations/2024_01_01_100003_create_team_invitations_table.php b/database/migrations/2024_01_01_100003_create_team_invitations_table.php index f1abe7800..17a113d23 100644 --- a/database/migrations/2024_01_01_100003_create_team_invitations_table.php +++ b/database/migrations/2024_01_01_100003_create_team_invitations_table.php @@ -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) { @@ -25,8 +27,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('team_invitations'); diff --git a/database/migrations/2024_03_03_200001_create_genders_table.php b/database/migrations/2024_03_03_200001_create_genders_table.php index 8dabc5a23..8d6cd7f22 100644 --- a/database/migrations/2024_03_03_200001_create_genders_table.php +++ b/database/migrations/2024_03_03_200001_create_genders_table.php @@ -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) { @@ -21,8 +23,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('genders'); diff --git a/database/migrations/2024_03_03_300001_create_people_table.php b/database/migrations/2024_03_03_300001_create_people_table.php index ded7f85cb..aaf93e14c 100644 --- a/database/migrations/2024_03_03_300001_create_people_table.php +++ b/database/migrations/2024_03_03_300001_create_people_table.php @@ -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) { @@ -54,8 +56,10 @@ public function up(): void } /** - * Reverse the migrations. - */ + * Reverse the migrations. + * + * @return void + */ public function down(): void { Schema::dropIfExists('people'); diff --git a/database/migrations/2024_03_03_300002_create_person_metadata_table.php b/database/migrations/2024_03_03_300002_create_person_metadata_table.php index 5e36d136c..0f4d110d4 100644 --- a/database/migrations/2024_03_03_300002_create_person_metadata_table.php +++ b/database/migrations/2024_03_03_300002_create_person_metadata_table.php @@ -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(); @@ -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'); } diff --git a/database/migrations/2024_03_03_300003_create_couples_table.php b/database/migrations/2024_03_03_300003_create_couples_table.php index 5d24a8ac3..53088165c 100644 --- a/database/migrations/2024_03_03_300003_create_couples_table.php +++ b/database/migrations/2024_03_03_300003_create_couples_table.php @@ -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(); @@ -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'); } diff --git a/database/migrations/2024_04_04_100001_create_activity_log_table.php b/database/migrations/2024_04_04_100001_create_activity_log_table.php index 4fbda8cb7..38be1bf86 100644 --- a/database/migrations/2024_04_04_100001_create_activity_log_table.php +++ b/database/migrations/2024_04_04_100001_create_activity_log_table.php @@ -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'); @@ -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')); } diff --git a/database/migrations/2024_05_05_100001_create_media_table.php b/database/migrations/2024_05_05_100001_create_media_table.php index d8b8ddb2e..431a6d554 100644 --- a/database/migrations/2024_05_05_100001_create_media_table.php +++ b/database/migrations/2024_05_05_100001_create_media_table.php @@ -6,6 +6,11 @@ return new class extends Migration { + /** + * Run the migrations. + * + * @return void + */ public function up(): void { Schema::create('media', function (Blueprint $table) { @@ -29,4 +34,14 @@ public function up(): void $table->nullableTimestamps(); }); } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('media'); + } };