This commit is contained in:
2026-04-18 14:18:52 +02:00
parent 5b4d3d435e
commit f3e5100d5d
126 changed files with 743 additions and 795 deletions

View File

@@ -32,4 +32,4 @@ return new class extends Migration
{
Schema::dropIfExists('users');
}
};
};

View File

@@ -5,8 +5,8 @@ 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;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
@@ -17,16 +17,16 @@ return new class extends Migration
{
// Change Tagging from Hentai to Episode
$hentai = DB::table('hentai')->get();
foreach($hentai as $h) {
foreach ($hentai as $h) {
$episodes = Episode::where('hentai_id', $h->id)->get();
foreach($episodes as $episode) {
foreach ($episodes as $episode) {
$episode->tag($h->tagNames());
}
}
}
// Delete Hentai Tags
foreach($hentai as $h) {
foreach ($hentai as $h) {
$h->untag();
}
@@ -39,7 +39,7 @@ return new class extends Migration
});
$episodes = DB::table('episode')->get();
foreach($episodes as $episode) {
foreach ($episodes as $episode) {
$hentai = Hentai::where('id', $episode->hentai_id)->first();
$episode->title = $hentai->title;

View File

@@ -12,11 +12,11 @@ return new class extends Migration
public function up(): void
{
$episodes = DB::table('episode')->whereNull('download_url_4k')
->where('legacy_stream', 0)
->where('resolution', '4k')
->get();
->where('legacy_stream', 0)
->where('resolution', '4k')
->get();
foreach($episodes as $episode) {
foreach ($episodes as $episode) {
$episode->download_url_4k = Str::replace('1080p', '2160p', $episode->download_url);
$episode->save();
}

View File

@@ -22,8 +22,7 @@ return new class extends Migration
*/
public function down()
{
Schema::table('gallery', function (Blueprint $table)
{
Schema::table('gallery', function (Blueprint $table) {
$table->dropIndex(['episode_id', 'hentai_id']);
});
}

View File

@@ -2,8 +2,8 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{

View File

@@ -23,13 +23,13 @@ return new class extends Migration
});
// Migrate old entries
foreach(Episode::all() as $episode) {
foreach (Episode::all() as $episode) {
// 1080p
if (! empty($episode->download_url)) {
Downloads::create([
'episode_id' => $episode->id,
'type' => 'FHD',
'url' => $episode->download_url
'type' => 'FHD',
'url' => $episode->download_url,
]);
}
@@ -37,8 +37,8 @@ return new class extends Migration
if (! empty($episode->download_url_interpolated)) {
Downloads::create([
'episode_id' => $episode->id,
'type' => 'FHDi',
'url' => $episode->download_url_interpolated
'type' => 'FHDi',
'url' => $episode->download_url_interpolated,
]);
}
@@ -46,8 +46,8 @@ return new class extends Migration
if (! empty($episode->download_url_4k)) {
Downloads::create([
'episode_id' => $episode->id,
'type' => 'UHD',
'url' => $episode->download_url_4k
'type' => 'UHD',
'url' => $episode->download_url_4k,
]);
}
}

View File

@@ -2,7 +2,6 @@
use App\Models\Episode;
use App\Models\Hentai;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
@@ -13,10 +12,10 @@ return new class extends Migration
*/
public function up(): void
{
foreach (Hentai::all() as $hentai) {
foreach (Hentai::all() as $hentai) {
$slugParts = explode('-', $hentai->slug);
$lastPart = $slugParts[array_key_last($slugParts)];
if (is_numeric($lastPart) && $lastPart < 1000) {
if (is_numeric($lastPart) && $lastPart < 1000) {
$slugParts[array_key_last($slugParts)] = 's'.$lastPart;
$newSlug = implode('-', $slugParts);

View File

@@ -18,7 +18,7 @@ return new class extends Migration
// Update the title_search field with sanitized titles
DB::table('episodes')->update([
'title_search' => DB::raw("REGEXP_REPLACE(title, '[^A-Za-z0-9 ]', '')")
'title_search' => DB::raw("REGEXP_REPLACE(title, '[^A-Za-z0-9 ]', '')"),
]);
}

View File

@@ -2,8 +2,8 @@
use App\Models\Playlist;
use App\Models\PlaylistEpisode;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

View File

@@ -1,11 +1,10 @@
<?php
use App\Models\Downloads;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
@@ -14,10 +13,10 @@ return new class extends Migration
*/
public function up(): void
{
# Delete entries with "#" as URL
// Delete entries with "#" as URL
Downloads::where('url', '#')->delete();
# Remove duplicate entries
// Remove duplicate entries
$duplicates = DB::table('downloads')
->select('episode_id', 'type', DB::raw('COUNT(*) as count'))
->groupBy('episode_id', 'type')

View File

@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration

View File

@@ -46,7 +46,6 @@ return new class extends Migration
$table->rememberToken()->after('password');
});
/**
* --------------------------------------------------------------------
* Fix Discord Profile Pictures
@@ -54,8 +53,7 @@ return new class extends Migration
* The oauth package by socialite now returns a full url of the avatar.
* Meaning all the old entries have to be fixed.
*/
foreach (User::whereNotNull('discord_avatar')->get() as $user)
{
foreach (User::whereNotNull('discord_avatar')->get() as $user) {
$isGif = preg_match('/a_.+/m', $user->discord_avatar) === 1;
$extension = $isGif ? 'gif' : 'webp';
$user->discord_avatar = sprintf('https://cdn.discordapp.com/avatars/%s/%s.%s', $user->id, $user->discord_avatar, $extension);

View File

@@ -3,8 +3,8 @@
use App\Models\Playlist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
@@ -136,7 +136,7 @@ return new class extends Migration
}
/**
* Due to incorrect handling of user deletes,
* Due to incorrect handling of user deletes,
* we have unreferenced data
*/
private function deleteUnreferencedData(): void
@@ -150,7 +150,7 @@ return new class extends Migration
$playlists = Playlist::where('user_id', '>', 1_000_000)
->get();
foreach($playlists as $playlist) {
foreach ($playlists as $playlist) {
DB::table('playlist_episodes')
->where('playlist_id', '=', $playlist->id)
->delete();

View File

@@ -69,7 +69,7 @@ return new class extends Migration
// Re-Add foreign key constraint and index
Schema::table('comments', function (Blueprint $table) {
$table->foreign('child_id')->references('id')->on('comments')->onDelete('cascade');
$table->index(["commenter_id", "commenter_type"]);
$table->index(['commenter_id', 'commenter_type']);
});
}
};

View File

@@ -13,8 +13,8 @@ return new class extends Migration
{
Schema::table('users', function (Blueprint $table) {
$table->string('locale', 10)
->nullable()
->after('discord_avatar');
->nullable()
->after('discord_avatar');
});
}

View File

@@ -14,17 +14,17 @@ return new class extends Migration
{
// Migrate supporters
DB::table('users')->where('is_patreon', 1)->update([
'roles' => DB::raw("JSON_ARRAY('supporter')")
'roles' => DB::raw("JSON_ARRAY('supporter')"),
]);
// Migrate banned
DB::table('users')->where('is_banned', 1)->update([
'roles' => DB::raw("JSON_ARRAY('banned')")
'roles' => DB::raw("JSON_ARRAY('banned')"),
]);
// Migrate admins
DB::table('users')->where('is_admin', 1)->update([
'roles' => DB::raw("JSON_ARRAY('admin')")
'roles' => DB::raw("JSON_ARRAY('admin')"),
]);
// Drop columns

View File

@@ -13,8 +13,8 @@ return new class extends Migration
{
Schema::table('users', function (Blueprint $table) {
$table->string('matrix_id')
->nullable()
->after('discord_id');
->nullable()
->after('discord_id');
});
}