Skip to content
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

Migration Error - "Integrity constraint violation" #124

Closed
tigerchick opened this issue Dec 8, 2024 · 10 comments
Closed

Migration Error - "Integrity constraint violation" #124

tigerchick opened this issue Dec 8, 2024 · 10 comments
Labels
Bug Report Something isn't working

Comments

@tigerchick
Copy link

tigerchick commented Dec 8, 2024

When upgrading to 4.6.0 from 4.5.2 I get a migration error which causes the update to fail and for the site to go down:

Integrity constraint violation: SQLSTATE[23000]: Integrity constraint violation....

The only way to clear this is to revert that database and the composer.json / composer.lock files.

Sorry, I didn't take a full record of the error.. I did note however that the issue above occurred very many times in the stated error (presumably for each sql record that was migrated (or not!)

This on Craft 4.13.5

@lindseydiloreto
Copy link
Collaborator

lindseydiloreto commented Dec 8, 2024

Thanks for reporting! You are now the second person to report this issue, but the first person didn't have a pre-migration database backup.

I might have a solution for this, will post back here shortly.

@lindseydiloreto lindseydiloreto added the Bug Report Something isn't working label Dec 8, 2024
@lindseydiloreto
Copy link
Collaborator

I just pushed a patch which (hopefully) resolves this issue.

When you get a chance, please grab the latest dev release and try again...

"doublesecretagency/craft-googlemaps": "dev-v4-dev"

Please let me know if that does the trick for you! 🤞

@lindseydiloreto lindseydiloreto changed the title Migration Error on updating from 4.5.2 to 4.6.0 Migration Error - "Integrity constraint violation" Dec 9, 2024
@tigerchick
Copy link
Author

tigerchick commented Dec 11, 2024

Sorry for the delay. I just tried this but it failed again - with a different error this time:

One of Google Maps’s migrations failed.

Database Exception: SQLSTATE[HY000]: General error: 1832 Cannot change column 'siteId': used in a foreign key constraint 'fk_ajypmcpbnbdzmtunrmumevunblpjpljaerbl'
The SQL being executed was: ALTER TABLE googlemaps_addresses CHANGE siteId siteId int(11) NOT NULL

I'll email you the full output.

Edit: This "new" error actually seems to be the same error that was reported in the thread #125

@lindseydiloreto
Copy link
Collaborator

Yeah, looks like you're now hitting that other error. I suspect that both bugs were in there all along, and fixing yours just made the other one more visible.

It almost sounds like something didn't get rolled back properly. I'll probably need a full database export to get it resolved.

Will ping you via email to discuss further. 👍

@lindseydiloreto
Copy link
Collaborator

Actually, I may have just been able to fix it blind. Grab the latest dev release and give it another shot...

"doublesecretagency/craft-googlemaps": "dev-v4-dev"

Make sure you've rolled back the database before trying the migration again.

Let me know how it goes! 🤞

@tigerchick
Copy link
Author

Actually, I may have just been able to fix it blind. Grab the latest dev release and give it another shot...

"doublesecretagency/craft-googlemaps": "dev-v4-dev"

Make sure you've rolled back the database before trying the migration again.

Let me know how it goes! 🤞

Before I run this, can I confirm that is the correct dev version - v4 is the same number as before. (Deliberate, I'm sure, just want to double check!)

@lindseydiloreto
Copy link
Collaborator

Yes, that is correct. v4-dev is the branch where these changes are, and the dev- prefix allows you to get changes which haven't been tagged yet (like this one).

@tigerchick
Copy link
Author

I can confirm that this now works correctly. Successful migration! Well done.

@lindseydiloreto
Copy link
Collaborator

Brilliant, thanks for confirming! 🍺

@lindseydiloreto
Copy link
Collaborator

Great news, this patch has been officially released in v4.6.1. 🎉

If you've experienced a failed migration, be sure to roll the database back before trying again.

Hope that helps, thanks again for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants