This commit is contained in:
2025-09-18 15:31:27 +02:00
commit 2abba0c2b7
406 changed files with 31879 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('username');
$table->string('discriminator');
$table->string('email')->nullable()->unique();
$table->string('avatar')->nullable();
$table->boolean('verified');
$table->string('locale');
$table->boolean('mfa_enabled');
$table->string('refresh_token')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('contact', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email');
$table->string('subject');
$table->text('message');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('contact');
}
};

View File

@@ -0,0 +1,20 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('is_admin')->default(0);
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->json('roles')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('roles');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->rememberToken()->after('refresh_token');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropRememberToken();
});
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('discord_access_tokens', function (Blueprint $table) {
$table->id();
$table->string('access_token');
$table->string('refresh_token');
$table->string('token_type');
$table->integer('expires_in');
$table->timestamp('expires_at');
$table->string('scope');
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('discord_access_tokens');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('refresh_token');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('refresh_token')->nullable();
});
}
};

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('global_name')->nullable()->after('username');
$table->string('discriminator')->nullable()->change();
$table->string('banner')->nullable()->after('verified');
$table->string('banner_color')->nullable()->after('banner');
$table->string('accent_color')->nullable()->after('banner_color');
$table->string('premium_type')->nullable()->after('mfa_enabled');
$table->string('public_flags')->nullable()->after('premium_type');
$table->boolean('verified')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('global_name');
$table->string('discriminator')->change();
$table->dropColumn('banner');
$table->dropColumn('banner_color');
$table->dropColumn('accent_color');
$table->dropColumn('premium_type');
$table->dropColumn('public_flags');
$table->boolean('verified')->change();
});
}
};

View File

@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('markable_likes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete();
$table->morphs('markable');
$table->string('value')->nullable();
$table->json('metadata')->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('markable_likes');
}
};

View File

@@ -0,0 +1,78 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('hentai', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('title_jpn');
$table->string('slug');
$table->tinyInteger('episodes');
$table->text('description');
$table->tinyText('duration');
$table->tinyText('status');
$table->float('score');
$table->string('cover_url');
$table->integer('studios_id');
$table->date('upload_date');
$table->date('release_date');
$table->timestamps();
});
Schema::create('episode', function (Blueprint $table) {
$table->id();
$table->integer('hentai_id');
$table->integer('episode');
$table->string('url');
$table->string('cover_url');
$table->tinyText('resolution');
$table->bigInteger('view_count')->unsigned()->default(0)->index();
$table->string('download_url')->nullable();
$table->boolean('legacy_stream')->default(1);
$table->timestamps();
});
Schema::create('studios', function (Blueprint $table) {
$table->id();
$table->tinyText('name');
$table->tinyText('slug');
$table->timestamps();
});
Schema::create('gallery', function (Blueprint $table) {
$table->id();
$table->integer('hentai_id');
$table->integer('episode_id');
$table->string('image_url');
$table->string('thumbnail_url');
$table->timestamps();
});
Schema::create('popular_weekly', function (Blueprint $table) {
$table->id();
$table->integer('episode_id');
$table->timestamps();
});
Schema::create('popular_monthly', function (Blueprint $table) {
$table->id();
$table->integer('episode_id');
$table->timestamps();
});
Schema::create('popular_daily', function (Blueprint $table) {
$table->id();
$table->integer('episode_id');
$table->timestamps();
});
}
};

View File

@@ -0,0 +1,73 @@
<?php
use App\Models\Episode;
use App\Models\Hentai;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Change Tagging from Hentai to Episode
$hentai = DB::table('hentai')->get();
foreach($hentai as $h) {
$episodes = Episode::where('hentai_id', $h->id)->get();
foreach($episodes as $episode) {
$episode->tag($h->tagNames());
}
}
// Delete Hentai Tags
foreach($hentai as $h) {
$h->untag();
}
Schema::table('episode', function (Blueprint $table) {
$table->string('title')->after('id');
$table->string('title_jpn')->after('title');
$table->string('slug')->after('title_jpn');
$table->integer('studios_id')->after('hentai_id');
$table->date('release_date')->nullable()->after('legacy_stream');
});
$episodes = DB::table('episode')->get();
foreach($episodes as $episode) {
$hentai = Hentai::where('id', $episode->hentai_id)->first();
$episode->title = $hentai->title;
$episode->title_jpn = $hentai->title_jpn;
$episode->slug = $hentai->slug.'-'.$episode->episode;
$episode->studios_id = $hentai->studios_id;
$episode->release_date = Carbon::parse(strval($hentai->release_date).' 01:01:01');
$alreadyexists = Episode::where('slug', $episode->slug)->first();
if ($alreadyexists) {
throw new \RuntimeException('Migration stopped! Slug already exists: '.$episode->slug);
}
$episode->save();
}
// Remove
Schema::table('hentai', function (Blueprint $table) {
$table->dropColumn('title');
$table->dropColumn('title_jpn');
$table->dropColumn('episodes');
$table->dropColumn('duration');
$table->dropColumn('status');
$table->dropColumn('score');
$table->dropColumn('cover_url');
$table->dropColumn('studios_id');
$table->dropColumn('upload_date');
$table->dropColumn('release_date');
});
}
};

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// 0 = Cover
// 1 = Thumbnail
Schema::table('users', function (Blueprint $table) {
$table->boolean('search_design')->default(1);
$table->boolean('home_top_design')->default(0);
$table->boolean('home_middle_design')->default(1);
});
}
};

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('playlists', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->index();
$table->string('name');
$table->boolean('is_private')->default(1);
$table->timestamps();
});
Schema::create('playlist_episodes', function (Blueprint $table) {
$table->id();
$table->integer('position')->nullable();
$table->integer('playlist_id')->index();
$table->integer('episode_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('playlists');
Schema::dropIfExists('playlist_episodes');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('alerts', function (Blueprint $table) {
$table->id();
$table->integer('type');
$table->text('text');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('alerts');
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('is_patreon')->default(0);
});
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episode', function (Blueprint $table) {
$table->string('download_url_4k')->after('download_url')->nullable();
});
}
};

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$episodes = DB::table('episode')->whereNull('download_url_4k')
->where('legacy_stream', 0)
->where('resolution', '4k')
->get();
foreach($episodes as $episode) {
$episode->download_url_4k = Str::replace('1080p', '2160p', $episode->download_url);
$episode->save();
}
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('watched', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->index()->constrained()->cascadeOnDelete();
$table->integer('episode_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('watched');
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->json('tag_blacklist')->nullable();
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episode', function (Blueprint $table) {
$table->boolean('interpolated')->default(0)->after('legacy_stream');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('episode', function (Blueprint $table) {
$table->dropColumn('interpolated');
});
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('gallery', function (Blueprint $table) {
$table->index('hentai_id');
$table->index('episode_id');
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::table('gallery', function (Blueprint $table)
{
$table->dropIndex(['episode_id', 'hentai_id']);
});
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('torrents', function (Blueprint $table) {
$table->id();
$table->integer('hentai_id');
$table->string('torrent_url');
$table->string('episodes');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('torrents');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('subtitles', function (Blueprint $table) {
$table->id();
$table->tinyText('name');
$table->tinyText('slug');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('subtitles');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('episode_subtitles', function (Blueprint $table) {
$table->id();
$table->foreignId('episode_id')->index();
$table->foreignId('subtitle_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('episode_subtitles');
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episode', function (Blueprint $table) {
$table->text('description')->after('episode');
});
DB::statement('UPDATE `episode` INNER JOIN `hentai` ON `episode`.`hentai_id` = `hentai`.`id` SET `episode`.`description` = `hentai`.`description`');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('episode', function (Blueprint $table) {
$table->dropColumn('description');
});
}
};

View File

@@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::rename('contact', 'contacts');
Schema::rename('episode', 'episodes');
Schema::rename('hentai', 'hentais');
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->string('download_url_interpolated')->after('download_url')->nullable();
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('is_banned')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('is_banned');
});
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->dropColumn('legacy_stream');
});
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->dropColumn('resolution');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->boolean('is_dvd_aspect')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->dropColumn('is_dvd_aspect');
});
}
};

View File

@@ -0,0 +1,70 @@
<?php
use App\Models\Downloads;
use App\Models\Episode;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('downloads', function (Blueprint $table) {
$table->id();
$table->foreignId('episode_id')->index()->constrained()->cascadeOnDelete();
$table->char('type', 5);
$table->string('url');
$table->double('size')->nullable();
$table->timestamps();
});
// Migrate old entries
foreach(Episode::all() as $episode) {
// 1080p
if (! empty($episode->download_url)) {
Downloads::create([
'episode_id' => $episode->id,
'type' => 'FHD',
'url' => $episode->download_url
]);
}
// 1080p48
if (! empty($episode->download_url_interpolated)) {
Downloads::create([
'episode_id' => $episode->id,
'type' => 'FHDi',
'url' => $episode->download_url_interpolated
]);
}
// 2160p
if (! empty($episode->download_url_4k)) {
Downloads::create([
'episode_id' => $episode->id,
'type' => 'UHD',
'url' => $episode->download_url_4k
]);
}
}
// Drop old entries
Schema::table('episodes', function (Blueprint $table) {
$table->dropColumn('download_url_interpolated');
$table->dropColumn('download_url_4k');
$table->dropColumn('download_url');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('downloads');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('downloads', function (Blueprint $table) {
$table->bigInteger('count')->after('size')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('downloads', function (Blueprint $table) {
$table->dropColumn('count');
});
}
};

View File

@@ -0,0 +1,33 @@
<?php
use App\Models\Episode;
use App\Models\Hentai;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
foreach (Hentai::all() as $hentai) {
$slugParts = explode('-', $hentai->slug);
$lastPart = $slugParts[array_key_last($slugParts)];
if (is_numeric($lastPart) && $lastPart < 1000) {
$slugParts[array_key_last($slugParts)] = 's'.$lastPart;
$newSlug = implode('-', $slugParts);
// Update hentai slug
$hentai->slug = $newSlug;
$hentai->save();
// Update episodes related to this hentai in bulk
Episode::where('hentai_id', $hentai->id)
->update(['slug' => DB::raw("CONCAT('$newSlug-', episode)")]);
}
}
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('downloads_left')->default(5);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('downloads_left');
});
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->string('title_search')->after('title');
});
// Update the title_search field with sanitized titles
DB::table('episodes')->update([
'title_search' => DB::raw("REGEXP_REPLACE(title, '[^A-Za-z0-9 ]', '')")
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->dropColumn('title_search');
});
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_downloads', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->index();
$table->foreignId('episode_id')->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_downloads');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('site_backgrounds', function (Blueprint $table) {
$table->id();
$table->date('date_start');
$table->date('date_end');
$table->boolean('default')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('site_backgrounds');
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->boolean('interpolated_qhd')->default(0)->after('interpolated');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->dropColumn('interpolated_qhd');
});
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->boolean('interpolated_uhd')->default(0)->after('interpolated');
// Drop old qhd column
$table->dropColumn('interpolated_qhd');
});
Schema::table('user_downloads', function (Blueprint $table) {
$table->boolean('interpolated')->default(0)->after('episode_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('episodes', function (Blueprint $table) {
$table->dropColumn('interpolated_uhd');
});
}
};

View File

@@ -0,0 +1,49 @@
<?php
use App\Models\Playlist;
use App\Models\PlaylistEpisode;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Remove duplicates
$duplicates = DB::table('playlist_episodes')
->select('playlist_id', 'episode_id', DB::raw('MIN(id) as keep_id'))
->groupBy('playlist_id', 'episode_id')
->havingRaw('COUNT(*) > 1')
->get();
foreach ($duplicates as $dup) {
DB::table('playlist_episodes')
->where('playlist_id', $dup->playlist_id)
->where('episode_id', $dup->episode_id)
->where('id', '!=', $dup->keep_id)
->delete();
}
// Fix index
$playlistIds = Playlist::all()->pluck('id');
foreach ($playlistIds as $playlistId) {
$episodes = PlaylistEpisode::where('playlist_id', $playlistId)
->get();
foreach ($episodes as $index => $episode) {
$episode->position = $index + 1;
$episode->save();
}
}
// Make entries unique
Schema::table('playlist_episodes', function (Blueprint $table) {
$table->unique(['playlist_id', 'episode_id']);
});
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('discord_access_tokens', function (Blueprint $table) {
$table->string('access_token', 300)->change();
$table->string('refresh_token', 300)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('discord_access_tokens', function (Blueprint $table) {
$table->string('access_token')->change(); // back to default (255)
$table->string('refresh_token')->change(); // back to default (255)
});
}
};