From 0710daca965936f80170929fc89d26c53d066235 Mon Sep 17 00:00:00 2001 From: Phan An Date: Tue, 12 Mar 2024 11:48:57 +0700 Subject: [PATCH] fix: playlist UUID migration --- .env.example | 3 +-- .../Commands/Storage/SetupLocalStorageCommand.php | 2 +- .../2024_01_16_215642_use_uuids_for_playlists.php | 11 +++-------- .../profile-preferences/PreferencesForm.vue | 4 ++-- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index 20ebecb4..35df6f28 100644 --- a/.env.example +++ b/.env.example @@ -146,8 +146,7 @@ OUTPUT_BIT_RATE=128 # environment, such a download will (silently) fail. ALLOW_DOWNLOAD=true -# Whether to create a backup of a song instead of deleting it from the filesystem. -# If true, the song will simply be renamed into a .bak file. +# Whether to create a backup of a song when deleting it from the filesystem. BACKUP_ON_DELETE=true # Sync logs can be found under storage/logs/. Valid options are: diff --git a/app/Console/Commands/Storage/SetupLocalStorageCommand.php b/app/Console/Commands/Storage/SetupLocalStorageCommand.php index 2bed367b..5ce615e0 100644 --- a/app/Console/Commands/Storage/SetupLocalStorageCommand.php +++ b/app/Console/Commands/Storage/SetupLocalStorageCommand.php @@ -11,7 +11,7 @@ use Jackiedo\DotenvEditor\DotenvEditor; class SetupLocalStorageCommand extends Command { 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) { diff --git a/database/migrations/2024_01_16_215642_use_uuids_for_playlists.php b/database/migrations/2024_01_16_215642_use_uuids_for_playlists.php index 8a992d6a..0eb1f73e 100644 --- a/database/migrations/2024_01_16_215642_use_uuids_for_playlists.php +++ b/database/migrations/2024_01_16_215642_use_uuids_for_playlists.php @@ -1,6 +1,5 @@ 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; $newId = Str::uuid()->toString(); - $playlist->id = $newId; - $playlist->save(); - - DB::table('playlist_song')->where('playlist_id', $oldId)->update([ - 'playlist_id' => $newId, - ]); + DB::table('playlists')->where('id', $oldId)->update(['id' => $newId]); + DB::table('playlist_song')->where('playlist_id', $oldId)->update(['playlist_id' => $newId]); }); Schema::enableForeignKeyConstraints(); diff --git a/resources/assets/js/components/profile-preferences/PreferencesForm.vue b/resources/assets/js/components/profile-preferences/PreferencesForm.vue index f16084ed..a569634c 100644 --- a/resources/assets/js/components/profile-preferences/PreferencesForm.vue +++ b/resources/assets/js/components/profile-preferences/PreferencesForm.vue @@ -1,6 +1,6 @@