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 61 forks source link

Upgrade to Craft 4.x failing on Freeform update #972

Closed watershed closed 9 months ago

watershed commented 10 months ago

I have a 3.9.10 Craft instance with Freeform Pro 3.13.33, running on PHP 8.1.26 and MariaDB 10.6.16, which I'm trying to upgrade to 4.x.

The instance has lots of Freeform forms.

I'm following the steps at https://craftcms.com/docs/4.x/upgrade.html#performing-the-upgrade.

Each time I do so I'm starting with a completely empty database which I'm restoring to a Craft 3.9.10 content state.

Every time I invoke php craft migrate/all the point of failure relates to applying m220330_111857_SplitSubmissionsTable with respect to a Freeform form submissions table.

For example, here's an anonymised error dump:

create table {{%freeform_submissions_form_1_7_8_6_60}} ...Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'craft_freeform_submissions_form_1_7_8_6_60' already exists
The SQL being executed was: CREATE TABLE `craft_freeform_submissions_form_1_7_8_6_60` (
        `id` int(11) NOT NULL,
        `first_name_1` text,
        `last_name_2` text,
        `country_23` text,
        `email_3` text,
        `specialty_29` text,
        `company_name_7` text,
        `optin_39` text,
        `dropdown3_40` text
) ENGINE = InnoDb DEFAULT CHARACTER SET = utf8 (/path/to/account/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /path/to/account/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException()
#1 /path/to/account/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute()
#2 /path/to/account/vendor/yiisoft/yii2/db/Migration.php(322): yii\db\Command->execute()
#3 /path/to/account/vendor/solspace/craft-freeform/packages/plugin/src/migrations/m220330_111857_SplitSubmissionsTable.php(118): yii\db\Migration->createTable()
#4 /path/to/account/vendor/solspace/craft-freeform/packages/plugin/src/migrations/m220330_111857_SplitSubmissionsTable.php(85): Solspace\Freeform\migrations\m220330_111857_SplitSubmissionsTable->createFormTable()
#5 /path/to/account/vendor/craftcms/cms/src/db/Migration.php(49): Solspace\Freeform\migrations\m220330_111857_SplitSubmissionsTable->safeUp()
#6 /path/to/account/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#7 /path/to/account/vendor/craftcms/cms/src/console/controllers/MigrateController.php(361): yii\console\controllers\BaseMigrateController->migrateUp()
#8 [internal function]: craft\console\controllers\MigrateController->actionAll()
#9 /path/to/account/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#10 /path/to/account/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#11 /path/to/account/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#12 /path/to/account/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction()
#13 /path/to/account/vendor/yiisoft/yii2/base/Module.php(552): craft\console\controllers\MigrateController->runAction()
#14 /path/to/account/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#15 /path/to/account/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#16 /path/to/account/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#17 /path/to/account/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest()
#18 /path/to/account/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()
#19 /path/to/account/craft(23): yii\base\Application->run()
#20 {main}
*** failed to apply m220330_111857_SplitSubmissionsTable (time: 0.003s)

IF I delete all the forms in the CMS at Freeform > Forms, and drop all the corresponding tables from the database, and then run the upgrade process, it works!

Is there a way to go about this without having to sacrifice all the forms and rebuild them?

gustavs-gutmanis commented 10 months ago

Hi @watershed

It is very strange that you already have the split tables, which was a feature introduced in Freeform 4.x.

Since you have the change already, you could try removing the m220330_111857_SplitSubmissionsTable migration from the migrations folder inside Freeform migrations folder in vendor/solspace/craft-freeform/packages/plugin/src/migrations/ and run the migration again.

Let me know if that works.

watershed commented 10 months ago

Thanks for the prompt reply. Makes me wonder if there's something in my vendor codebase for 3.9.10 that isn't quite as chronologically correct as I think it is.

I'll look into it and try your suggestion. Thanks.