mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
fix: no need to pre-calculate playlist song order
This commit is contained in:
parent
9f414be1f3
commit
a84dba5e50
1 changed files with 0 additions and 14 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
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
|
||||
|
@ -12,18 +11,5 @@ return new class extends Migration
|
|||
Schema::table('playlist_song', static function (Blueprint $table): void {
|
||||
$table->unsignedInteger('position')->index()->default(0);
|
||||
});
|
||||
|
||||
DB::table('playlists')->orderBy('id')->chunk(100, static function ($playlists): void {
|
||||
foreach ($playlists as $playlist) {
|
||||
DB::table('playlist_song')
|
||||
->where('playlist_id', $playlist->id)
|
||||
->update([
|
||||
'position' => DB::raw("(SELECT COUNT(id)
|
||||
FROM playlist_song p
|
||||
WHERE p.playlist_id = '$playlist->id'
|
||||
AND p.id <= playlist_song.id)"),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue