-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations may fail to run in mysql if sql_require_primary_key is enabled #44411
Comments
See #33238 and the discussion with the reason why this is not considered a Laravel bug. There is also a workaround on this comment: #33238 (comment) |
Hi @rodrigopedra - that's a helpful start, thanks! Since the problematic migration is part of Nova, I can't realistically apply that workaround in the migration itself since it's a vendor file. It's probably not appropriate to edit Any thoughts? |
you can try creating a migration, on your project, with an earlier date, much like the users migration has 000000 in its timestamp, to disable and then a migration with a date greater than the most recent nova migration to reenable |
@Firehed yesterday I was on the go, and didn't think of events. You can also listen for the Check for the |
Thanks @rodrigopedra |
Description:
When trying to run a DB migration structured like this:
If the DB is a mysql server with
sql_require_primary_key
enabled, the migration fails with the following message:From what I can tell, this appears to run
CREATE TABLE (`id` char(36) not null, ...) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
and thenALTER TABLE ... ADD PRIMARY KEY (`id`)
Ideally, the two would be combined into a single statement, as
$table->id()
does. I'm not sure if there are other options (such as temporarily disabling that mode)Steps To Reproduce:
The easiest repro step is to do a clean install of Laravel Nova and try to run
artisan migrate
when configured to a MySQL server with that setting enabled (this is, apparently, the default on DigitalOcean managed DBs) - I ran into this when one of the built-in Nova migrations was running. However I believe this is not a Nova issue, but one where any UUID PK is configured with the above structure.Otherwise, a migration as above should be sufficient.
The text was updated successfully, but these errors were encountered: