You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to rollback migrations causes a fail because of the missing index: 'original_media_id'
"plank/laravel-mediable": "^6.1",
MYSQL: Server version: 8.0.39 MySQL Community Server - GPL
All that was done was install the package, publish the config, make a new media model that implements the media and expands on it.
After getting some error after trying to publish the migrations and making changes i got this error.
Trying to fix it by removing my changes to the published migrations.
Presented the same problem with the same failure on attempt to rollback the migration.
$ php artisan migrate:rollback --step=3
INFO Rolling back migrations.
2024_03_30_000000_add_alt_to_media .............................................Server version: 8.0.39 MySQL Community Server - GPL
........................................................ 47ms DONE
2020_10_12_000000_add_variants_to_media ................................................................................................. 2ms FAIL
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'original_media_id'; check that column/key exists (Connection: mysql, SQL: alter table `media` drop foreign key `original_media_id`)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:822
818▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
819▕ );
820▕ }
821▕
➜ 822▕ throw new QueryException(
823▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
824▕ );
825▕ }
826▕ }
+35 vendor frames
36 artisan:35
Illuminate\Foundation\Console\Kernel::handle()
Proposed solution to 2020_10_12_000000_add_variants_to_media:
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('media_original_media_id_foreign'); // The actual foreign key index.
$table->dropColumn('original_media_id');
}
Or is this just an issue specific to me due to mysql version or other environment factors on my end?
The text was updated successfully, but these errors were encountered:
Or more intuitively, making the dropForeign use an array instead: if (DB::getDriverName() !== 'sqlite') { $table->dropForeign(['original_media_id']); $table->dropColumn('original_media_id'); }
Because without it; it doesn't create the index name before trying to drop it.
Attempting to rollback migrations causes a fail because of the missing index: 'original_media_id'
"plank/laravel-mediable": "^6.1",
MYSQL: Server version: 8.0.39 MySQL Community Server - GPL
All that was done was install the package, publish the config, make a new media model that implements the media and expands on it.
After getting some error after trying to publish the migrations and making changes i got this error.
Trying to fix it by removing my changes to the published migrations.
Presented the same problem with the same failure on attempt to rollback the migration.
steps to reporduce:
-install
-migrate
-rollback
Proposed solution to 2020_10_12_000000_add_variants_to_media:
Or is this just an issue specific to me due to mysql version or other environment factors on my end?
The text was updated successfully, but these errors were encountered: