refactor: remove down methods and constants in migrations (#1027)

This commit is contained in:
Kyrch
2025-12-19 20:02:17 -03:00
committed by GitHub
parent c91de1acf9
commit 869677e49f
60 changed files with 387 additions and 991 deletions
@@ -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);
}
};
@@ -21,12 +21,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};
@@ -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);
}
};
@@ -25,12 +25,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};
@@ -26,12 +26,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -24,12 +24,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sessions');
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -25,12 +25,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
}
};
@@ -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']);
}
};
@@ -29,13 +29,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -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);
}
};
@@ -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();
});
}
}
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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();
});
}
}
@@ -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);
}
};
@@ -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);
}
};
@@ -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');
}
};
@@ -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');
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -24,12 +24,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};
@@ -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);
}
};
@@ -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();
});
}
}
@@ -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);
}
};
@@ -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);
}
};
@@ -33,12 +33,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('filament_exceptions_table');
}
};
@@ -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);
}
};
@@ -27,12 +27,4 @@ return new class extends Migration
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('recent_entries');
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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');
});
}
}
@@ -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);
}
};
@@ -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);
}
};
@@ -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);
}
};
@@ -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');
});
}
}
@@ -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');
});
}
}
@@ -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();
});
}
}
@@ -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);
}
};
@@ -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);
}
};