Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 fails due to already existing table 'freeform_forms_groups' #1754

Closed
JazzMusic131 opened this issue Jan 27, 2025 · 4 comments
Closed
Assignees

Comments

@JazzMusic131
Copy link

What happened?

I am trying to upgrade Freeform Pro on a Craft 4 site, from 5.5.4 to 5.9.2. When performing the migrations, I get an error stating that the table freeform_forms_groups already exists.

Is version 5.9.2 compatible with Craft 4? I am currently running Craft version 4.14.1. PHP version: 8.2

Errors and Stack Trace (if available)

Database Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'freeform_forms_groups' already exists
The SQL being executed was: CREATE TABLE freeform_forms_groups (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
siteId int(11) NOT NULL,
label varchar(255),
order int(11) NOT NULL,
dateCreated datetime(0),
dateUpdated datetime(0),
uid char(36) NOT NULL DEFAULT '0'
) ENGINE = InnoDb DEFAULT CHARACTER SET = utf8

Migration: Solspace\Freeform\migrations\m240903_145017_CreateFormGroupsTable

Output:

> create table {{%freeform_forms_groups}} ...Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'freeform_forms_groups' already exists
The SQL being executed was: CREATE TABLE freeform_forms_groups (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
siteId int(11) NOT NULL,
label varchar(255),
order int(11) NOT NULL,
dateCreated datetime(0),
dateUpdated datetime(0),
uid char(36) NOT NULL DEFAULT '0'
) ENGINE = InnoDb DEFAULT CHARACTER SET = utf8 (/var/www/html/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1325): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE f...')
#1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1120): yii\db\Command->internalExecute('CREATE TABLE f...')
#2 /var/www/html/vendor/yiisoft/yii2/db/Migration.php(334): yii\db\Command->execute()
#3 /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/migrations/m240903_145017_CreateFormGroupsTable.php(15): yii\db\Migration->createTable('{{%freeform_for...', Array)
#4 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(50): Solspace\Freeform\migrations\m240903_145017_CreateFormGroupsTable->safeUp()
#5 /var/www/html/vendor/craftcms/cms/src/db/MigrationManager.php(233): craft\db\Migration->up(true)
#6 /var/www/html/vendor/craftcms/cms/src/db/MigrationManager.php(149): craft\db\MigrationManager->migrateUp(Object(Solspace\Freeform\migrations\m240903_145017_CreateFormGroupsTable))
#7 /var/www/html/vendor/craftcms/cms/src/services/Updates.php(252): craft\db\MigrationManager->up()
#8 /var/www/html/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(493): craft\services\Updates->runMigrations(Array)
#9 /var/www/html/vendor/craftcms/cms/src/controllers/UpdaterController.php(209): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#10 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#11 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('migrate', Array)
#14 /var/www/html/vendor/craftcms/cms/src/web/Application.php(348): yii\base\Module->runAction('updater/migrate', Array)
#15 /var/www/html/vendor/craftcms/cms/src/web/Application.php(740): craft\web\Application->runAction('updater/migrate')
#16 /var/www/html/vendor/craftcms/cms/src/web/Application.php(273): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#17 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /var/www/html/public/index.php(12): yii\base\Application->run()
#19 {main}

How can we reproduce this?

  1. Set up Craft installation using version 4.14.1
  2. Install Freeform Pro version 5.5.4
  3. Upgrade Freeform Pro to version 5.9.2 using composer update
  4. Run the database migration(s)

Freeform Edition

Pro

Freeform Version

5.9.2

Craft Version

4.14.1

When did this issue start?

After upgrading from older Freeform version

Previous Freeform Version

5.5.4

@JazzMusic131 JazzMusic131 added the issue Something isn't working correctly label Jan 27, 2025
@kjmartens kjmartens self-assigned this Jan 27, 2025
@kjmartens
Copy link
Contributor

Sorry for the trouble @JazzMusic131,

Freeform 5.9.2 is compatible with both Craft 4 and 5. 🙂

Is there any chance that the migration failed once before this in your attempt to update? When an error says that a database table already exists, it usually means that the migration ran once before.

At any rate, I'm curious if any of the options below are possible:

  1. Revert the site database (not just the vendor packages) back to the original version of Freeform (5.5.4?). Try running the upgrade again and see what migration error you get. It could be that another one failed initially.
  2. Is it possible to send us an email at [email protected] with a copy of your database?
  3. If that isn't possible, could you still send an email to us and we can provide some instructions to attempt to manually repair the issues in the database table(s)? 🙂

@JazzMusic131
Copy link
Author

JazzMusic131 commented Jan 27, 2025

@kjmartens This happened to me once before, but with another table freeform_submissions_newsletter_signup_2, which was I believe one of my form tables, but I'm unsure as to why that occurred and I shelved the upgrade. At the time, I was attempting to upgrade Freeform Pro from 5.5.4 to 5.6.7.

I reverted and tried running the update again; I got the same migration error but this time for the freeform_forms_translations table. Here is the stack trace:

Database Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'freeform_forms_translations' already exists
The SQL being executed was: CREATE TABLE freeform_forms_translations (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
formId int(11) NOT NULL,
siteId int(11) NOT NULL,
translations longtext NOT NULL,
dateCreated datetime(0) NOT NULL,
dateUpdated datetime(0) NOT NULL,
uid char(36) NOT NULL DEFAULT '0'
) ENGINE = InnoDb DEFAULT CHARACTER SET = utf8

Migration: Solspace\Freeform\migrations\m240819_104209_AddTranslationTable

Output:

> create table {{%freeform_forms_translations}} ...Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'freeform_forms_translations' already exists
The SQL being executed was: CREATE TABLE freeform_forms_translations (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
formId int(11) NOT NULL,
siteId int(11) NOT NULL,
translations longtext NOT NULL,
dateCreated datetime(0) NOT NULL,
dateUpdated datetime(0) NOT NULL,
uid char(36) NOT NULL DEFAULT '0'
) ENGINE = InnoDb DEFAULT CHARACTER SET = utf8 (/var/www/html/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1325): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE f...')
#1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1120): yii\db\Command->internalExecute('CREATE TABLE f...')
#2 /var/www/html/vendor/yiisoft/yii2/db/Migration.php(334): yii\db\Command->execute()
#3 /var/www/html/vendor/solspace/craft-freeform/packages/plugin/src/migrations/m240819_104209_AddTranslationTable.php(11): yii\db\Migration->createTable('{{%freeform_for...', Array)
#4 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(50): Solspace\Freeform\migrations\m240819_104209_AddTranslationTable->safeUp()
#5 /var/www/html/vendor/craftcms/cms/src/db/MigrationManager.php(233): craft\db\Migration->up(true)
#6 /var/www/html/vendor/craftcms/cms/src/db/MigrationManager.php(149): craft\db\MigrationManager->migrateUp(Object(Solspace\Freeform\migrations\m240819_104209_AddTranslationTable))
#7 /var/www/html/vendor/craftcms/cms/src/services/Updates.php(252): craft\db\MigrationManager->up()
#8 /var/www/html/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(493): craft\services\Updates->runMigrations(Array)
#9 /var/www/html/vendor/craftcms/cms/src/controllers/UpdaterController.php(209): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#10 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#11 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('migrate', Array)
#14 /var/www/html/vendor/craftcms/cms/src/web/Application.php(348): yii\base\Module->runAction('updater/migrate', Array)
#15 /var/www/html/vendor/craftcms/cms/src/web/Application.php(740): craft\web\Application->runAction('updater/migrate')
#16 /var/www/html/vendor/craftcms/cms/src/web/Application.php(273): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#17 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /var/www/html/public/index.php(12): yii\base\Application->run()
#19 {main}

This is a client site, so I feel uncomfortable with sharing the database externally due to possible NDA issues, so I will send an email to support and go the manual repair instructions route.

@kjmartens
Copy link
Contributor

Yes, please create a support ticket and we can discuss this further. 🙂

@JazzMusic131
Copy link
Author

@kjmartens Just sent an email to [email protected]. Thanks!

@kjmartens kjmartens added investigating Currently investigating the report and removed issue Something isn't working correctly investigating Currently investigating the report labels Jan 30, 2025
@solspace solspace locked and limited conversation to collaborators Feb 4, 2025
@kjmartens kjmartens converted this issue into discussion #1780 Feb 4, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Development

No branches or pull requests

2 participants