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

Error during migration when updating to Formie 4.13.8: "Integrity constraint violation - Duplicate entry" #2238

Closed
romainpoirier opened this issue Jan 15, 2025 · 4 comments

Comments

@romainpoirier
Copy link

romainpoirier commented Jan 15, 2025

Describe the bug

After updating my Craft CMS site to Formie 2.1.38, I ran the standard post-deployment maintenance tasks:

./craft migrate/all  
./craft project-config/apply  

During this process, I encountered the following error related to applying Formie modifications:

Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'plugin:formie-m231223_000000_notification_handle' for key 'craft_idx_xzhetbuluufsshfxgmgifdemyudzkwxmteuh'  
The SQL being executed was: INSERT INTO `craft_migrations` (`track`, `name`, `applyTime`, `dateCreated`, `dateUpdated`, `uid`) VALUES ('plugin:formie', 'm231223_000000_notification_handle', '2025-01-15 08:42:31', '2025-01-15 08:42:31', '2025-01-15 08:42:31', '083f9e06-1d04-4259-9e2c-8c8fe20c0cf8')  

The error seems to occur during the migration m231223_000000_notification_handle, specifically on duplicate entries. My site contains many complex multi-tab forms, and testing every form across all scenarios would be a time-intensive task.

The migration should complete without errors, applying all necessary updates to the Formie plugin seamlessly.

Could you please provide insights into what caused this error and how to resolve it effectively without having to test every form manually?

Steps to reproduce

  1. Update Craft CMS to Formie 4.13.8.
  2. Execute ./craft migrate/all and ./craft project-config/apply.
  3. Observe the error during the migration process.

Form settings

  • Multi-page form: Yes
  • Submission Method: Page Reload
  • Client-side Validation: Yes
  • Custom Form Templates: No

Craft CMS version

4.13.10

Plugin version

2.1.38

Multi-site?

Yes

Additional context

No response

@engram-design
Copy link
Member

That error seems to point to the fact that the migration has already been run on that environment, but it's trying to run it again. I know you mention Formie 4.13.8, but this seems to be Craft 4.13.8, correct?

That shouldn't happen under normal circumstances. You could potentially remove that row from the migrations database table, but I've not seen this sort if issue before...

@romainpoirier
Copy link
Author

Thank you and apologies for the confusion earlier. The updates involve:

  • "craftcms/cms": "4.13.10"
  • "verbb/formie": "2.1.38"

Just to clarify, based on your explanation, can this message be safely ignored? Would you confirm that neither a rollback nor further investigation is necessary in this case?

@engram-design
Copy link
Member

It's a pretty safe migration to re-run, as it creates email notification handles, which previously didn't exist, which was my recommendation to remove that row in the migrations table (and the migration would run again). I'm not quite sure why or how it's gotten to that state though.

@romainpoirier
Copy link
Author

After deleting the row in the database and re-running the migration, everything proceeded smoothly:

./craft migrate/all
Checking for pending migrations ...
Total 1 new Formie migration to be applied:
    - m231223_000000_notification_handle

Apply the above migration? (yes|no) [no]: yes
Create database backup? (yes|no) [yes]: yes
Backing up the database ... done
*** applying m231223_000000_notification_handle
    > update in {{%formie_notifications}} ... done (time: 0.001s)
    > update in {{%formie_notifications}} ... done (time: 0.000s)
    ...
*** applied m231223_000000_notification_handle (time: 0.070s)

1 migration was applied.

Migrated up successfully.

Thank you for the clarification—it was very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants