mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
fix: playlist folder migration
This commit is contained in:
parent
9d9dbf6fd5
commit
140f06427c
1 changed files with 6 additions and 1 deletions
|
@ -31,6 +31,11 @@ return new class extends Migration
|
|||
});
|
||||
|
||||
DB::table('playlists')->whereNotNull('folder_id')->get()->each(static function ($playlist): void {
|
||||
// There might be some data inconsistency, so we need to check if the folder exists first.
|
||||
if (DB::table('playlist_folders')->find($playlist->folder_id) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::table('playlist_playlist_folder')->insert([
|
||||
'folder_id' => $playlist->folder_id,
|
||||
'playlist_id' => $playlist->id,
|
||||
|
@ -39,7 +44,7 @@ return new class extends Migration
|
|||
|
||||
Schema::table('playlists', static function (Blueprint $table): void {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->dropForeign('playlists_folder_id_foreign');
|
||||
$table->dropForeign(['folder_id']);
|
||||
}
|
||||
|
||||
$table->dropColumn('folder_id');
|
||||
|
|
Loading…
Reference in a new issue