From 186b0b33ca00790fc024166c19899d21f122c36c Mon Sep 17 00:00:00 2001 From: clayton Date: Mon, 14 Aug 2023 14:04:39 -0700 Subject: [PATCH 1/3] Use new migration format for migrations that are depended on --- .../2016_02_27_103851_create_osu_slack_users_table.php | 4 ++-- .../2016_02_29_052133_create_beatmapset_discussions.php | 4 ++-- .../2016_03_02_214730_change_primary_key_on_slack_users.php | 4 ++-- ...6_03_03_223651_osu_slack_user_make_slack_id_nullable.php | 4 ++-- .../migrations/2016_03_09_083112_add_index_on_slack_id.php | 4 ++-- .../2016_03_18_170000_create_oauth_scopes_table.php | 6 +++--- .../2016_03_18_170001_create_oauth_grants_table.php | 6 +++--- .../2016_03_18_170002_create_oauth_grant_scopes_table.php | 6 +++--- .../2016_03_18_170003_create_oauth_clients_table.php | 6 +++--- ...016_03_18_170004_create_oauth_client_endpoints_table.php | 6 +++--- .../2016_03_18_170005_create_oauth_client_scopes_table.php | 6 +++--- .../2016_03_18_170006_create_oauth_client_grants_table.php | 6 +++--- .../2016_03_18_170007_create_oauth_sessions_table.php | 6 +++--- .../2016_03_18_170008_create_oauth_session_scopes_table.php | 6 +++--- .../2016_03_18_170009_create_oauth_auth_codes_table.php | 6 +++--- ...016_03_18_170010_create_oauth_auth_code_scopes_table.php | 6 +++--- .../2016_03_18_170011_create_oauth_access_tokens_table.php | 6 +++--- ..._03_18_170012_create_oauth_access_token_scopes_table.php | 6 +++--- .../2016_03_18_170013_create_oauth_refresh_tokens_table.php | 6 +++--- ...016_08_25_055700_create_contest_vote_aggregates_view.php | 4 ++-- ...2350_add_kudosu_refresh_votes_to_beatmap_discussions.php | 4 ++-- .../migrations/2021_03_24_130818_create_solo_scores.php | 4 ++-- 22 files changed, 58 insertions(+), 58 deletions(-) diff --git a/database/migrations/2016_02_27_103851_create_osu_slack_users_table.php b/database/migrations/2016_02_27_103851_create_osu_slack_users_table.php index 930c5b46f2e..3b40356a477 100644 --- a/database/migrations/2016_02_27_103851_create_osu_slack_users_table.php +++ b/database/migrations/2016_02_27_103851_create_osu_slack_users_table.php @@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; -class CreateOsuSlackUsersTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -33,4 +33,4 @@ public function down() { Schema::drop('osu_slack_users'); } -} +}; diff --git a/database/migrations/2016_02_29_052133_create_beatmapset_discussions.php b/database/migrations/2016_02_29_052133_create_beatmapset_discussions.php index a30e01891f9..1680f863892 100644 --- a/database/migrations/2016_02_29_052133_create_beatmapset_discussions.php +++ b/database/migrations/2016_02_29_052133_create_beatmapset_discussions.php @@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; -class CreateBeatmapsetDiscussions extends Migration +return new class extends Migration { /** * Run the migrations. @@ -38,4 +38,4 @@ public function down() { Schema::drop('beatmapset_discussions'); } -} +}; diff --git a/database/migrations/2016_03_02_214730_change_primary_key_on_slack_users.php b/database/migrations/2016_03_02_214730_change_primary_key_on_slack_users.php index b82525f382a..9421a8c0b20 100644 --- a/database/migrations/2016_03_02_214730_change_primary_key_on_slack_users.php +++ b/database/migrations/2016_03_02_214730_change_primary_key_on_slack_users.php @@ -5,7 +5,7 @@ use Illuminate\Database\Migrations\Migration; -class ChangePrimaryKeyOnSlackUsers extends Migration +return new class extends Migration { /** * Run the migrations. @@ -32,4 +32,4 @@ public function down() $table->primary('slack_id'); }); } -} +}; diff --git a/database/migrations/2016_03_03_223651_osu_slack_user_make_slack_id_nullable.php b/database/migrations/2016_03_03_223651_osu_slack_user_make_slack_id_nullable.php index 3cf8c349b85..039a814efff 100644 --- a/database/migrations/2016_03_03_223651_osu_slack_user_make_slack_id_nullable.php +++ b/database/migrations/2016_03_03_223651_osu_slack_user_make_slack_id_nullable.php @@ -5,7 +5,7 @@ use Illuminate\Database\Migrations\Migration; -class OsuSlackUserMakeSlackIdNullable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -30,4 +30,4 @@ public function down() $table->string('slack_id', 50)->change(); }); } -} +}; diff --git a/database/migrations/2016_03_09_083112_add_index_on_slack_id.php b/database/migrations/2016_03_09_083112_add_index_on_slack_id.php index 2e921b1cdfc..37062ab5bab 100644 --- a/database/migrations/2016_03_09_083112_add_index_on_slack_id.php +++ b/database/migrations/2016_03_09_083112_add_index_on_slack_id.php @@ -5,7 +5,7 @@ use Illuminate\Database\Migrations\Migration; -class AddIndexOnSlackId extends Migration +return new class extends Migration { /** * Run the migrations. @@ -30,4 +30,4 @@ public function down() $table->dropIndex('osu_slack_users_slack_id_index'); }); } -} +}; diff --git a/database/migrations/2016_03_18_170000_create_oauth_scopes_table.php b/database/migrations/2016_03_18_170000_create_oauth_scopes_table.php index 0b4a1d6dc13..024520563c6 100644 --- a/database/migrations/2016_03_18_170000_create_oauth_scopes_table.php +++ b/database/migrations/2016_03_18_170000_create_oauth_scopes_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthScopesTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -44,4 +44,4 @@ public function down() { Schema::drop('oauth_scopes'); } -} +}; diff --git a/database/migrations/2016_03_18_170001_create_oauth_grants_table.php b/database/migrations/2016_03_18_170001_create_oauth_grants_table.php index a15f8ff741d..7328dc475c7 100644 --- a/database/migrations/2016_03_18_170001_create_oauth_grants_table.php +++ b/database/migrations/2016_03_18_170001_create_oauth_grants_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthGrantsTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -42,4 +42,4 @@ public function down() { Schema::drop('oauth_grants'); } -} +}; diff --git a/database/migrations/2016_03_18_170002_create_oauth_grant_scopes_table.php b/database/migrations/2016_03_18_170002_create_oauth_grant_scopes_table.php index 97449c9e213..bab3c792dba 100644 --- a/database/migrations/2016_03_18_170002_create_oauth_grant_scopes_table.php +++ b/database/migrations/2016_03_18_170002_create_oauth_grant_scopes_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthGrantScopesTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -60,4 +60,4 @@ public function down() }); Schema::drop('oauth_grant_scopes'); } -} +}; diff --git a/database/migrations/2016_03_18_170003_create_oauth_clients_table.php b/database/migrations/2016_03_18_170003_create_oauth_clients_table.php index daeec12299b..1359641de7c 100644 --- a/database/migrations/2016_03_18_170003_create_oauth_clients_table.php +++ b/database/migrations/2016_03_18_170003_create_oauth_clients_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthClientsTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -46,4 +46,4 @@ public function down() { Schema::drop('oauth_clients'); } -} +}; diff --git a/database/migrations/2016_03_18_170004_create_oauth_client_endpoints_table.php b/database/migrations/2016_03_18_170004_create_oauth_client_endpoints_table.php index d1911f1b7f4..517f0799160 100644 --- a/database/migrations/2016_03_18_170004_create_oauth_client_endpoints_table.php +++ b/database/migrations/2016_03_18_170004_create_oauth_client_endpoints_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthClientEndpointsTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -56,4 +56,4 @@ public function down() Schema::drop('oauth_client_endpoints'); } -} +}; diff --git a/database/migrations/2016_03_18_170005_create_oauth_client_scopes_table.php b/database/migrations/2016_03_18_170005_create_oauth_client_scopes_table.php index e7a76431f35..cce22e692cd 100644 --- a/database/migrations/2016_03_18_170005_create_oauth_client_scopes_table.php +++ b/database/migrations/2016_03_18_170005_create_oauth_client_scopes_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthClientScopesTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -60,4 +60,4 @@ public function down() }); Schema::drop('oauth_client_scopes'); } -} +}; diff --git a/database/migrations/2016_03_18_170006_create_oauth_client_grants_table.php b/database/migrations/2016_03_18_170006_create_oauth_client_grants_table.php index 1afb2c9af0c..9954f7a4ca8 100644 --- a/database/migrations/2016_03_18_170006_create_oauth_client_grants_table.php +++ b/database/migrations/2016_03_18_170006_create_oauth_client_grants_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthClientGrantsTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -61,4 +61,4 @@ public function down() }); Schema::drop('oauth_client_grants'); } -} +}; diff --git a/database/migrations/2016_03_18_170007_create_oauth_sessions_table.php b/database/migrations/2016_03_18_170007_create_oauth_sessions_table.php index 375c4a41aef..c308bd23e3f 100644 --- a/database/migrations/2016_03_18_170007_create_oauth_sessions_table.php +++ b/database/migrations/2016_03_18_170007_create_oauth_sessions_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthSessionsTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -56,4 +56,4 @@ public function down() }); Schema::drop('oauth_sessions'); } -} +}; diff --git a/database/migrations/2016_03_18_170008_create_oauth_session_scopes_table.php b/database/migrations/2016_03_18_170008_create_oauth_session_scopes_table.php index 79b1614618c..b804afdae65 100644 --- a/database/migrations/2016_03_18_170008_create_oauth_session_scopes_table.php +++ b/database/migrations/2016_03_18_170008_create_oauth_session_scopes_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthSessionScopesTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -60,4 +60,4 @@ public function down() }); Schema::drop('oauth_session_scopes'); } -} +}; diff --git a/database/migrations/2016_03_18_170009_create_oauth_auth_codes_table.php b/database/migrations/2016_03_18_170009_create_oauth_auth_codes_table.php index 2904702cf10..0ceb3a6e34b 100644 --- a/database/migrations/2016_03_18_170009_create_oauth_auth_codes_table.php +++ b/database/migrations/2016_03_18_170009_create_oauth_auth_codes_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthAuthCodesTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -55,4 +55,4 @@ public function down() }); Schema::drop('oauth_auth_codes'); } -} +}; diff --git a/database/migrations/2016_03_18_170010_create_oauth_auth_code_scopes_table.php b/database/migrations/2016_03_18_170010_create_oauth_auth_code_scopes_table.php index fdee7611740..773341aca9f 100644 --- a/database/migrations/2016_03_18_170010_create_oauth_auth_code_scopes_table.php +++ b/database/migrations/2016_03_18_170010_create_oauth_auth_code_scopes_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthAuthCodeScopesTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -60,4 +60,4 @@ public function down() }); Schema::drop('oauth_auth_code_scopes'); } -} +}; diff --git a/database/migrations/2016_03_18_170011_create_oauth_access_tokens_table.php b/database/migrations/2016_03_18_170011_create_oauth_access_tokens_table.php index c5881633d8e..d1ed8e68564 100644 --- a/database/migrations/2016_03_18_170011_create_oauth_access_tokens_table.php +++ b/database/migrations/2016_03_18_170011_create_oauth_access_tokens_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthAccessTokensTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -55,4 +55,4 @@ public function down() }); Schema::drop('oauth_access_tokens'); } -} +}; diff --git a/database/migrations/2016_03_18_170012_create_oauth_access_token_scopes_table.php b/database/migrations/2016_03_18_170012_create_oauth_access_token_scopes_table.php index 4c9a7af4344..22ee8a14f47 100644 --- a/database/migrations/2016_03_18_170012_create_oauth_access_token_scopes_table.php +++ b/database/migrations/2016_03_18_170012_create_oauth_access_token_scopes_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthAccessTokenScopesTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -60,4 +60,4 @@ public function down() }); Schema::drop('oauth_access_token_scopes'); } -} +}; diff --git a/database/migrations/2016_03_18_170013_create_oauth_refresh_tokens_table.php b/database/migrations/2016_03_18_170013_create_oauth_refresh_tokens_table.php index b7262b034ee..8d0197c550f 100644 --- a/database/migrations/2016_03_18_170013_create_oauth_refresh_tokens_table.php +++ b/database/migrations/2016_03_18_170013_create_oauth_refresh_tokens_table.php @@ -1,6 +1,6 @@ @@ -18,7 +18,7 @@ * * @author Luca Degasperi */ -class CreateOauthRefreshTokensTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -53,4 +53,4 @@ public function down() Schema::drop('oauth_refresh_tokens'); } -} +}; diff --git a/database/migrations/2016_08_25_055700_create_contest_vote_aggregates_view.php b/database/migrations/2016_08_25_055700_create_contest_vote_aggregates_view.php index c5d3ba509ec..77c927e26a2 100644 --- a/database/migrations/2016_08_25_055700_create_contest_vote_aggregates_view.php +++ b/database/migrations/2016_08_25_055700_create_contest_vote_aggregates_view.php @@ -5,7 +5,7 @@ use Illuminate\Database\Migrations\Migration; -class CreateContestVoteAggregatesView extends Migration +return new class extends Migration { /** * Run the migrations. @@ -26,4 +26,4 @@ public function down() { DB::statement('DROP VIEW contest_vote_aggregates'); } -} +}; diff --git a/database/migrations/2016_12_19_132350_add_kudosu_refresh_votes_to_beatmap_discussions.php b/database/migrations/2016_12_19_132350_add_kudosu_refresh_votes_to_beatmap_discussions.php index 52887733f7c..ed3d91a2e05 100644 --- a/database/migrations/2016_12_19_132350_add_kudosu_refresh_votes_to_beatmap_discussions.php +++ b/database/migrations/2016_12_19_132350_add_kudosu_refresh_votes_to_beatmap_discussions.php @@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\Schema; -class AddKudosuRefreshVotesToBeatmapDiscussions extends Migration +return new class extends Migration { /** * Run the migrations. @@ -31,4 +31,4 @@ public function down() $table->dropColumn('kudosu_refresh_votes'); }); } -} +}; diff --git a/database/migrations/2021_03_24_130818_create_solo_scores.php b/database/migrations/2021_03_24_130818_create_solo_scores.php index efe5868dd64..baf985fd4f1 100644 --- a/database/migrations/2021_03_24_130818_create_solo_scores.php +++ b/database/migrations/2021_03_24_130818_create_solo_scores.php @@ -7,7 +7,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateSoloScores extends Migration +return new class extends Migration { /** * Run the migrations. @@ -53,4 +53,4 @@ public function down() { Schema::dropIfExists('solo_scores'); } -} +}; From 97ea074d098ae26afa11839241654daf11e87190 Mon Sep 17 00:00:00 2001 From: clayton Date: Mon, 14 Aug 2023 14:07:16 -0700 Subject: [PATCH 2/3] Require migration dependencies instead of assuming class will be declared --- app/helpers.php | 19 +++++++ .../2016_10_28_000000_update_oauth_tables.php | 56 +++++++++---------- .../2017_02_01_105338_drop_slack_users.php | 8 +-- ...36_delete_contest_vote_aggregates_view.php | 4 +- ..._28_110634_drop_beatmapset_discussions.php | 4 +- ...refresh_votes_from_beatmap_discussions.php | 4 +- ...1_09_15_065842_create_new_score_tables.php | 2 +- 7 files changed, 58 insertions(+), 39 deletions(-) diff --git a/app/helpers.php b/app/helpers.php index 9a44187996b..37628534669 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -7,6 +7,7 @@ use App\Models\LoginAttempt; use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\Validation\NoRFCWarningsValidation; +use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Arr; use Illuminate\Support\HtmlString; @@ -1847,3 +1848,21 @@ function unmix(string $resource): HtmlString { return app('assets-manifest')->src($resource); } + +/** + * Get an instance of the named migration. + */ +function migration(string $name): object +{ + $instance = app('files')->getRequire( + database_path('migrations').DIRECTORY_SEPARATOR."{$name}.php", + ); + + if (!$instance instanceof Migration) { + throw new Exception( + "\"{$name}\" does not return an instance of ".Migration::class.'.', + ); + } + + return $instance; +} diff --git a/database/migrations/2016_10_28_000000_update_oauth_tables.php b/database/migrations/2016_10_28_000000_update_oauth_tables.php index 022fb841ebe..26ab914ed63 100644 --- a/database/migrations/2016_10_28_000000_update_oauth_tables.php +++ b/database/migrations/2016_10_28_000000_update_oauth_tables.php @@ -14,20 +14,20 @@ class UpdateOauthTables extends Migration */ public function up() { - (new CreateOauthRefreshTokensTable())->down(); - (new CreateOauthAccessTokenScopesTable())->down(); - (new CreateOauthAccessTokensTable())->down(); - (new CreateOauthAuthCodeScopesTable())->down(); - (new CreateOauthAuthCodesTable())->down(); - (new CreateOauthSessionScopesTable())->down(); - (new CreateOauthSessionsTable())->down(); - (new CreateOauthClientGrantsTable())->down(); - (new CreateOauthClientScopesTable())->down(); - (new CreateOauthClientEndpointsTable())->down(); - (new CreateOauthClientsTable())->down(); - (new CreateOauthGrantScopesTable())->down(); - (new CreateOauthGrantsTable())->down(); - (new CreateOauthScopesTable())->down(); + migration('2016_03_18_170013_create_oauth_refresh_tokens_table')->down(); + migration('2016_03_18_170012_create_oauth_access_token_scopes_table')->down(); + migration('2016_03_18_170011_create_oauth_access_tokens_table')->down(); + migration('2016_03_18_170010_create_oauth_auth_code_scopes_table')->down(); + migration('2016_03_18_170009_create_oauth_auth_codes_table')->down(); + migration('2016_03_18_170008_create_oauth_session_scopes_table')->down(); + migration('2016_03_18_170007_create_oauth_sessions_table')->down(); + migration('2016_03_18_170006_create_oauth_client_grants_table')->down(); + migration('2016_03_18_170005_create_oauth_client_scopes_table')->down(); + migration('2016_03_18_170004_create_oauth_client_endpoints_table')->down(); + migration('2016_03_18_170003_create_oauth_clients_table')->down(); + migration('2016_03_18_170002_create_oauth_grant_scopes_table')->down(); + migration('2016_03_18_170001_create_oauth_grants_table')->down(); + migration('2016_03_18_170000_create_oauth_scopes_table')->down(); } /** @@ -37,19 +37,19 @@ public function up() */ public function down() { - (new CreateOauthScopesTable())->up(); - (new CreateOauthGrantsTable())->up(); - (new CreateOauthGrantScopesTable())->up(); - (new CreateOauthClientsTable())->up(); - (new CreateOauthClientEndpointsTable())->up(); - (new CreateOauthClientScopesTable())->up(); - (new CreateOauthClientGrantsTable())->up(); - (new CreateOauthSessionsTable())->up(); - (new CreateOauthSessionScopesTable())->up(); - (new CreateOauthAuthCodesTable())->up(); - (new CreateOauthAuthCodeScopesTable())->up(); - (new CreateOauthAccessTokensTable())->up(); - (new CreateOauthAccessTokenScopesTable())->up(); - (new CreateOauthRefreshTokensTable())->up(); + migration('2016_03_18_170000_create_oauth_scopes_table')->up(); + migration('2016_03_18_170001_create_oauth_grants_table')->up(); + migration('2016_03_18_170002_create_oauth_grant_scopes_table')->up(); + migration('2016_03_18_170003_create_oauth_clients_table')->up(); + migration('2016_03_18_170004_create_oauth_client_endpoints_table')->up(); + migration('2016_03_18_170005_create_oauth_client_scopes_table')->up(); + migration('2016_03_18_170006_create_oauth_client_grants_table')->up(); + migration('2016_03_18_170007_create_oauth_sessions_table')->up(); + migration('2016_03_18_170008_create_oauth_session_scopes_table')->up(); + migration('2016_03_18_170009_create_oauth_auth_codes_table')->up(); + migration('2016_03_18_170010_create_oauth_auth_code_scopes_table')->up(); + migration('2016_03_18_170011_create_oauth_access_tokens_table')->up(); + migration('2016_03_18_170012_create_oauth_access_token_scopes_table')->up(); + migration('2016_03_18_170013_create_oauth_refresh_tokens_table')->up(); } } diff --git a/database/migrations/2017_02_01_105338_drop_slack_users.php b/database/migrations/2017_02_01_105338_drop_slack_users.php index 70fdce5b1f9..76c21dfbf13 100644 --- a/database/migrations/2017_02_01_105338_drop_slack_users.php +++ b/database/migrations/2017_02_01_105338_drop_slack_users.php @@ -25,9 +25,9 @@ public function up() */ public function down() { - (new CreateOsuSlackUsersTable())->up(); - (new ChangePrimaryKeyOnSlackUsers())->up(); - (new OsuSlackUserMakeSlackIdNullable())->up(); - (new AddIndexOnSlackId())->up(); + migration('2016_02_27_103851_create_osu_slack_users_table')->up(); + migration('2016_03_02_214730_change_primary_key_on_slack_users')->up(); + migration('2016_03_03_223651_osu_slack_user_make_slack_id_nullable')->up(); + migration('2016_03_09_083112_add_index_on_slack_id')->up(); } } diff --git a/database/migrations/2017_02_13_013536_delete_contest_vote_aggregates_view.php b/database/migrations/2017_02_13_013536_delete_contest_vote_aggregates_view.php index 735dbd08822..7f517af9f6c 100644 --- a/database/migrations/2017_02_13_013536_delete_contest_vote_aggregates_view.php +++ b/database/migrations/2017_02_13_013536_delete_contest_vote_aggregates_view.php @@ -14,7 +14,7 @@ class DeleteContestVoteAggregatesView extends Migration */ public function up() { - (new CreateContestVoteAggregatesView())->down(); + migration('2016_08_25_055700_create_contest_vote_aggregates_view')->down(); } /** @@ -24,6 +24,6 @@ public function up() */ public function down() { - (new CreateContestVoteAggregatesView())->up(); + migration('2016_08_25_055700_create_contest_vote_aggregates_view')->up(); } } diff --git a/database/migrations/2017_08_28_110634_drop_beatmapset_discussions.php b/database/migrations/2017_08_28_110634_drop_beatmapset_discussions.php index fe2bf67d2d9..f1af5665620 100644 --- a/database/migrations/2017_08_28_110634_drop_beatmapset_discussions.php +++ b/database/migrations/2017_08_28_110634_drop_beatmapset_discussions.php @@ -14,7 +14,7 @@ class DropBeatmapsetDiscussions extends Migration */ public function up() { - (new CreateBeatmapsetDiscussions())->down(); + migration('2016_02_29_052133_create_beatmapset_discussions')->down(); } /** @@ -24,6 +24,6 @@ public function up() */ public function down() { - (new CreateBeatmapsetDiscussions())->up(); + migration('2016_02_29_052133_create_beatmapset_discussions')->up(); } } diff --git a/database/migrations/2017_11_22_081837_remove_kudosu_refresh_votes_from_beatmap_discussions.php b/database/migrations/2017_11_22_081837_remove_kudosu_refresh_votes_from_beatmap_discussions.php index 0ce4c3940d0..19008befe2d 100644 --- a/database/migrations/2017_11_22_081837_remove_kudosu_refresh_votes_from_beatmap_discussions.php +++ b/database/migrations/2017_11_22_081837_remove_kudosu_refresh_votes_from_beatmap_discussions.php @@ -14,7 +14,7 @@ class RemoveKudosuRefreshVotesFromBeatmapDiscussions extends Migration */ public function up() { - (new AddKudosuRefreshVotesToBeatmapDiscussions())->down(); + migration('2016_12_19_132350_add_kudosu_refresh_votes_to_beatmap_discussions')->down(); } /** @@ -24,6 +24,6 @@ public function up() */ public function down() { - (new AddKudosuRefreshVotesToBeatmapDiscussions())->up(); + migration('2016_12_19_132350_add_kudosu_refresh_votes_to_beatmap_discussions')->up(); } } diff --git a/database/migrations/2021_09_15_065842_create_new_score_tables.php b/database/migrations/2021_09_15_065842_create_new_score_tables.php index f2f50945c3e..3ee8010bcfe 100644 --- a/database/migrations/2021_09_15_065842_create_new_score_tables.php +++ b/database/migrations/2021_09_15_065842_create_new_score_tables.php @@ -49,6 +49,6 @@ public function down() { Schema::dropIfExists('solo_scores_process_history'); Schema::dropIfExists('solo_scores'); - (new CreateSoloScores())->up(); + migration('2021_03_24_130818_create_solo_scores')->up(); } } From d02ac3547c7ce7eaf34eb41bb062bc8fdb8694eb Mon Sep 17 00:00:00 2001 From: clayton Date: Mon, 14 Aug 2023 23:04:13 -0700 Subject: [PATCH 3/3] Simpler `migration()` implementation --- app/helpers.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/app/helpers.php b/app/helpers.php index 37628534669..458034fbd0c 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1852,17 +1852,7 @@ function unmix(string $resource): HtmlString /** * Get an instance of the named migration. */ -function migration(string $name): object +function migration(string $name): Migration { - $instance = app('files')->getRequire( - database_path('migrations').DIRECTORY_SEPARATOR."{$name}.php", - ); - - if (!$instance instanceof Migration) { - throw new Exception( - "\"{$name}\" does not return an instance of ".Migration::class.'.', - ); - } - - return $instance; + return require database_path("migrations/{$name}.php"); }