mirror of
https://github.com/koel/koel
synced 2024-11-24 13:13:05 +00:00
fix: key constraint prevents migration (closes #1725)
This commit is contained in:
parent
033c234928
commit
b12b6e03b4
1 changed files with 12 additions and 10 deletions
|
@ -11,27 +11,27 @@ return new class extends Migration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
Schema::disableForeignKeyConstraints();
|
||||||
|
|
||||||
|
if (DB::getDriverName() !== 'sqlite') {
|
||||||
|
collect(['playlist_song', 'interactions'])->each(static function (string $table): void {
|
||||||
|
Schema::table($table, static function (Blueprint $table): void {
|
||||||
|
$table->dropForeign(['song_id']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Schema::table('songs', static function (Blueprint $table): void {
|
Schema::table('songs', static function (Blueprint $table): void {
|
||||||
$table->string('id', 36)->change();
|
$table->string('id', 36)->change();
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::table('playlist_song', static function (Blueprint $table): void {
|
Schema::table('playlist_song', static function (Blueprint $table): void {
|
||||||
$table->string('song_id', 36)->change();
|
$table->string('song_id', 36)->change();
|
||||||
|
|
||||||
if (DB::getDriverName() !== 'sqlite') {
|
|
||||||
$table->dropForeign('playlist_song_song_id_foreign');
|
|
||||||
}
|
|
||||||
|
|
||||||
$table->foreign('song_id')->references('id')->on('songs')->cascadeOnDelete()->cascadeOnUpdate();
|
$table->foreign('song_id')->references('id')->on('songs')->cascadeOnDelete()->cascadeOnUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::table('interactions', static function (Blueprint $table): void {
|
Schema::table('interactions', static function (Blueprint $table): void {
|
||||||
$table->string('song_id', 36)->change();
|
$table->string('song_id', 36)->change();
|
||||||
|
|
||||||
if (DB::getDriverName() !== 'sqlite') {
|
|
||||||
$table->dropForeign('interactions_song_id_foreign');
|
|
||||||
}
|
|
||||||
|
|
||||||
$table->foreign('song_id')->references('id')->on('songs')->cascadeOnDelete()->cascadeOnUpdate();
|
$table->foreign('song_id')->references('id')->on('songs')->cascadeOnDelete()->cascadeOnUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,5 +39,7 @@ return new class extends Migration
|
||||||
$song->id = Str::uuid();
|
$song->id = Str::uuid();
|
||||||
$song->save();
|
$song->save();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::enableForeignKeyConstraints();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue