solspace / craft-freeform

Freeform for Craft: The most reliable form builder that's ready for wherever your project takes you.
https://docs.solspace.com/craft/freeform/v5/
Other
47 stars 59 forks source link

SQL Error - Form not working #1486

Closed paragonn closed 1 month ago

paragonn commented 2 months ago

What happened?

We recently moved our website database from a standalone Azure Mysql8 DB to their new Azure Mysql8 Flex DB. After we moved to the new database server we are now getting an SQL query error whenever we create a new form in Freeform. It affects the form_submissions_x table that gets created with the form. The error occurs on this query "ALTER TABLE freeform_submissions_2_2_fs_leadgen_1_203 ADD CONSTRAINT PK PRIMARY KEY (id)".

Below is the table description from Mysql: +-----------+-----------------+------+-----+---------+--------------------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-----------------+------+-----+---------+--------------------------+ | my_row_id | bigint unsigned | NO | PRI | NULL | auto_increment INVISIBLE | | id | int | YES | | NULL |. | +-----------+-----------------+------+-----+---------+--------------------------+

Errors and Stack Trace (if available)

./web-2024-08-21.log:2024-08-21 11:22:09 [web.ERROR] [yii\db\Exception] SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined The SQL being executed was: ALTER TABLE `freeform_submissions_2_2_fs_leadgen_1_203` ADD CONSTRAINT `PK` PRIMARY KEY (`id`) {"trace":["#0 /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/db/Command.php(1307): yii\\db\\Schema->convertException()","#1 /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/db/Command.php(1102): yii\\db\\Command->internalExecute()","#2 /var/www/ijmna/ijm.org/htdocs/vendor/solspace/craft-freeform/packages/plugin/src/Form/Managers/ContentManager.php(67): yii\\db\\Command->execute()","#3 /var/www/ijmna/ijm.org/htdocs/vendor/solspace/craft-freeform/packages/plugin/src/Form/Managers/ContentManager.php(37): Solspace\\Freeform\\Form\\Managers\\ContentManager->ensureContentTableCreated()","#4 /var/www/ijmna/ijm.org/htdocs/vendor/solspace/craft-freeform/packages/plugin/src/Services/FormsService.php(290): Solspace\\Freeform\\Form\\Managers\\ContentManager->performDatabaseColumnAlterations()","#5 /var/www/ijmna/ijm.org/htdocs/vendor/solspace/craft-freeform/packages/plugin/src/Controllers/FormsController.php(203): Solspace\\Freeform\\Services\\FormsService->save()","#6 [internal function]: Solspace\\Freeform\\Controllers\\FormsController->actionSave()","#7 /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()","#8 /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams()","#9 /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction()","#10 /var/www/ijmna/ijm.org/htdocs/vendor/craftcms/cms/src/web/Application.php(341): yii\\base\\Module->runAction()","#11 /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/web/Application.php(103): craft\\web\\Application->runAction()","#12 /var/www/ijmna/ijm.org/htdocs/vendor/craftcms/cms/src/web/Application.php(309): yii\\web\\Application->handleRequest()","#13 /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest()","#14 /var/www/ijmna/ijm.org/htdocs/web/index.php(12): yii\\base\\Application->run()","#15 {main}"],"memory":11572200,"exception":"[object] (yii\\db\\Exception(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined\nThe SQL being executed was: ALTER TABLE `freeform_submissions_2_2_fs_leadgen_1_203` ADD CONSTRAINT `PK` PRIMARY KEY (`id`) at /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/db/Schema.php:676)\n[previous exception] [object] (PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined at /var/www/ijmna/ijm.org/htdocs/vendor/yiisoft/yii2/db/Command.php:1302)"}

How can we reproduce this?

Freeform Edition

Pro

Freeform Version

4.1.16

Craft Version

4.8.4

When did this issue start?

After a change to hosting configuration

Previous Freeform Version

No response

paragonn commented 2 months ago

I just tried to upgrade to the latest in the Freeform 4 branch (4.1.21) and the problem is still happening.

kjmartens commented 2 months ago

@paragonn, sorry for the trouble you're experiencing.

I will see if a developer can check into this soon. It's likely an issue specific to your environment and will require some kind of manual adjustment.

paragonn commented 2 months ago

Hi @kjmartens and @seandelaney -- Any news?

paragonn commented 1 month ago

Hi @kjmartens and @seandelaney -- Just checking in here. Any news?

kjmartens commented 1 month ago

Sorry for the delay @paragonn. Due to holidays, I have had to queue this up for @gustavs-gutmanis instead. He'll have a look at it tomorrow (Thursday). 🙂

kjmartens commented 1 month ago

This should now be resolved in Freeform 4.1.22 (and 5.5.10 for those using that version). 🙂

Thank you for your patience, and sorry for the wait.