diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 83ed076b7..5e134aeea 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Auth\User; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,13 +14,13 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(User::TABLE)) { - Schema::create(User::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('users')) { + Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string(User::ATTRIBUTE_NAME); - $table->string(User::ATTRIBUTE_EMAIL)->unique(); - $table->timestamp(User::ATTRIBUTE_EMAIL_VERIFIED_AT)->nullable(); - $table->string(User::ATTRIBUTE_PASSWORD); + $table->string('name'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); $table->text('two_factor_secret') ->nullable(); @@ -36,18 +35,10 @@ return new class extends Migration $table->rememberToken(); $table->timestamps(6); - $table->softDeletes(User::ATTRIBUTE_DELETED_AT, 6); + $table->softDeletes('deleted_at', 6); - $table->unique(User::ATTRIBUTE_NAME); + $table->unique('name'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(User::TABLE); - } }; diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 1dd3cbc05..2f599c7fb 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -21,12 +21,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('password_reset_tokens'); - } }; diff --git a/database/migrations/2017_11_26_225409_create_videos_table.php b/database/migrations/2017_11_26_225409_create_videos_table.php index b37b852b2..d6c76d869 100644 --- a/database/migrations/2017_11_26_225409_create_videos_table.php +++ b/database/migrations/2017_11_26_225409_create_videos_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Enums\Models\Wiki\VideoOverlap; -use App\Models\Wiki\Video; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,32 +13,24 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Video::TABLE)) { - Schema::create(Video::TABLE, function (Blueprint $table) { - $table->id(Video::ATTRIBUTE_ID); + if (! Schema::hasTable('videos')) { + Schema::create('videos', function (Blueprint $table) { + $table->id('video_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Video::ATTRIBUTE_BASENAME); - $table->string(Video::ATTRIBUTE_FILENAME); - $table->string(Video::ATTRIBUTE_PATH); - $table->integer(Video::ATTRIBUTE_SIZE); - $table->string(Video::ATTRIBUTE_MIMETYPE); - $table->integer(Video::ATTRIBUTE_RESOLUTION)->nullable(); - $table->boolean(Video::ATTRIBUTE_NC)->default(false); - $table->boolean(Video::ATTRIBUTE_SUBBED)->default(false); - $table->boolean(Video::ATTRIBUTE_LYRICS)->default(false); - $table->boolean(Video::ATTRIBUTE_UNCEN)->default(false); - $table->integer(Video::ATTRIBUTE_OVERLAP)->default(VideoOverlap::NONE->value); - $table->integer(Video::ATTRIBUTE_SOURCE)->nullable(); + $table->softDeletes(precision: 6); + $table->string('basename'); + $table->string('filename'); + $table->string('path'); + $table->integer('size'); + $table->string('mimetype'); + $table->integer('resolution')->nullable(); + $table->boolean('nc')->default(false); + $table->boolean('subbed')->default(false); + $table->boolean('lyrics')->default(false); + $table->boolean('uncen')->default(false); + $table->integer('overlap')->default(0); + $table->integer('source')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Video::TABLE); - } }; diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index dfd360a3f..df5fff8ef 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -25,12 +25,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('failed_jobs'); - } }; diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php index 5599302de..5047266a5 100644 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -26,12 +26,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('personal_access_tokens'); - } }; diff --git a/database/migrations/2020_04_12_212732_create_announcements_table.php b/database/migrations/2020_04_12_212732_create_announcements_table.php index 6b9b37c0b..19774dfd8 100644 --- a/database/migrations/2020_04_12_212732_create_announcements_table.php +++ b/database/migrations/2020_04_12_212732_create_announcements_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Admin\Announcement; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,20 +13,12 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Announcement::TABLE)) { - Schema::create(Announcement::TABLE, function (Blueprint $table) { - $table->id(Announcement::ATTRIBUTE_ID); + if (! Schema::hasTable('announcements')) { + Schema::create('announcements', function (Blueprint $table) { + $table->id('announcement_id'); $table->timestamps(6); - $table->text(Announcement::ATTRIBUTE_CONTENT); + $table->text('content'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Announcement::TABLE); - } }; diff --git a/database/migrations/2020_05_05_044925_create_anime_table.php b/database/migrations/2020_05_05_044925_create_anime_table.php index 1ef0928d9..b1d9d8f78 100644 --- a/database/migrations/2020_05_05_044925_create_anime_table.php +++ b/database/migrations/2020_05_05_044925_create_anime_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Enums\Models\Wiki\AnimeMediaFormat; -use App\Models\Wiki\Anime; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,26 +13,18 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Anime::TABLE)) { - Schema::create(Anime::TABLE, function (Blueprint $table) { - $table->id(Anime::ATTRIBUTE_ID); + if (! Schema::hasTable('anime')) { + Schema::create('anime', function (Blueprint $table) { + $table->id('anime_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Anime::ATTRIBUTE_SLUG); - $table->string(Anime::ATTRIBUTE_NAME); - $table->integer(Anime::ATTRIBUTE_YEAR)->nullable(); - $table->integer(Anime::ATTRIBUTE_SEASON)->nullable(); - $table->integer(Anime::ATTRIBUTE_MEDIA_FORMAT)->default(AnimeMediaFormat::UNKNOWN->value); - $table->text(Anime::ATTRIBUTE_SYNOPSIS)->nullable(); + $table->softDeletes(precision: 6); + $table->string('slug'); + $table->string('name'); + $table->integer('year')->nullable(); + $table->integer('season')->nullable(); + $table->integer('media_format')->default(0); + $table->text('synopsis')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Anime::TABLE); - } }; diff --git a/database/migrations/2020_05_05_044939_create_series_table.php b/database/migrations/2020_05_05_044939_create_series_table.php index f33cfba6f..7d185edd2 100644 --- a/database/migrations/2020_05_05_044939_create_series_table.php +++ b/database/migrations/2020_05_05_044939_create_series_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Series; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,22 +13,14 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Series::TABLE)) { - Schema::create(Series::TABLE, function (Blueprint $table) { - $table->id(Series::ATTRIBUTE_ID); + if (! Schema::hasTable('series')) { + Schema::create('series', function (Blueprint $table) { + $table->id('series_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Series::ATTRIBUTE_SLUG); - $table->string(Series::ATTRIBUTE_NAME); + $table->softDeletes(precision: 6); + $table->string('slug'); + $table->string('name'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Series::TABLE); - } }; diff --git a/database/migrations/2020_05_05_044953_create_songs_table.php b/database/migrations/2020_05_05_044953_create_songs_table.php index 257f254ef..4be9af920 100644 --- a/database/migrations/2020_05_05_044953_create_songs_table.php +++ b/database/migrations/2020_05_05_044953_create_songs_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Song; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,21 +13,13 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Song::TABLE)) { - Schema::create(Song::TABLE, function (Blueprint $table) { - $table->id(Song::ATTRIBUTE_ID); + if (! Schema::hasTable('songs')) { + Schema::create('songs', function (Blueprint $table) { + $table->id('song_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Song::ATTRIBUTE_TITLE)->nullable(); + $table->softDeletes(precision: 6); + $table->string('title')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Song::TABLE); - } }; diff --git a/database/migrations/2020_05_05_045006_create_artists_table.php b/database/migrations/2020_05_05_045006_create_artists_table.php index 9b7d2670f..f53c79686 100644 --- a/database/migrations/2020_05_05_045006_create_artists_table.php +++ b/database/migrations/2020_05_05_045006_create_artists_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Artist; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,23 +13,15 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Artist::TABLE)) { - Schema::create(Artist::TABLE, function (Blueprint $table) { - $table->id(Artist::ATTRIBUTE_ID); + if (! Schema::hasTable('artists')) { + Schema::create('artists', function (Blueprint $table) { + $table->id('artist_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Artist::ATTRIBUTE_SLUG); - $table->string(Artist::ATTRIBUTE_NAME); - $table->text(Artist::ATTRIBUTE_INFORMATION)->nullable(); + $table->softDeletes(precision: 6); + $table->string('slug'); + $table->string('name'); + $table->text('information')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Artist::TABLE); - } }; diff --git a/database/migrations/2020_05_05_045017_create_resources_table.php b/database/migrations/2020_05_05_045017_create_resources_table.php index 80b78ea07..e7fca968f 100644 --- a/database/migrations/2020_05_05_045017_create_resources_table.php +++ b/database/migrations/2020_05_05_045017_create_resources_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\ExternalResource; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,23 +13,15 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ExternalResource::TABLE)) { - Schema::create(ExternalResource::TABLE, function (Blueprint $table) { - $table->id(ExternalResource::ATTRIBUTE_ID); + if (! Schema::hasTable('resources')) { + Schema::create('resources', function (Blueprint $table) { + $table->id('resource_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->integer(ExternalResource::ATTRIBUTE_SITE)->nullable(); - $table->string(ExternalResource::ATTRIBUTE_LINK)->nullable(); - $table->integer(ExternalResource::ATTRIBUTE_EXTERNAL_ID)->nullable(); + $table->softDeletes(precision: 6); + $table->integer('site')->nullable(); + $table->string('link')->nullable(); + $table->integer('external_id')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ExternalResource::TABLE); - } }; diff --git a/database/migrations/2020_05_05_045028_create_anime_themes_table.php b/database/migrations/2020_05_05_045028_create_anime_themes_table.php index 4cf469b4f..14a9462e6 100644 --- a/database/migrations/2020_05_05_045028_create_anime_themes_table.php +++ b/database/migrations/2020_05_05_045028_create_anime_themes_table.php @@ -2,10 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Anime; -use App\Models\Wiki\Anime\AnimeTheme; -use App\Models\Wiki\Song; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -17,29 +13,21 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(AnimeTheme::TABLE)) { - Schema::create(AnimeTheme::TABLE, function (Blueprint $table) { - $table->id(AnimeTheme::ATTRIBUTE_ID); + if (! Schema::hasTable('anime_themes')) { + Schema::create('anime_themes', function (Blueprint $table) { + $table->id('theme_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->integer(AnimeTheme::ATTRIBUTE_TYPE)->nullable(); - $table->integer(AnimeTheme::ATTRIBUTE_SEQUENCE)->nullable(); - $table->string(AnimeTheme::ATTRIBUTE_SLUG); + $table->softDeletes(precision: 6); + $table->integer('type')->nullable(); + $table->integer('sequence')->nullable(); + $table->string('slug'); - $table->unsignedBigInteger(AnimeTheme::ATTRIBUTE_ANIME); - $table->foreign(AnimeTheme::ATTRIBUTE_ANIME)->references(Anime::ATTRIBUTE_ID)->on(Anime::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('anime_id'); + $table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete(); - $table->unsignedBigInteger(AnimeTheme::ATTRIBUTE_SONG)->nullable(); - $table->foreign(AnimeTheme::ATTRIBUTE_SONG)->references(Song::ATTRIBUTE_ID)->on(Song::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('song_id')->nullable(); + $table->foreign('song_id')->references('song_id')->on('songs')->nullOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(AnimeTheme::TABLE); - } }; diff --git a/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php b/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php index b7ac82021..1a18c6a95 100644 --- a/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php +++ b/database/migrations/2020_05_05_045037_create_anime_theme_entries_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Anime\AnimeTheme; -use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,28 +13,20 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(AnimeThemeEntry::TABLE)) { - Schema::create(AnimeThemeEntry::TABLE, function (Blueprint $table) { - $table->id(AnimeThemeEntry::ATTRIBUTE_ID); + if (! Schema::hasTable('anime_theme_entries')) { + Schema::create('anime_theme_entries', function (Blueprint $table) { + $table->id('entry_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->integer(AnimeThemeEntry::ATTRIBUTE_VERSION)->nullable(); - $table->string(AnimeThemeEntry::ATTRIBUTE_EPISODES)->nullable(); - $table->boolean(AnimeThemeEntry::ATTRIBUTE_NSFW)->default(false); - $table->boolean(AnimeThemeEntry::ATTRIBUTE_SPOILER)->default(false); - $table->text(AnimeThemeEntry::ATTRIBUTE_NOTES)->nullable(); + $table->softDeletes(precision: 6); + $table->integer('version')->nullable(); + $table->string('episodes')->nullable(); + $table->boolean('nsfw')->default(false); + $table->boolean('spoiler')->default(false); + $table->text('notes')->nullable(); - $table->unsignedBigInteger(AnimeThemeEntry::ATTRIBUTE_THEME); - $table->foreign(AnimeThemeEntry::ATTRIBUTE_THEME)->references(AnimeTheme::ATTRIBUTE_ID)->on(AnimeTheme::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('theme_id'); + $table->foreign('theme_id')->references('theme_id')->on('anime_themes')->cascadeOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(AnimeThemeEntry::TABLE); - } }; diff --git a/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php b/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php index b8268926c..d5d9e10a8 100644 --- a/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php +++ b/database/migrations/2020_05_05_051400_create_anime_synonyms_table.php @@ -2,10 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Enums\Models\Wiki\AnimeSynonymType; -use App\Models\Wiki\Anime; -use App\Models\Wiki\Anime\AnimeSynonym; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -17,25 +13,17 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(AnimeSynonym::TABLE)) { - Schema::create(AnimeSynonym::TABLE, function (Blueprint $table) { - $table->id(AnimeSynonym::ATTRIBUTE_ID); + if (! Schema::hasTable('anime_synonyms')) { + Schema::create('anime_synonyms', function (Blueprint $table) { + $table->id('synonym_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(AnimeSynonym::ATTRIBUTE_TEXT)->nullable(); - $table->integer(AnimeSynonym::ATTRIBUTE_TYPE)->default(AnimeSynonymType::OTHER->value); + $table->softDeletes(precision: 6); + $table->string('text')->nullable(); + $table->integer('type')->default(0); - $table->unsignedBigInteger(AnimeSynonym::ATTRIBUTE_ANIME); - $table->foreign(AnimeSynonym::ATTRIBUTE_ANIME)->references(Anime::ATTRIBUTE_ID)->on(Anime::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('anime_id'); + $table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(AnimeSynonym::TABLE); - } }; diff --git a/database/migrations/2020_05_05_054036_create_anime_series.php b/database/migrations/2020_05_05_054036_create_anime_series.php index e482d57dc..3cbea128f 100644 --- a/database/migrations/2020_05_05_054036_create_anime_series.php +++ b/database/migrations/2020_05_05_054036_create_anime_series.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Anime; -use App\Models\Wiki\Series; -use App\Pivots\Wiki\AnimeSeries; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,23 +13,15 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(AnimeSeries::TABLE)) { - Schema::create(AnimeSeries::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('anime_series')) { + Schema::create('anime_series', function (Blueprint $table) { $table->timestamps(6); - $table->unsignedBigInteger(AnimeSeries::ATTRIBUTE_ANIME); - $table->foreign(AnimeSeries::ATTRIBUTE_ANIME)->references(Anime::ATTRIBUTE_ID)->on(Anime::TABLE)->cascadeOnDelete(); - $table->unsignedBigInteger(AnimeSeries::ATTRIBUTE_SERIES); - $table->foreign(AnimeSeries::ATTRIBUTE_SERIES)->references(Series::ATTRIBUTE_ID)->on(Series::TABLE)->cascadeOnDelete(); - $table->primary([AnimeSeries::ATTRIBUTE_ANIME, AnimeSeries::ATTRIBUTE_SERIES]); + $table->unsignedBigInteger('anime_id'); + $table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete(); + $table->unsignedBigInteger('series_id'); + $table->foreign('series_id')->references('series_id')->on('series')->cascadeOnDelete(); + $table->primary(['anime_id', 'series_id']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(AnimeSeries::TABLE); - } }; diff --git a/database/migrations/2020_05_05_055804_create_anime_theme_entry_video.php b/database/migrations/2020_05_05_055804_create_anime_theme_entry_video.php index 87c7f0b21..48bb079de 100644 --- a/database/migrations/2020_05_05_055804_create_anime_theme_entry_video.php +++ b/database/migrations/2020_05_05_055804_create_anime_theme_entry_video.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; -use App\Models\Wiki\Video; -use App\Pivots\Wiki\AnimeThemeEntryVideo; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,23 +13,15 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(AnimeThemeEntryVideo::TABLE)) { - Schema::create(AnimeThemeEntryVideo::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('anime_theme_entry_video')) { + Schema::create('anime_theme_entry_video', function (Blueprint $table) { $table->timestamps(6); - $table->unsignedBigInteger(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY); - $table->foreign(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY)->references(AnimeThemeEntry::ATTRIBUTE_ID)->on(AnimeThemeEntry::TABLE)->cascadeOnDelete(); - $table->unsignedBigInteger(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO); - $table->foreign(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO)->references(Video::ATTRIBUTE_ID)->on('videos')->cascadeOnDelete(); - $table->primary([AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO]); + $table->unsignedBigInteger('entry_id'); + $table->foreign('entry_id')->references('entry_id')->on('anime_theme_entries')->cascadeOnDelete(); + $table->unsignedBigInteger('video_id'); + $table->foreign('video_id')->references('video_id')->on('videos')->cascadeOnDelete(); + $table->primary(['entry_id', 'video_id']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(AnimeThemeEntryVideo::TABLE); - } }; diff --git a/database/migrations/2020_05_05_062655_create_artist_song.php b/database/migrations/2020_05_05_062655_create_artist_song.php index fcaaa031a..9bdc770ec 100644 --- a/database/migrations/2020_05_05_062655_create_artist_song.php +++ b/database/migrations/2020_05_05_062655_create_artist_song.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Artist; -use App\Models\Wiki\Song; -use App\Pivots\Wiki\ArtistSong; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,25 +13,17 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ArtistSong::TABLE)) { - Schema::create(ArtistSong::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('artist_song')) { + Schema::create('artist_song', function (Blueprint $table) { $table->timestamps(6); - $table->unsignedBigInteger(ArtistSong::ATTRIBUTE_ARTIST); - $table->foreign(ArtistSong::ATTRIBUTE_ARTIST)->references(Artist::ATTRIBUTE_ID)->on(Artist::TABLE)->cascadeOnDelete(); - $table->unsignedBigInteger(ArtistSong::ATTRIBUTE_SONG); - $table->foreign(ArtistSong::ATTRIBUTE_SONG)->references(Song::ATTRIBUTE_ID)->on(Song::TABLE)->cascadeOnDelete(); - $table->primary([ArtistSong::ATTRIBUTE_ARTIST, ArtistSong::ATTRIBUTE_SONG]); - $table->string(ArtistSong::ATTRIBUTE_AS)->nullable(); - $table->string(ArtistSong::ATTRIBUTE_ALIAS)->nullable(); + $table->unsignedBigInteger('artist_id'); + $table->foreign('artist_id')->references('artist_id')->on('artists')->cascadeOnDelete(); + $table->unsignedBigInteger('song_id'); + $table->foreign('song_id')->references('song_id')->on('songs')->cascadeOnDelete(); + $table->primary(['artist_id', 'song_id']); + $table->string('as')->nullable(); + $table->string('alias')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ArtistSong::TABLE); - } }; diff --git a/database/migrations/2020_06_10_050701_create_artist_member.php b/database/migrations/2020_06_10_050701_create_artist_member.php index 89316be34..c88718e90 100644 --- a/database/migrations/2020_06_10_050701_create_artist_member.php +++ b/database/migrations/2020_06_10_050701_create_artist_member.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Artist; -use App\Pivots\Wiki\ArtistMember; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,26 +13,18 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ArtistMember::TABLE)) { - Schema::create(ArtistMember::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('artist_member')) { + Schema::create('artist_member', function (Blueprint $table) { $table->timestamps(6); - $table->unsignedBigInteger(ArtistMember::ATTRIBUTE_ARTIST); - $table->foreign(ArtistMember::ATTRIBUTE_ARTIST)->references(Artist::ATTRIBUTE_ID)->on(Artist::TABLE)->cascadeOnDelete(); - $table->unsignedBigInteger(ArtistMember::ATTRIBUTE_MEMBER); - $table->foreign(ArtistMember::ATTRIBUTE_MEMBER)->references(Artist::ATTRIBUTE_ID)->on(Artist::TABLE)->cascadeOnDelete(); - $table->primary([ArtistMember::ATTRIBUTE_ARTIST, ArtistMember::ATTRIBUTE_MEMBER]); - $table->string(ArtistMember::ATTRIBUTE_AS)->nullable(); - $table->string(ArtistMember::ATTRIBUTE_ALIAS)->nullable(); - $table->string(ArtistMember::ATTRIBUTE_NOTES)->nullable(); + $table->unsignedBigInteger('artist_id'); + $table->foreign('artist_id')->references('artist_id')->on('artists')->cascadeOnDelete(); + $table->unsignedBigInteger('member_id'); + $table->foreign('member_id')->references('artist_id')->on('artists')->cascadeOnDelete(); + $table->primary(['artist_id', 'member_id']); + $table->string('as')->nullable(); + $table->string('alias')->nullable(); + $table->string('notes')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ArtistMember::TABLE); - } }; diff --git a/database/migrations/2020_09_16_183751_create_sessions_table.php b/database/migrations/2020_09_16_183751_create_sessions_table.php index 4b2b62a7d..ccc5318ce 100644 --- a/database/migrations/2020_09_16_183751_create_sessions_table.php +++ b/database/migrations/2020_09_16_183751_create_sessions_table.php @@ -24,12 +24,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('sessions'); - } }; diff --git a/database/migrations/2020_11_24_231534_create_image_table.php b/database/migrations/2020_11_24_231534_create_image_table.php index 0d6cd67cc..2992a4edc 100644 --- a/database/migrations/2020_11_24_231534_create_image_table.php +++ b/database/migrations/2020_11_24_231534_create_image_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Image; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,22 +13,14 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Image::TABLE)) { - Schema::create(Image::TABLE, function (Blueprint $table) { - $table->id(Image::ATTRIBUTE_ID); + if (! Schema::hasTable('images')) { + Schema::create('images', function (Blueprint $table) { + $table->id('image_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Image::ATTRIBUTE_PATH); - $table->integer(Image::ATTRIBUTE_FACET)->nullable(); + $table->softDeletes(precision: 6); + $table->string('path'); + $table->integer('facet')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Image::TABLE); - } }; diff --git a/database/migrations/2021_08_20_185746_create_studios_table.php b/database/migrations/2021_08_20_185746_create_studios_table.php index ffb223b7c..d38316a90 100644 --- a/database/migrations/2021_08_20_185746_create_studios_table.php +++ b/database/migrations/2021_08_20_185746_create_studios_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Studio; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,22 +13,14 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Studio::TABLE)) { - Schema::create(Studio::TABLE, function (Blueprint $table) { - $table->id(Studio::ATTRIBUTE_ID); + if (! Schema::hasTable('studios')) { + Schema::create('studios', function (Blueprint $table) { + $table->id('studio_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Studio::ATTRIBUTE_SLUG); - $table->string(Studio::ATTRIBUTE_NAME); + $table->softDeletes(precision: 6); + $table->string('slug'); + $table->string('name'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Studio::TABLE); - } }; diff --git a/database/migrations/2021_08_20_213018_create_anime_studio.php b/database/migrations/2021_08_20_213018_create_anime_studio.php index 688d30d3c..0d7ddc6ee 100644 --- a/database/migrations/2021_08_20_213018_create_anime_studio.php +++ b/database/migrations/2021_08_20_213018_create_anime_studio.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Anime; -use App\Models\Wiki\Studio; -use App\Pivots\Wiki\AnimeStudio; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,23 +13,15 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(AnimeStudio::TABLE)) { - Schema::create(AnimeStudio::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('anime_studio')) { + Schema::create('anime_studio', function (Blueprint $table) { $table->timestamps(6); - $table->unsignedBigInteger(AnimeStudio::ATTRIBUTE_ANIME); - $table->foreign(AnimeStudio::ATTRIBUTE_ANIME)->references(Anime::ATTRIBUTE_ID)->on(Anime::TABLE)->cascadeOnDelete(); - $table->unsignedBigInteger(AnimeStudio::ATTRIBUTE_STUDIO); - $table->foreign(AnimeStudio::ATTRIBUTE_STUDIO)->references(Studio::ATTRIBUTE_ID)->on(Studio::TABLE)->cascadeOnDelete(); - $table->primary([AnimeStudio::ATTRIBUTE_ANIME, AnimeStudio::ATTRIBUTE_STUDIO]); + $table->unsignedBigInteger('anime_id'); + $table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete(); + $table->unsignedBigInteger('studio_id'); + $table->foreign('studio_id')->references('studio_id')->on('studios')->cascadeOnDelete(); + $table->primary(['anime_id', 'studio_id']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(AnimeStudio::TABLE); - } }; diff --git a/database/migrations/2022_02_14_175203_create_page_table.php b/database/migrations/2022_02_14_175203_create_page_table.php index 4455720ac..0378b2d6e 100644 --- a/database/migrations/2022_02_14_175203_create_page_table.php +++ b/database/migrations/2022_02_14_175203_create_page_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Document\Page; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,23 +13,15 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Page::TABLE)) { - Schema::create(Page::TABLE, function (Blueprint $table) { - $table->id(Page::ATTRIBUTE_ID); + if (! Schema::hasTable('pages')) { + Schema::create('pages', function (Blueprint $table) { + $table->id('page_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Page::ATTRIBUTE_SLUG); - $table->string(Page::ATTRIBUTE_NAME); - $table->mediumText(Page::ATTRIBUTE_BODY); + $table->softDeletes(precision: 6); + $table->string('slug'); + $table->string('name'); + $table->mediumText('body'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Page::TABLE); - } }; diff --git a/database/migrations/2022_04_09_234337_create_jobs_table.php b/database/migrations/2022_04_09_234337_create_jobs_table.php index 94c93cce1..6eb97de8c 100644 --- a/database/migrations/2022_04_09_234337_create_jobs_table.php +++ b/database/migrations/2022_04_09_234337_create_jobs_table.php @@ -25,12 +25,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('jobs'); - } }; diff --git a/database/migrations/2022_05_09_032230_create_permission_tables.php b/database/migrations/2022_05_09_032230_create_permission_tables.php index 5867d6752..a7ff4987a 100644 --- a/database/migrations/2022_05_09_032230_create_permission_tables.php +++ b/database/migrations/2022_05_09_032230_create_permission_tables.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Auth\Role; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -48,9 +47,9 @@ return new class extends Migration } $table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format) $table->string('guard_name'); // For MyISAM use string('guard_name', 25); - $table->boolean(Role::ATTRIBUTE_DEFAULT)->default(false); - $table->string(Role::ATTRIBUTE_COLOR)->nullable(); - $table->integer(Role::ATTRIBUTE_PRIORITY)->nullable(); + $table->boolean('default')->default(false); + $table->string('color')->nullable(); + $table->integer('priority')->nullable(); $table->timestamps(); if ($teams || config('permission.testing')) { $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); @@ -134,22 +133,4 @@ return new class extends Migration ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) ->forget(config('permission.cache.key')); } - - /** - * Reverse the migrations. - */ - public function down(): void - { - $tableNames = config('permission.table_names'); - - if (empty($tableNames)) { - throw new Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); - } - - Schema::dropIfExists($tableNames['role_has_permissions']); - Schema::dropIfExists($tableNames['model_has_roles']); - Schema::dropIfExists($tableNames['model_has_permissions']); - Schema::dropIfExists($tableNames['roles']); - Schema::dropIfExists($tableNames['permissions']); - } }; diff --git a/database/migrations/2022_05_12_165551_create_cache_table.php b/database/migrations/2022_05_12_165551_create_cache_table.php index d571846dd..0db56b962 100644 --- a/database/migrations/2022_05_12_165551_create_cache_table.php +++ b/database/migrations/2022_05_12_165551_create_cache_table.php @@ -29,13 +29,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('cache'); - Schema::dropIfExists('cache_locks'); - } }; diff --git a/database/migrations/2022_07_05_200425_create_audio_table.php b/database/migrations/2022_07_05_200425_create_audio_table.php index 8f7e7727c..e25692d4f 100644 --- a/database/migrations/2022_07_05_200425_create_audio_table.php +++ b/database/migrations/2022_07_05_200425_create_audio_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Audio; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,25 +13,17 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Audio::TABLE)) { - Schema::create(Audio::TABLE, function (Blueprint $table) { - $table->id(Audio::ATTRIBUTE_ID); + if (! Schema::hasTable('audios')) { + Schema::create('audios', function (Blueprint $table) { + $table->id('audio_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Audio::ATTRIBUTE_BASENAME); - $table->string(Audio::ATTRIBUTE_FILENAME); - $table->string(Audio::ATTRIBUTE_PATH); - $table->integer(Audio::ATTRIBUTE_SIZE); - $table->string(Audio::ATTRIBUTE_MIMETYPE); + $table->softDeletes(precision: 6); + $table->string('basename'); + $table->string('filename'); + $table->string('path'); + $table->integer('size'); + $table->string('mimetype'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Audio::TABLE); - } }; diff --git a/database/migrations/2022_07_16_214509_add_video_belongs_to_audio.php b/database/migrations/2022_07_16_214509_add_video_belongs_to_audio.php index e48f4171d..ac5288db5 100644 --- a/database/migrations/2022_07_16_214509_add_video_belongs_to_audio.php +++ b/database/migrations/2022_07_16_214509_add_video_belongs_to_audio.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Audio; -use App\Models\Wiki\Video; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,22 +13,10 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasColumn(Video::TABLE, Video::ATTRIBUTE_AUDIO)) { - Schema::table(Video::TABLE, function (Blueprint $table) { - $table->unsignedBigInteger(Video::ATTRIBUTE_AUDIO)->nullable(); - $table->foreign(Video::ATTRIBUTE_AUDIO)->references(Audio::ATTRIBUTE_ID)->on(Audio::TABLE)->nullOnDelete(); - }); - } - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - if (Schema::hasColumn(Video::TABLE, Video::ATTRIBUTE_AUDIO)) { - Schema::table(Video::TABLE, function (Blueprint $table) { - $table->dropConstrainedForeignId(Video::ATTRIBUTE_AUDIO); + if (! Schema::hasColumn('videos', 'audio_id')) { + Schema::table('videos', function (Blueprint $table) { + $table->unsignedBigInteger('audio_id')->nullable(); + $table->foreign('audio_id')->references('audio_id')->on('audios')->nullOnDelete(); }); } } diff --git a/database/migrations/2022_09_10_191055_create_dumps_table.php b/database/migrations/2022_09_10_191055_create_dumps_table.php index 240ff3cdc..5c22b8a37 100644 --- a/database/migrations/2022_09_10_191055_create_dumps_table.php +++ b/database/migrations/2022_09_10_191055_create_dumps_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Admin\Dump; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,20 +13,12 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Dump::TABLE)) { - Schema::create(Dump::TABLE, function (Blueprint $table) { - $table->id(Dump::ATTRIBUTE_ID); + if (! Schema::hasTable('dumps')) { + Schema::create('dumps', function (Blueprint $table) { + $table->id('dump_id'); $table->timestamps(6); - $table->string(Dump::ATTRIBUTE_PATH); + $table->string('path'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Dump::TABLE); - } }; diff --git a/database/migrations/2022_09_21_020421_create_video_script_table.php b/database/migrations/2022_09_21_020421_create_video_script_table.php index 5625aa275..4d908f144 100644 --- a/database/migrations/2022_09_21_020421_create_video_script_table.php +++ b/database/migrations/2022_09_21_020421_create_video_script_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Video; -use App\Models\Wiki\Video\VideoScript; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,24 +13,16 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(VideoScript::TABLE)) { - Schema::create(VideoScript::TABLE, function (Blueprint $table) { - $table->id(VideoScript::ATTRIBUTE_ID); + if (! Schema::hasTable('video_scripts')) { + Schema::create('video_scripts', function (Blueprint $table) { + $table->id('script_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(VideoScript::ATTRIBUTE_PATH); + $table->softDeletes(precision: 6); + $table->string('path'); - $table->unsignedBigInteger(VideoScript::ATTRIBUTE_VIDEO)->nullable(); - $table->foreign(VideoScript::ATTRIBUTE_VIDEO)->references(Video::ATTRIBUTE_ID)->on(Video::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('video_id')->nullable(); + $table->foreign('video_id')->references('video_id')->on('videos')->nullOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(VideoScript::TABLE); - } }; diff --git a/database/migrations/2022_09_29_203332_create_playlists_table.php b/database/migrations/2022_09_29_203332_create_playlists_table.php index 6be5b9caf..07cd9c9b9 100644 --- a/database/migrations/2022_09_29_203332_create_playlists_table.php +++ b/database/migrations/2022_09_29_203332_create_playlists_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Contracts\Models\HasHashids; -use App\Models\Auth\User; -use App\Models\List\Playlist; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\MySqlConnection; use Illuminate\Database\Schema\Blueprint; @@ -18,31 +15,23 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Playlist::TABLE)) { - Schema::create(Playlist::TABLE, function (Blueprint $table) { - $table->id(Playlist::ATTRIBUTE_ID); + if (! Schema::hasTable('playlists')) { + Schema::create('playlists', function (Blueprint $table) { + $table->id('playlist_id'); $table->timestamps(6); - $hashIdColumn = $table->string(HasHashids::ATTRIBUTE_HASHID)->nullable(); + $hashIdColumn = $table->string('hashid')->nullable(); if (DB::connection() instanceof MySqlConnection) { // Set collation to binary to be case-sensitive $hashIdColumn->collation('utf8mb4_bin'); } - $table->string(Playlist::ATTRIBUTE_NAME); - $table->integer(Playlist::ATTRIBUTE_VISIBILITY); + $table->string('name'); + $table->integer('visibility'); - $table->unsignedBigInteger(Playlist::ATTRIBUTE_USER)->nullable(); - $table->foreign(Playlist::ATTRIBUTE_USER)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('user_id')->nullable(); + $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); - $table->text(Playlist::ATTRIBUTE_DESCRIPTION)->nullable(); + $table->text('description')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Playlist::TABLE); - } }; diff --git a/database/migrations/2022_09_29_204718_create_playlist_tracks_table.php b/database/migrations/2022_09_29_204718_create_playlist_tracks_table.php index bd11fd3e9..df4f2d697 100644 --- a/database/migrations/2022_09_29_204718_create_playlist_tracks_table.php +++ b/database/migrations/2022_09_29_204718_create_playlist_tracks_table.php @@ -2,11 +2,6 @@ declare(strict_types=1); -use App\Contracts\Models\HasHashids; -use App\Models\List\Playlist; -use App\Models\List\Playlist\PlaylistTrack; -use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; -use App\Models\Wiki\Video; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\MySqlConnection; use Illuminate\Database\Schema\Blueprint; @@ -20,39 +15,31 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(PlaylistTrack::TABLE)) { - Schema::create(PlaylistTrack::TABLE, function (Blueprint $table) { - $table->id(PlaylistTrack::ATTRIBUTE_ID); + if (! Schema::hasTable('playlist_tracks')) { + Schema::create('playlist_tracks', function (Blueprint $table) { + $table->id('track_id'); $table->timestamps(6); - $hashIdColumn = $table->string(HasHashids::ATTRIBUTE_HASHID)->nullable(); + $hashIdColumn = $table->string('hashid')->nullable(); if (DB::connection() instanceof MySqlConnection) { // Set collation to binary to be case-sensitive $hashIdColumn->collation('utf8mb4_bin'); } - $table->unsignedBigInteger(PlaylistTrack::ATTRIBUTE_PLAYLIST); - $table->foreign(PlaylistTrack::ATTRIBUTE_PLAYLIST)->references(Playlist::ATTRIBUTE_ID)->on(Playlist::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('playlist_id'); + $table->foreign('playlist_id')->references('playlist_id')->on('playlists')->cascadeOnDelete(); - $table->unsignedBigInteger(PlaylistTrack::ATTRIBUTE_ENTRY)->nullable(); - $table->foreign(PlaylistTrack::ATTRIBUTE_ENTRY)->references(AnimeThemeEntry::ATTRIBUTE_ID)->on(AnimeThemeEntry::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('entry_id')->nullable(); + $table->foreign('entry_id')->references('entry_id')->on('anime_theme_entries')->nullOnDelete(); - $table->unsignedBigInteger(PlaylistTrack::ATTRIBUTE_VIDEO)->nullable(); - $table->foreign(PlaylistTrack::ATTRIBUTE_VIDEO)->references(Video::ATTRIBUTE_ID)->on(Video::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('video_id')->nullable(); + $table->foreign('video_id')->references('video_id')->on('videos')->nullOnDelete(); - $table->unsignedBigInteger(PlaylistTrack::ATTRIBUTE_PREVIOUS)->nullable(); - $table->foreign(PlaylistTrack::ATTRIBUTE_PREVIOUS)->references(PlaylistTrack::ATTRIBUTE_ID)->on(PlaylistTrack::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('previous_id')->nullable(); + $table->foreign('previous_id')->references('track_id')->on('playlist_tracks')->nullOnDelete(); - $table->unsignedBigInteger(PlaylistTrack::ATTRIBUTE_NEXT)->nullable(); - $table->foreign(PlaylistTrack::ATTRIBUTE_NEXT)->references(PlaylistTrack::ATTRIBUTE_ID)->on(PlaylistTrack::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('next_id')->nullable(); + $table->foreign('next_id')->references('track_id')->on('playlist_tracks')->nullOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(PlaylistTrack::TABLE); - } }; diff --git a/database/migrations/2022_09_29_205510_add_first_last_tracks_to_playlist.php b/database/migrations/2022_09_29_205510_add_first_last_tracks_to_playlist.php index e81c00918..f3f439f40 100644 --- a/database/migrations/2022_09_29_205510_add_first_last_tracks_to_playlist.php +++ b/database/migrations/2022_09_29_205510_add_first_last_tracks_to_playlist.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\List\Playlist; -use App\Models\List\Playlist\PlaylistTrack; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,35 +13,17 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasColumn(Playlist::TABLE, Playlist::ATTRIBUTE_FIRST)) { - Schema::table(Playlist::TABLE, function (Blueprint $table) { - $table->unsignedBigInteger(Playlist::ATTRIBUTE_FIRST)->nullable(); - $table->foreign(Playlist::ATTRIBUTE_FIRST)->references(PlaylistTrack::ATTRIBUTE_ID)->on(PlaylistTrack::TABLE)->nullOnDelete(); + if (! Schema::hasColumn('playlists', 'first_id')) { + Schema::table('playlists', function (Blueprint $table) { + $table->unsignedBigInteger('first_id')->nullable(); + $table->foreign('first_id')->references('track_id')->on('playlist_tracks')->nullOnDelete(); }); } - if (! Schema::hasColumn(Playlist::TABLE, Playlist::ATTRIBUTE_LAST)) { - Schema::table(Playlist::TABLE, function (Blueprint $table) { - $table->unsignedBigInteger(Playlist::ATTRIBUTE_LAST)->nullable(); - $table->foreign(Playlist::ATTRIBUTE_LAST)->references(PlaylistTrack::ATTRIBUTE_ID)->on(PlaylistTrack::TABLE)->nullOnDelete(); - }); - } - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - if (Schema::hasColumn(Playlist::TABLE, Playlist::ATTRIBUTE_FIRST)) { - Schema::table(Playlist::TABLE, function (Blueprint $table) { - $table->dropConstrainedForeignId(Playlist::ATTRIBUTE_FIRST); - }); - } - - if (Schema::hasColumn(Playlist::TABLE, Playlist::ATTRIBUTE_LAST)) { - Schema::table(Playlist::TABLE, function (Blueprint $table) { - $table->dropConstrainedForeignId(Playlist::ATTRIBUTE_LAST); + if (! Schema::hasColumn('playlists', 'last_id')) { + Schema::table('playlists', function (Blueprint $table) { + $table->unsignedBigInteger('last_id')->nullable(); + $table->foreign('last_id')->references('track_id')->on('playlist_tracks')->nullOnDelete(); }); } } diff --git a/database/migrations/2022_11_01_000001_create_features_table.php b/database/migrations/2022_11_01_000001_create_features_table.php index 2f9adb9b7..efec75deb 100644 --- a/database/migrations/2022_11_01_000001_create_features_table.php +++ b/database/migrations/2022_11_01_000001_create_features_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Admin\Feature; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,24 +13,16 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Feature::TABLE)) { - Schema::create(Feature::TABLE, function (Blueprint $table) { - $table->id(Feature::ATTRIBUTE_ID); - $table->string(Feature::ATTRIBUTE_NAME); - $table->string(Feature::ATTRIBUTE_SCOPE); - $table->text(Feature::ATTRIBUTE_VALUE); + if (! Schema::hasTable('features')) { + Schema::create('features', function (Blueprint $table) { + $table->id('feature_id'); + $table->string('name'); + $table->string('scope'); + $table->text('value'); $table->timestamps(6); - $table->unique([Feature::ATTRIBUTE_NAME, Feature::ATTRIBUTE_SCOPE]); + $table->unique(['name', 'scope']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Feature::TABLE); - } }; diff --git a/database/migrations/2023_04_24_002635_create_featured_theme_table.php b/database/migrations/2023_04_24_002635_create_featured_theme_table.php index 302019790..917114427 100644 --- a/database/migrations/2023_04_24_002635_create_featured_theme_table.php +++ b/database/migrations/2023_04_24_002635_create_featured_theme_table.php @@ -2,10 +2,6 @@ declare(strict_types=1); -use App\Models\Admin\FeaturedTheme; -use App\Models\Auth\User; -use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; -use App\Models\Wiki\Video; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -17,30 +13,22 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(FeaturedTheme::TABLE)) { - Schema::create(FeaturedTheme::TABLE, function (Blueprint $table) { - $table->id(FeaturedTheme::ATTRIBUTE_ID); + if (! Schema::hasTable('featured_themes')) { + Schema::create('featured_themes', function (Blueprint $table) { + $table->id('featured_theme_id'); $table->timestamps(6); - $table->timestamp(FeaturedTheme::ATTRIBUTE_START_AT, 6)->nullable(); - $table->timestamp(FeaturedTheme::ATTRIBUTE_END_AT, 6)->nullable(); + $table->timestamp('start_at', 6)->nullable(); + $table->timestamp('end_at', 6)->nullable(); - $table->unsignedBigInteger(FeaturedTheme::ATTRIBUTE_USER)->nullable(); - $table->foreign(FeaturedTheme::ATTRIBUTE_USER)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('user_id')->nullable(); + $table->foreign('user_id')->references('id')->on('users')->nullOnDelete(); - $table->unsignedBigInteger(FeaturedTheme::ATTRIBUTE_ENTRY)->nullable(); - $table->foreign(FeaturedTheme::ATTRIBUTE_ENTRY)->references(AnimeThemeEntry::ATTRIBUTE_ID)->on(AnimeThemeEntry::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('entry_id')->nullable(); + $table->foreign('entry_id')->references('entry_id')->on('anime_theme_entries')->nullOnDelete(); - $table->unsignedBigInteger(FeaturedTheme::ATTRIBUTE_VIDEO)->nullable(); - $table->foreign(FeaturedTheme::ATTRIBUTE_VIDEO)->references(Video::ATTRIBUTE_ID)->on(Video::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('video_id')->nullable(); + $table->foreign('video_id')->references('video_id')->on('videos')->nullOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(FeaturedTheme::TABLE); - } }; diff --git a/database/migrations/2023_05_19_210011_create_job_batches_table.php b/database/migrations/2023_05_19_210011_create_job_batches_table.php index 4d95053fd..dba976bfc 100644 --- a/database/migrations/2023_05_19_210011_create_job_batches_table.php +++ b/database/migrations/2023_05_19_210011_create_job_batches_table.php @@ -26,12 +26,4 @@ return new class extends Migration $table->integer('finished_at')->nullable(); }); } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('job_batches'); - } }; diff --git a/database/migrations/2023_06_07_000001_create_pulse_tables.php b/database/migrations/2023_06_07_000001_create_pulse_tables.php index 23f887fc5..8b3374224 100644 --- a/database/migrations/2023_06_07_000001_create_pulse_tables.php +++ b/database/migrations/2023_06_07_000001_create_pulse_tables.php @@ -76,14 +76,4 @@ return new class extends PulseMigration $table->index(['period', 'type', 'aggregate', 'bucket']); // For aggregate queries... }); } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('pulse_values'); - Schema::dropIfExists('pulse_entries'); - Schema::dropIfExists('pulse_aggregates'); - } }; diff --git a/database/migrations/2024_03_10_181149_create_external_profile_table.php b/database/migrations/2024_03_10_181149_create_external_profile_table.php index e0863d8fe..410ad79e9 100644 --- a/database/migrations/2024_03_10_181149_create_external_profile_table.php +++ b/database/migrations/2024_03_10_181149_create_external_profile_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Enums\Models\List\ExternalProfileVisibility; -use App\Models\Auth\User; -use App\Models\List\ExternalProfile; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,28 +13,20 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ExternalProfile::TABLE)) { - Schema::create(ExternalProfile::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('external_profiles')) { + Schema::create('external_profiles', function (Blueprint $table) { $table->timestamps(6); - $table->id(ExternalProfile::ATTRIBUTE_ID); - $table->string(ExternalProfile::ATTRIBUTE_NAME); - $table->integer(ExternalProfile::ATTRIBUTE_SITE); - $table->integer(ExternalProfile::ATTRIBUTE_VISIBILITY)->default(ExternalProfileVisibility::PRIVATE->value); + $table->id('profile_id'); + $table->string('name'); + $table->integer('site'); + $table->integer('visibility')->default(1); - $table->unsignedBigInteger(ExternalProfile::ATTRIBUTE_USER)->nullable(); - $table->foreign(ExternalProfile::ATTRIBUTE_USER)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('user_id')->nullable(); + $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); - $table->timestamp(ExternalProfile::ATTRIBUTE_SYNCED_AT, 6)->nullable(); - $table->integer(ExternalProfile::ATTRIBUTE_EXTERNAL_USER_ID)->nullable(); + $table->timestamp('synced_at', 6)->nullable(); + $table->integer('external_user_id')->nullable(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ExternalProfile::TABLE); - } }; diff --git a/database/migrations/2024_03_10_181158_create_external_entry_table.php b/database/migrations/2024_03_10_181158_create_external_entry_table.php index 1d425d015..f6c621516 100644 --- a/database/migrations/2024_03_10_181158_create_external_entry_table.php +++ b/database/migrations/2024_03_10_181158_create_external_entry_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Models\List\External\ExternalEntry; -use App\Models\List\ExternalProfile; -use App\Models\Wiki\Anime; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,28 +13,20 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ExternalEntry::TABLE)) { - Schema::create(ExternalEntry::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('external_entries')) { + Schema::create('external_entries', function (Blueprint $table) { $table->timestamps(6); - $table->id(ExternalEntry::ATTRIBUTE_ID); - $table->float(ExternalEntry::ATTRIBUTE_SCORE)->nullable(); - $table->integer(ExternalEntry::ATTRIBUTE_WATCH_STATUS); - $table->boolean(ExternalEntry::ATTRIBUTE_IS_FAVORITE)->default(false); + $table->id('entry_id'); + $table->float('score')->nullable(); + $table->integer('watch_status'); + $table->boolean('is_favorite')->default(false); - $table->unsignedBigInteger(ExternalEntry::ATTRIBUTE_ANIME)->nullable(); - $table->foreign(ExternalEntry::ATTRIBUTE_ANIME)->references(Anime::ATTRIBUTE_ID)->on(Anime::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('anime_id')->nullable(); + $table->foreign('anime_id')->references('anime_id')->on('anime')->nullOnDelete(); - $table->unsignedBigInteger(ExternalEntry::ATTRIBUTE_PROFILE); - $table->foreign(ExternalEntry::ATTRIBUTE_PROFILE)->references(ExternalProfile::ATTRIBUTE_ID)->on(ExternalProfile::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('profile_id'); + $table->foreign('profile_id')->references('profile_id')->on('external_profiles')->cascadeOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ExternalEntry::TABLE); - } }; diff --git a/database/migrations/2024_04_11_024316_create_notifications_table.php b/database/migrations/2024_04_11_024316_create_notifications_table.php index 8d9105e04..274b9bef2 100644 --- a/database/migrations/2024_04_11_024316_create_notifications_table.php +++ b/database/migrations/2024_04_11_024316_create_notifications_table.php @@ -24,12 +24,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('notifications'); - } }; diff --git a/database/migrations/2024_04_26_135545_create_groups_table.php b/database/migrations/2024_04_26_135545_create_groups_table.php index be5304090..7e53e1e86 100644 --- a/database/migrations/2024_04_26_135545_create_groups_table.php +++ b/database/migrations/2024_04_26_135545_create_groups_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Constants\ModelConstants; -use App\Models\Wiki\Group; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,22 +13,14 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Group::TABLE)) { - Schema::create(Group::TABLE, function (Blueprint $table) { - $table->id(Group::ATTRIBUTE_ID); + if (! Schema::hasTable('groups')) { + Schema::create('groups', function (Blueprint $table) { + $table->id('group_id'); $table->timestamps(6); - $table->softDeletes(ModelConstants::ATTRIBUTE_DELETED_AT, 6); - $table->string(Group::ATTRIBUTE_NAME); - $table->string(Group::ATTRIBUTE_SLUG); + $table->softDeletes(precision: 6); + $table->string('name'); + $table->string('slug'); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Group::TABLE); - } }; diff --git a/database/migrations/2024_04_26_140035_add_theme_group_attribute_to_anime_theme.php b/database/migrations/2024_04_26_140035_add_theme_group_attribute_to_anime_theme.php index 17d6117c1..5f6b9519e 100644 --- a/database/migrations/2024_04_26_140035_add_theme_group_attribute_to_anime_theme.php +++ b/database/migrations/2024_04_26_140035_add_theme_group_attribute_to_anime_theme.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Anime\AnimeTheme; -use App\Models\Wiki\Group; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,22 +13,10 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasColumn(AnimeTheme::TABLE, AnimeTheme::ATTRIBUTE_GROUP)) { - Schema::table(AnimeTheme::TABLE, function (Blueprint $table) { - $table->unsignedBigInteger(AnimeTheme::ATTRIBUTE_GROUP)->nullable(); - $table->foreign(AnimeTheme::ATTRIBUTE_GROUP)->references(Group::ATTRIBUTE_ID)->on(Group::TABLE)->nullOnDelete(); - }); - } - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - if (Schema::hasColumn(AnimeTheme::TABLE, AnimeTheme::ATTRIBUTE_GROUP)) { - Schema::table(AnimeTheme::TABLE, function (Blueprint $table) { - $table->dropConstrainedForeignId(AnimeTheme::ATTRIBUTE_GROUP); + if (! Schema::hasColumn('anime_themes', 'group_id')) { + Schema::table('anime_themes', function (Blueprint $table) { + $table->unsignedBigInteger('group_id')->nullable(); + $table->foreign('group_id')->references('group_id')->on('groups')->nullOnDelete(); }); } } diff --git a/database/migrations/2024_05_31_052841_create_discord_threads_table.php b/database/migrations/2024_05_31_052841_create_discord_threads_table.php index e5cf068fa..d59ed649a 100644 --- a/database/migrations/2024_05_31_052841_create_discord_threads_table.php +++ b/database/migrations/2024_05_31_052841_create_discord_threads_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Discord\DiscordThread; -use App\Models\Wiki\Anime; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,23 +13,15 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(DiscordThread::TABLE)) { - Schema::create(DiscordThread::TABLE, function (Blueprint $table) { + if (! Schema::hasTable('discord_threads')) { + Schema::create('discord_threads', function (Blueprint $table) { $table->timestamps(6); - $table->string(DiscordThread::ATTRIBUTE_ID)->primary(); - $table->string(DiscordThread::ATTRIBUTE_NAME); + $table->string('thread_id')->primary(); + $table->string('name'); - $table->unsignedBigInteger(DiscordThread::ATTRIBUTE_ANIME); - $table->foreign(DiscordThread::ATTRIBUTE_ANIME)->references(Anime::ATTRIBUTE_ID)->on(Anime::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('anime_id'); + $table->foreign('anime_id')->references('anime_id')->on('anime')->cascadeOnDelete(); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(DiscordThread::TABLE); - } }; diff --git a/database/migrations/2024_06_25_145723_create_action_logs_table.php b/database/migrations/2024_06_25_145723_create_action_logs_table.php index 652ab7609..9d7c10935 100644 --- a/database/migrations/2024_06_25_145723_create_action_logs_table.php +++ b/database/migrations/2024_06_25_145723_create_action_logs_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Admin\ActionLog; -use App\Models\Auth\User; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,35 +13,27 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ActionLog::TABLE)) { - Schema::create(ActionLog::TABLE, function (Blueprint $table) { - $table->bigIncrements(ActionLog::ATTRIBUTE_ID); - $table->string(ActionLog::ATTRIBUTE_BATCH_ID); + if (! Schema::hasTable('action_logs')) { + Schema::create('action_logs', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->string('batch_id'); - $table->unsignedBigInteger(ActionLog::ATTRIBUTE_USER); - $table->foreign(ActionLog::ATTRIBUTE_USER)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('user_id'); + $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); - $table->string(ActionLog::ATTRIBUTE_NAME); - $table->morphs(ActionLog::ATTRIBUTE_ACTIONABLE); - $table->morphs(ActionLog::ATTRIBUTE_TARGET); - $table->string(ActionLog::ATTRIBUTE_MODEL_TYPE); - $table->uuid(ActionLog::ATTRIBUTE_MODEL_ID)->nullable(); - $table->integer(ActionLog::ATTRIBUTE_STATUS)->nullable(); - $table->json(ActionLog::ATTRIBUTE_FIELDS)->nullable(); - $table->text(ActionLog::ATTRIBUTE_EXCEPTION)->nullable(); + $table->string('name'); + $table->morphs('actionable'); + $table->morphs('target'); + $table->string('model_type'); + $table->uuid('model_id')->nullable(); + $table->integer('status')->nullable(); + $table->json('fields')->nullable(); + $table->text('exception')->nullable(); $table->timestamps(6); - $table->timestamp(ActionLog::ATTRIBUTE_FINISHED_AT, 6)->nullable(); + $table->timestamp('finished_at', 6)->nullable(); - $table->index([ActionLog::ATTRIBUTE_BATCH_ID, ActionLog::ATTRIBUTE_MODEL_TYPE, ActionLog::ATTRIBUTE_MODEL_ID]); + $table->index(['batch_id', 'model_type', 'model_id']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ActionLog::TABLE); - } }; diff --git a/database/migrations/2024_08_12_052046_create_filament_exceptions_table.php b/database/migrations/2024_08_12_052046_create_filament_exceptions_table.php index 3cd034e94..63039f820 100644 --- a/database/migrations/2024_08_12_052046_create_filament_exceptions_table.php +++ b/database/migrations/2024_08_12_052046_create_filament_exceptions_table.php @@ -33,12 +33,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('filament_exceptions_table'); - } }; diff --git a/database/migrations/2024_08_26_022027_create_external_tokens_table.php b/database/migrations/2024_08_26_022027_create_external_tokens_table.php index ef2412b0a..a14e61120 100644 --- a/database/migrations/2024_08_26_022027_create_external_tokens_table.php +++ b/database/migrations/2024_08_26_022027_create_external_tokens_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\List\External\ExternalToken; -use App\Models\List\ExternalProfile; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,25 +13,17 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ExternalToken::TABLE)) { - Schema::create(ExternalToken::TABLE, function (Blueprint $table) { - $table->id(ExternalToken::ATTRIBUTE_ID); - $table->longText(ExternalToken::ATTRIBUTE_ACCESS_TOKEN)->nullable(); - $table->longText(ExternalToken::ATTRIBUTE_REFRESH_TOKEN)->nullable(); + if (! Schema::hasTable('external_tokens')) { + Schema::create('external_tokens', function (Blueprint $table) { + $table->id('token_id'); + $table->longText('access_token')->nullable(); + $table->longText('refresh_token')->nullable(); - $table->unsignedBigInteger(ExternalToken::ATTRIBUTE_PROFILE)->nullable()->unique(); - $table->foreign(ExternalToken::ATTRIBUTE_PROFILE)->references(ExternalProfile::ATTRIBUTE_ID)->on(ExternalProfile::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('profile_id')->nullable()->unique(); + $table->foreign('profile_id')->references('profile_id')->on('external_profiles')->cascadeOnDelete(); $table->timestamps(6); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ExternalToken::TABLE); - } }; diff --git a/database/migrations/2024_09_12_045347_create_recently_table.php b/database/migrations/2024_09_12_045347_create_recently_table.php index f289719f1..5eaa8af53 100644 --- a/database/migrations/2024_09_12_045347_create_recently_table.php +++ b/database/migrations/2024_09_12_045347_create_recently_table.php @@ -27,12 +27,4 @@ return new class extends Migration }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('recent_entries'); - } }; diff --git a/database/migrations/2025_01_01_070445_create_view_aggregates_table.php b/database/migrations/2025_01_01_070445_create_view_aggregates_table.php index 88ccc7168..e3a6f6901 100644 --- a/database/migrations/2025_01_01_070445_create_view_aggregates_table.php +++ b/database/migrations/2025_01_01_070445_create_view_aggregates_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Aggregate\ViewAggregate; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,20 +13,12 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(ViewAggregate::TABLE)) { - Schema::create(ViewAggregate::TABLE, function (Blueprint $table) { - $table->morphs(ViewAggregate::ATTRIBUTE_VIEWABLE); - $table->integer(ViewAggregate::ATTRIBUTE_VALUE)->default(0); - $table->primary([ViewAggregate::ATTRIBUTE_VIEWABLE_ID, ViewAggregate::ATTRIBUTE_VIEWABLE_TYPE]); + if (! Schema::hasTable('view_aggregates')) { + Schema::create('view_aggregates', function (Blueprint $table) { + $table->morphs('viewable'); + $table->integer('value')->default(0); + $table->primary(['viewable_id', 'viewable_type']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(ViewAggregate::TABLE); - } }; diff --git a/database/migrations/2025_01_30_132216_create_performances_and_membership_tables.php b/database/migrations/2025_01_30_132216_create_performances_and_membership_tables.php index 8499ebf22..9a987c3e0 100644 --- a/database/migrations/2025_01_30_132216_create_performances_and_membership_tables.php +++ b/database/migrations/2025_01_30_132216_create_performances_and_membership_tables.php @@ -2,10 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Artist; -use App\Models\Wiki\Song; -use App\Models\Wiki\Song\Membership; -use App\Models\Wiki\Song\Performance; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -17,48 +13,39 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Performance::TABLE)) { - Schema::create(Performance::TABLE, function (Blueprint $table) { - $table->id(Performance::ATTRIBUTE_ID); + if (! Schema::hasTable('performances')) { + Schema::create('performances', function (Blueprint $table) { + $table->id('performance_id'); - $table->unsignedBigInteger(Performance::ATTRIBUTE_SONG); - $table->foreign(Performance::ATTRIBUTE_SONG)->references(Song::ATTRIBUTE_ID)->on(Song::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('song_id'); + $table->foreign('song_id')->references('song_id')->on('songs')->cascadeOnDelete(); - $table->morphs(Performance::ATTRIBUTE_ARTIST); + $table->morphs('artist'); - $table->string(Performance::ATTRIBUTE_ALIAS)->nullable(); - $table->string(Performance::ATTRIBUTE_AS)->nullable(); + $table->string('alias')->nullable(); + $table->string('as')->nullable(); $table->timestamps(6); - $table->softDeletes(Performance::ATTRIBUTE_DELETED_AT, 6); + $table->softDeletes('deleted_at', 6); - $table->unique([Performance::ATTRIBUTE_SONG, Performance::ATTRIBUTE_ARTIST_TYPE, Performance::ATTRIBUTE_ARTIST_ID], 'unique_performance'); + $table->unique(['song_id', 'artist_type', 'artist_id'], 'unique_performance'); }); } - if (! Schema::hasTable(Membership::TABLE)) { - Schema::create(Membership::TABLE, function (Blueprint $table) { - $table->id(Membership::ATTRIBUTE_ID); + if (! Schema::hasTable('memberships')) { + Schema::create('memberships', function (Blueprint $table) { + $table->id('membership_id'); - $table->unsignedBigInteger(Membership::ATTRIBUTE_ARTIST); - $table->foreign(Membership::ATTRIBUTE_ARTIST)->references(Artist::ATTRIBUTE_ID)->on(Artist::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('artist_id'); + $table->foreign('artist_id')->references('artist_id')->on('artists')->cascadeOnDelete(); - $table->unsignedBigInteger(Membership::ATTRIBUTE_MEMBER); - $table->foreign(Membership::ATTRIBUTE_MEMBER)->references(Artist::ATTRIBUTE_ID)->on(Artist::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('member_id'); + $table->foreign('member_id')->references('artist_id')->on('artists')->cascadeOnDelete(); - $table->string(Performance::ATTRIBUTE_ALIAS)->nullable(); - $table->string(Performance::ATTRIBUTE_AS)->nullable(); + $table->string('alias')->nullable(); + $table->string('as')->nullable(); $table->timestamps(6); - $table->softDeletes(Performance::ATTRIBUTE_DELETED_AT, 6); + $table->softDeletes('deleted_at', 6); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Performance::TABLE); - Schema::dropIfExists(Membership::TABLE); - } }; diff --git a/database/migrations/2025_05_16_013458_create_likes_table.php b/database/migrations/2025_05_16_013458_create_likes_table.php index 5bfe4827e..e1cee5421 100644 --- a/database/migrations/2025_05_16_013458_create_likes_table.php +++ b/database/migrations/2025_05_16_013458_create_likes_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Auth\User; -use App\Models\User\Like; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,25 +13,17 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Like::TABLE)) { - Schema::create(Like::TABLE, function (Blueprint $table) { - $table->id(Like::ATTRIBUTE_ID); - $table->unsignedBigInteger(Like::ATTRIBUTE_USER)->nullable(); - $table->foreign(Like::ATTRIBUTE_USER)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->cascadeOnDelete(); + if (! Schema::hasTable('likes')) { + Schema::create('likes', function (Blueprint $table) { + $table->id('like_id'); + $table->unsignedBigInteger('user_id')->nullable(); + $table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete(); - $table->morphs(Like::ATTRIBUTE_LIKEABLE); + $table->morphs('likeable'); $table->timestamps(6); - $table->index([Like::ATTRIBUTE_USER, Like::ATTRIBUTE_LIKEABLE_TYPE, Like::ATTRIBUTE_LIKEABLE_ID]); + $table->index(['user_id', 'likeable_type', 'likeable_id']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Like::TABLE); - } }; diff --git a/database/migrations/2025_05_16_100535_create_like_aggregates_table.php b/database/migrations/2025_05_16_100535_create_like_aggregates_table.php index 60867878a..82382bb51 100644 --- a/database/migrations/2025_05_16_100535_create_like_aggregates_table.php +++ b/database/migrations/2025_05_16_100535_create_like_aggregates_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Aggregate\LikeAggregate; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,20 +13,12 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(LikeAggregate::TABLE)) { - Schema::create(LikeAggregate::TABLE, function (Blueprint $table) { - $table->morphs(LikeAggregate::ATTRIBUTE_LIKEABLE); - $table->integer(LikeAggregate::ATTRIBUTE_VALUE)->default(0); - $table->primary([LikeAggregate::ATTRIBUTE_LIKEABLE_ID, LikeAggregate::ATTRIBUTE_LIKEABLE_TYPE]); + if (! Schema::hasTable('like_aggregates')) { + Schema::create('like_aggregates', function (Blueprint $table) { + $table->morphs('likeable'); + $table->integer('value')->default(0); + $table->primary(['likeable_id', 'likeable_type']); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(LikeAggregate::TABLE); - } }; diff --git a/database/migrations/2025_07_13_075607_add_public_attribute_to_announcements_table.php b/database/migrations/2025_07_13_075607_add_public_attribute_to_announcements_table.php index 32e4bed18..54ff18635 100644 --- a/database/migrations/2025_07_13_075607_add_public_attribute_to_announcements_table.php +++ b/database/migrations/2025_07_13_075607_add_public_attribute_to_announcements_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Admin\Announcement; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,21 +13,9 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasColumn(Announcement::TABLE, Announcement::ATTRIBUTE_PUBLIC)) { - Schema::table(Announcement::TABLE, function (Blueprint $table) { - $table->boolean(Announcement::ATTRIBUTE_PUBLIC)->default(false)->after(Announcement::ATTRIBUTE_UPDATED_AT); - }); - } - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - if (Schema::hasColumn(Announcement::TABLE, Announcement::ATTRIBUTE_PUBLIC)) { - Schema::table(Announcement::TABLE, function (Blueprint $table) { - $table->dropColumn(Announcement::ATTRIBUTE_PUBLIC); + if (! Schema::hasColumn('announcements', 'public')) { + Schema::table('announcements', function (Blueprint $table) { + $table->boolean('public')->default(false)->after('updated_at'); }); } } diff --git a/database/migrations/2025_08_15_215051_create_resourceables_table.php b/database/migrations/2025_08_15_215051_create_resourceables_table.php index c6bf718db..468edb1ff 100644 --- a/database/migrations/2025_08_15_215051_create_resourceables_table.php +++ b/database/migrations/2025_08_15_215051_create_resourceables_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\ExternalResource; -use App\Pivots\Morph\Resourceable; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,30 +13,22 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Resourceable::TABLE)) { - Schema::create(Resourceable::TABLE, function (Blueprint $table) { - $table->unsignedBigInteger(Resourceable::ATTRIBUTE_RESOURCE); - $table->foreign(Resourceable::ATTRIBUTE_RESOURCE)->references(ExternalResource::ATTRIBUTE_ID)->on(ExternalResource::TABLE)->cascadeOnDelete(); + if (! Schema::hasTable('resourceables')) { + Schema::create('resourceables', function (Blueprint $table) { + $table->unsignedBigInteger('resource_id'); + $table->foreign('resource_id')->references('resource_id')->on('resources')->cascadeOnDelete(); - $table->morphs(Resourceable::RELATION_RESOURCEABLE); - $table->string(Resourceable::ATTRIBUTE_AS)->nullable(); + $table->morphs('resourceable'); + $table->string('as')->nullable(); $table->timestamps(6); $table->primary([ - Resourceable::ATTRIBUTE_RESOURCE, - Resourceable::ATTRIBUTE_RESOURCEABLE_TYPE, - Resourceable::ATTRIBUTE_RESOURCEABLE_ID, + 'resource_id', + 'resourceable_type', + 'resourceable_id', ]); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Resourceable::TABLE); - } }; diff --git a/database/migrations/2025_08_16_025830_create_imageables_table.php b/database/migrations/2025_08_16_025830_create_imageables_table.php index 441332c4f..0ac64546d 100644 --- a/database/migrations/2025_08_16_025830_create_imageables_table.php +++ b/database/migrations/2025_08_16_025830_create_imageables_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Image; -use App\Pivots\Morph\Imageable; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,30 +13,22 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Imageable::TABLE)) { - Schema::create(Imageable::TABLE, function (Blueprint $table) { - $table->unsignedBigInteger(Imageable::ATTRIBUTE_IMAGE); - $table->foreign(Imageable::ATTRIBUTE_IMAGE)->references(Image::ATTRIBUTE_ID)->on(Image::TABLE)->cascadeOnDelete(); + if (! Schema::hasTable('imageables')) { + Schema::create('imageables', function (Blueprint $table) { + $table->unsignedBigInteger('image_id'); + $table->foreign('image_id')->references('image_id')->on('images')->cascadeOnDelete(); - $table->morphs(Imageable::RELATION_IMAGEABLE); - $table->integer(Imageable::ATTRIBUTE_DEPTH)->nullable(); + $table->morphs('imageable'); + $table->integer('depth')->nullable(); $table->timestamps(6); $table->primary([ - Imageable::ATTRIBUTE_IMAGE, - Imageable::ATTRIBUTE_IMAGEABLE_TYPE, - Imageable::ATTRIBUTE_IMAGEABLE_ID, + 'image_id', + 'imageable_type', + 'imageable_id', ]); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(Imageable::TABLE); - } }; diff --git a/database/migrations/2025_08_24_041058_create_audits_table.php b/database/migrations/2025_08_24_041058_create_audits_table.php index 7e159820f..dce452d9d 100644 --- a/database/migrations/2025_08_24_041058_create_audits_table.php +++ b/database/migrations/2025_08_24_041058_create_audits_table.php @@ -32,15 +32,4 @@ return new class extends Migration $table->index([$morphPrefix.'_id', $morphPrefix.'_type']); }); } - - /** - * Reverse the migrations. - */ - public function down(): void - { - $connection = config('audit.drivers.database.connection', config('database.default')); - $table = config('audit.drivers.database.table', 'audits'); - - Schema::connection($connection)->dropIfExists($table); - } }; diff --git a/database/migrations/2025_10_23_192828_add_native_to_songs_table.php b/database/migrations/2025_10_23_192828_add_native_to_songs_table.php index 08d5fbe55..86cd39423 100644 --- a/database/migrations/2025_10_23_192828_add_native_to_songs_table.php +++ b/database/migrations/2025_10_23_192828_add_native_to_songs_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Song; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,9 +13,9 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasColumn(Song::TABLE, Song::ATTRIBUTE_TITLE_NATIVE)) { - Schema::table(Song::TABLE, function (Blueprint $table) { - $table->string(Song::ATTRIBUTE_TITLE_NATIVE)->nullable()->after(Song::ATTRIBUTE_TITLE); + if (! Schema::hasColumn('songs', 'title_native')) { + Schema::table('songs', function (Blueprint $table) { + $table->string('title_native')->nullable()->after('title'); }); } } diff --git a/database/migrations/2025_10_25_033138_add_relevance_to_performances.php b/database/migrations/2025_10_25_033138_add_relevance_to_performances.php index a321a3f75..edb715a0f 100644 --- a/database/migrations/2025_10_25_033138_add_relevance_to_performances.php +++ b/database/migrations/2025_10_25_033138_add_relevance_to_performances.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Models\Wiki\Song\Performance; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,9 +13,9 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasColumn(Performance::TABLE, Performance::ATTRIBUTE_RELEVANCE)) { - Schema::table(Performance::TABLE, function (Blueprint $table) { - $table->integer(Performance::ATTRIBUTE_RELEVANCE)->nullable()->after(Performance::ATTRIBUTE_AS); + if (! Schema::hasColumn('performances', 'relevance')) { + Schema::table('performances', function (Blueprint $table) { + $table->integer('relevance')->nullable()->after('as'); }); } } diff --git a/database/migrations/2025_10_30_204112_add_relevance_to_artist_members_table.php b/database/migrations/2025_10_30_204112_add_relevance_to_artist_members_table.php index 1084b7e09..04f74e00b 100644 --- a/database/migrations/2025_10_30_204112_add_relevance_to_artist_members_table.php +++ b/database/migrations/2025_10_30_204112_add_relevance_to_artist_members_table.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use App\Pivots\Wiki\ArtistMember; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,9 +13,9 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasColumn(ArtistMember::TABLE, ArtistMember::ATTRIBUTE_RELEVANCE)) { - Schema::table(ArtistMember::TABLE, function (Blueprint $table) { - $table->integer(ArtistMember::ATTRIBUTE_RELEVANCE)->nullable(); + if (! Schema::hasColumn('artist_member', 'relevance')) { + Schema::table('artist_member', function (Blueprint $table) { + $table->integer('relevance')->nullable(); }); } } diff --git a/database/migrations/2025_12_09_141202_create_submissions_table.php b/database/migrations/2025_12_09_141202_create_submissions_table.php index 8afb3c3db..db7a5d85b 100644 --- a/database/migrations/2025_12_09_141202_create_submissions_table.php +++ b/database/migrations/2025_12_09_141202_create_submissions_table.php @@ -2,9 +2,6 @@ declare(strict_types=1); -use App\Models\Auth\User; -use App\Models\User\Submission; -use App\Models\User\Submission\SubmissionStage; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -16,57 +13,48 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(Submission::TABLE)) { - Schema::create(Submission::TABLE, function (Blueprint $table) { - $table->id(Submission::ATTRIBUTE_ID); + if (! Schema::hasTable('submissions')) { + Schema::create('submissions', function (Blueprint $table) { + $table->id('submission_id'); - $table->nullableUuidMorphs(Submission::RELATION_ACTIONABLE); - $table->string(Submission::ATTRIBUTE_TYPE); - $table->longText(Submission::ATTRIBUTE_MODERATOR_NOTES)->nullable(); + $table->nullableUuidMorphs('actionable'); + $table->string('type'); + $table->longText('moderator_notes')->nullable(); - $table->integer(Submission::ATTRIBUTE_STATUS)->nullable(); + $table->integer('status')->nullable(); - $table->unsignedBigInteger(Submission::ATTRIBUTE_USER)->nullable(); - $table->foreign(Submission::ATTRIBUTE_USER)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('user_id')->nullable(); + $table->foreign('user_id')->references('id')->on('users')->nullOnDelete(); - $table->unsignedBigInteger(Submission::ATTRIBUTE_MODERATOR)->nullable(); - $table->foreign(Submission::ATTRIBUTE_MODERATOR)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('moderator_id')->nullable(); + $table->foreign('moderator_id')->references('id')->on('users')->nullOnDelete(); - $table->boolean(Submission::ATTRIBUTE_LOCKED)->default(false); - $table->timestamp(Submission::ATTRIBUTE_FINISHED_AT, 6)->nullable(); + $table->boolean('locked')->default(false); + $table->timestamp('finished_at', 6)->nullable(); $table->timestamps(6); - $table->index(Submission::ATTRIBUTE_STATUS); + $table->index('status'); }); } - if (! Schema::hasTable(SubmissionStage::TABLE)) { - Schema::create(SubmissionStage::TABLE, function (Blueprint $table) { - $table->id(SubmissionStage::ATTRIBUTE_ID); + if (! Schema::hasTable('submission_stages')) { + Schema::create('submission_stages', function (Blueprint $table) { + $table->id('stage_id'); - $table->integer(SubmissionStage::ATTRIBUTE_STAGE); + $table->integer('stage'); - $table->json(SubmissionStage::ATTRIBUTE_FIELDS)->nullable(); - $table->longText(SubmissionStage::ATTRIBUTE_NOTES)->nullable(); - $table->longText(SubmissionStage::ATTRIBUTE_MODERATOR_NOTES)->nullable(); + $table->json('fields')->nullable(); + $table->longText('notes')->nullable(); + $table->longText('moderator_notes')->nullable(); - $table->unsignedBigInteger(SubmissionStage::ATTRIBUTE_SUBMISSION); - $table->foreign(SubmissionStage::ATTRIBUTE_SUBMISSION)->references(Submission::ATTRIBUTE_ID)->on(Submission::TABLE)->cascadeOnDelete(); + $table->unsignedBigInteger('submission_id'); + $table->foreign('submission_id')->references('submission_id')->on('submissions')->cascadeOnDelete(); - $table->unsignedBigInteger(SubmissionStage::ATTRIBUTE_MODERATOR)->nullable(); - $table->foreign(SubmissionStage::ATTRIBUTE_MODERATOR)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('moderator_id')->nullable(); + $table->foreign('moderator_id')->references('id')->on('users')->nullOnDelete(); $table->timestamps(6); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(SubmissionStage::TABLE); - Schema::dropIfExists(Submission::TABLE); - } }; diff --git a/database/migrations/2025_12_11_125011_create_submission_virtuals_table.php b/database/migrations/2025_12_11_125011_create_submission_virtuals_table.php index a9328936e..90b4f7be3 100644 --- a/database/migrations/2025_12_11_125011_create_submission_virtuals_table.php +++ b/database/migrations/2025_12_11_125011_create_submission_virtuals_table.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use App\Models\Auth\User; -use App\Models\User\Submission\SubmissionVirtual; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -15,27 +13,19 @@ return new class extends Migration */ public function up(): void { - if (! Schema::hasTable(SubmissionVirtual::TABLE)) { - Schema::create(SubmissionVirtual::TABLE, function (Blueprint $table) { - $table->id(SubmissionVirtual::ATTRIBUTE_ID); + if (! Schema::hasTable('submission_virtuals')) { + Schema::create('submission_virtuals', function (Blueprint $table) { + $table->id('submission_virtual_id'); - $table->boolean(SubmissionVirtual::ATTRIBUTE_EXISTS)->default(false); - $table->string(SubmissionVirtual::ATTRIBUTE_MODEL_TYPE); - $table->json(SubmissionVirtual::ATTRIBUTE_FIELDS); + $table->boolean('exists')->default(false); + $table->string('model_type'); + $table->json('fields'); - $table->unsignedBigInteger(SubmissionVirtual::ATTRIBUTE_USER)->nullable(); - $table->foreign(SubmissionVirtual::ATTRIBUTE_USER)->references(User::ATTRIBUTE_ID)->on(User::TABLE)->nullOnDelete(); + $table->unsignedBigInteger('user_id')->nullable(); + $table->foreign('user_id')->references('id')->on('users')->nullOnDelete(); $table->timestamps(6); }); } } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists(SubmissionVirtual::TABLE); - } };