fix: playlist UUID migration

This commit is contained in:
Phan An 2024-03-12 11:48:57 +07:00
parent 7a4a6e4d98
commit 0710daca96
4 changed files with 7 additions and 13 deletions

View file

@ -146,8 +146,7 @@ OUTPUT_BIT_RATE=128
# environment, such a download will (silently) fail. # environment, such a download will (silently) fail.
ALLOW_DOWNLOAD=true ALLOW_DOWNLOAD=true
# Whether to create a backup of a song instead of deleting it from the filesystem. # Whether to create a backup of a song when deleting it from the filesystem.
# If true, the song will simply be renamed into a .bak file.
BACKUP_ON_DELETE=true BACKUP_ON_DELETE=true
# Sync logs can be found under storage/logs/. Valid options are: # Sync logs can be found under storage/logs/. Valid options are:

View file

@ -11,7 +11,7 @@ use Jackiedo\DotenvEditor\DotenvEditor;
class SetupLocalStorageCommand extends Command class SetupLocalStorageCommand extends Command
{ {
protected $signature = 'koel:storage:local'; protected $signature = 'koel:storage:local';
protected $description = 'Set up local storage for Koel'; protected $description = 'Set up the local storage for Koel';
public function __construct(private DotenvEditor $dotenvEditor) public function __construct(private DotenvEditor $dotenvEditor)
{ {

View file

@ -1,6 +1,5 @@
<?php <?php
use App\Models\Playlist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -27,16 +26,12 @@ return new class extends Migration {
$table->foreign('playlist_id')->references('id')->on('playlists')->cascadeOnDelete()->cascadeOnUpdate(); $table->foreign('playlist_id')->references('id')->on('playlists')->cascadeOnDelete()->cascadeOnUpdate();
}); });
Playlist::all()->each(static function (Playlist $playlist): void { DB::table('playlists')->get()->each(static function (object $playlist): void {
$oldId = $playlist->id; $oldId = $playlist->id;
$newId = Str::uuid()->toString(); $newId = Str::uuid()->toString();
$playlist->id = $newId; DB::table('playlists')->where('id', $oldId)->update(['id' => $newId]);
$playlist->save(); DB::table('playlist_song')->where('playlist_id', $oldId)->update(['playlist_id' => $newId]);
DB::table('playlist_song')->where('playlist_id', $oldId)->update([
'playlist_id' => $newId,
]);
}); });
Schema::enableForeignKeyConstraints(); Schema::enableForeignKeyConstraints();

View file

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<div class="form-row" v-if="isPlus"> <div v-if="isPlus" class="form-row">
<label> <label>
<CheckBox v-model="preferences.make_uploads_public" name="make_upload_public" /> <CheckBox v-model="preferences.make_uploads_public" name="make_upload_public" />
Make uploaded songs public by default Make uploaded songs public by default
@ -9,7 +9,7 @@
<div v-if="isPhone" class="form-row"> <div v-if="isPhone" class="form-row">
<label> <label>
<CheckBox v-model="preferences.show_now_playing_notification" name="notify" /> <CheckBox v-model="preferences.show_now_playing_notification" name="notify" />
Show Now Playing song notification Show Now Playing notification
</label> </label>
</div> </div>
<div v-if="!isPhone" class="form-row"> <div v-if="!isPhone" class="form-row">