[GH-ISSUE #2046] [Bug]: Cannot drop id during 7.11.0 update #1078

Closed
opened 2026-02-26 02:35:10 +03:00 by kerem · 3 comments
Owner

Originally created by @Doppelkeks12 on GitHub (Aug 11, 2025).
Original GitHub issue: https://github.com/koel/koel/issues/2046

Originally assigned to: @phanan on GitHub.

Read the Troubleshooting guide.

  • I have read and followed the Troubleshooting guide

Reproduction steps

  1. Have a koel version v7.10.2 ready
  2. Run rm -rf app config public/build/assets/* database/
  3. Run wget -qO- https://github.com/koel/koel/releases/download/v7.11.0/koel-v7.11.0.tar.gz | tar -xvzC . --strip-components=1
  4. Run php artisan cache:clear
  5. Run artisan koel:init --no-assets

Expected behavior

Update should run without any errors

Actual behavior

An error is thrown with the log below during the database migration

Logs

Laravel Log:

Next Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1829 Cannot drop column 'id': needed in a foreign key constraint 'songs_contributing_artist_id_foreign' of table 'songs' (Connection: mysql, SQL: alter table artistsdropid) in [...]vendor/laravel/framework/src/Illuminate/Database/Connection.php:825 Stack trace: #0 [...]vendor/laravel/framework/src/Illuminate/Database/Connection.php(779): Illuminate\Database\Connection->runQueryCallback('alter table ar...', Array, Object(Closure)) #1 [...]vendor/laravel/framework/src/Illuminate/Database/Connection.php(560): Illuminate\Database\Connection->run('alter table ar...', Array, Object(Closure)) #2 [...]vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php(118): Illuminate\Database\Connection->statement('alter table ar...') #3 [...]vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(564): Illuminate\Database\Schema\Blueprint->build(Object(Illuminate\Database\MySqlConnection), Object(Illuminate\Database\Schema\Grammars\MySqlGrammar)) #4 [...]vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(406): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint)) #5 [...]vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(361): Illuminate\Database\Schema\Builder->table('artists', Object(Closure)) #6 [...]database/migrations/2025_07_20_165510_promote_public_ids.php(79): Illuminate\Support\Facades\Facade::__callStatic('table', Array) `

Koel version

v7.10.2 Plus Edition to v7.11.0 Plus Edition

How did you install Koel?

Pre-compiled tar/zip archive

Additional information

I'm using mysql

Originally created by @Doppelkeks12 on GitHub (Aug 11, 2025). Original GitHub issue: https://github.com/koel/koel/issues/2046 Originally assigned to: @phanan on GitHub. ### Read the Troubleshooting guide. - [x] I have read and followed the Troubleshooting guide ### Reproduction steps 1. Have a koel version v7.10.2 ready 2. Run `rm -rf app config public/build/assets/* database/` 3. Run `wget -qO- https://github.com/koel/koel/releases/download/v7.11.0/koel-v7.11.0.tar.gz | tar -xvzC . --strip-components=1` 4. Run `php artisan cache:clear` 5. Run `artisan koel:init --no-assets` ### Expected behavior Update should run without any errors ### Actual behavior An error is thrown with the log below during the database migration ### Logs Laravel Log: `Next Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1829 Cannot drop column 'id': needed in a foreign key constraint 'songs_contributing_artist_id_foreign' of table 'songs' (Connection: mysql, SQL: alter table `artists` drop `id`) in [...]vendor/laravel/framework/src/Illuminate/Database/Connection.php:825 Stack trace: #0 [...]vendor/laravel/framework/src/Illuminate/Database/Connection.php(779): Illuminate\Database\Connection->runQueryCallback('alter table `ar...', Array, Object(Closure)) #1 [...]vendor/laravel/framework/src/Illuminate/Database/Connection.php(560): Illuminate\Database\Connection->run('alter table `ar...', Array, Object(Closure)) #2 [...]vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php(118): Illuminate\Database\Connection->statement('alter table `ar...') #3 [...]vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(564): Illuminate\Database\Schema\Blueprint->build(Object(Illuminate\Database\MySqlConnection), Object(Illuminate\Database\Schema\Grammars\MySqlGrammar)) #4 [...]vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(406): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint)) #5 [...]vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(361): Illuminate\Database\Schema\Builder->table('artists', Object(Closure)) #6 [...]database/migrations/2025_07_20_165510_promote_public_ids.php(79): Illuminate\Support\Facades\Facade::__callStatic('table', Array) ` ### Koel version v7.10.2 Plus Edition to v7.11.0 Plus Edition ### How did you install Koel? Pre-compiled tar/zip archive ### Additional information I'm using mysql
kerem closed this issue 2026-02-26 02:35:10 +03:00
Author
Owner

@phanan commented on GitHub (Aug 11, 2025):

Hmm, contributing_artist_id (and with it, the relationship) should have been removed sometime ago.

Schema::withoutForeignKeyConstraints(static function () use ($table): void {
    $table->dropForeign(['contributing_artist_id']);
    $table->dropColumn('contributing_artist_id');
});

Can you try restoring the DB backup and deleting both the column and the relationship manually before attempting the migration again?

<!-- gh-comment-id:3175050833 --> @phanan commented on GitHub (Aug 11, 2025): Hmm, `contributing_artist_id` (and with it, the relationship) should have been removed [sometime ago](https://github.com/koel/koel/commit/7a8573c6818df49cefa1ac8e7fd9ae331f110e8c#diff-03bd7b61d58e5b56012b1840c36ae4f5d0a3ae078623b911c851e8e5c32a603aR14-R17). ```php Schema::withoutForeignKeyConstraints(static function () use ($table): void { $table->dropForeign(['contributing_artist_id']); $table->dropColumn('contributing_artist_id'); }); ``` Can you try restoring the DB backup and deleting both the column and the relationship manually before attempting the migration again?
Author
Owner

@Doppelkeks12 commented on GitHub (Aug 11, 2025):

@phanan Yes, thanks. It works by removing both manually. I think I can keep those manual changes without breaking future migrations? I don't know how I got those column. My database isn't older than one year.

<!-- gh-comment-id:3175271807 --> @Doppelkeks12 commented on GitHub (Aug 11, 2025): @phanan Yes, thanks. It works by removing both manually. I think I can keep those manual changes without breaking future migrations? I don't know how I got those column. My database isn't older than one year.
Author
Owner

@phanan commented on GitHub (Aug 11, 2025):

@Doppelkeks12 Glad it works for you! Yeah, the manual changes can be kept. Migrations are only run once, so the problematic migration won't be executed again.

I don't know how I got those column. My database isn't older than one year.

It's certainly not your fault. Since Koel tries to support several different databases (MySQL/MariaDB, Postgres, and SQLite), making the same migrations work for all of them proves to be very complex, and sometimes hiccups like this happen.

<!-- gh-comment-id:3175335406 --> @phanan commented on GitHub (Aug 11, 2025): @Doppelkeks12 Glad it works for you! Yeah, the manual changes can be kept. Migrations are only run once, so the problematic migration won't be executed again. > I don't know how I got those column. My database isn't older than one year. It's certainly not your fault. Since Koel tries to support several different databases (MySQL/MariaDB, Postgres, and SQLite), making the same migrations work for all of them proves to be very complex, and sometimes hiccups like this happen.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#1078
No description provided.