doublesecretagency / craft-adwizard

Ad Wizard plugin for Craft CMS
Other
7 stars 8 forks source link

Unable to finish initial migration on Craft 4.5.14 #48

Closed cballenar closed 8 months ago

cballenar commented 10 months ago

System Settings:

Required via composer and installed via craft cli just fine but when attempting to do the migration it fails because it's trying to use Fields::assembleLayout which was deprecated in 3.5.

╰─❯ ddev php craft up                                                                                          
Checking for pending Craft and plugin migrations ...
Total 1 new Ad Wizard migration to be applied:
    - m180925_000003_adWizard_createFieldLayout

Apply the above migration? (yes|no) [no]:yes
Create database backup? (yes|no) [no]:no
Skipping database backup.
*** applying m180925_000003_adWizard_createFieldLayout
Exception: Calling unknown method: craft\services\Fields::assembleLayout() (/var/www/html/vendor/yiisoft/yii2/base/Component.php:300)
#0 /var/www/html/vendor/doublesecretagency/craft-adwizard/src/migrations/m180925_000003_adWizard_createFieldLayout.php(70): yii\base\Component->__call('assembleLayout', Array)
#1 /var/www/html/vendor/doublesecretagency/craft-adwizard/src/migrations/m180925_000003_adWizard_createFieldLayout.php(35): doublesecretagency\adwizard\migrations\m180925_000003_adWizard_createFieldLayout->_createFieldLayout()
#2 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(49): doublesecretagency\adwizard\migrations\m180925_000003_adWizard_createFieldLayout->safeUp()
#3 /var/www/html/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#4 /var/www/html/vendor/craftcms/cms/src/console/controllers/MigrateController.php(361): yii\console\controllers\BaseMigrateController->migrateUp('m180925_000003_...')
#5 [internal function]: craft\console\controllers\MigrateController->actionAll()
#6 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#7 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#8 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('all', Array)
#9 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('all', Array)
#10 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\controllers\MigrateController->runAction('all', Array)
#11 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#12 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('migrate/all', Array)
#13 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(212): craft\console\Application->runAction('migrate/all', Array)
#14 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(208): yii\base\Controller->run('migrate/all', Array)
#15 /var/www/html/vendor/craftcms/cms/src/console/controllers/UpController.php(66): craft\console\Controller->run('migrate/all', Array)
#16 [internal function]: craft\console\controllers\UpController->actionIndex()
#17 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#18 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#19 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('', Array)
#20 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('', Array)
#21 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(217): craft\console\Controller->traitRunAction('', Array)
#22 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('', Array)
#23 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('up', Array)
#24 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('up', Array)
#25 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('up', Array)
#26 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#27 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#28 /var/www/html/craft(13): yii\base\Application->run()
#29 {main}
*** failed to apply m180925_000003_adWizard_createFieldLayout (time: 0.040s)

0 from 1 migrations were applied.

Migration failed. The rest of the migrations are canceled.

Restore a database backup before trying again.

Aborting remaining tasks.
Failed to run php craft up: exit status 1
lindseydiloreto commented 10 months ago

Hi @cballenar, which version of Craft are you running?

lindseydiloreto commented 10 months ago

Sorry, just noticed you put the Craft version in the ticket name. 🙃

I'll take a look into it, will let you know what I find.

cballenar commented 10 months ago

I should've included it in the body as well (I just updated it). Thanks @lindseydiloreto !

lindseydiloreto commented 8 months ago

Hi @cballenar, sorry for the late reply.

Were you updating from a very old version of Ad Wizard and/or Craft? If so, what version(s) were you updating from?

If this was a fresh install of Ad Wizard, it shouldn't have tried to run those old migrations. I may end up just removing the entire set of migrations, since they are so old at this point.

lindseydiloreto commented 8 months ago

Digging deeper into this...

It appears this migration was released way back on July 16, 2019, the same day as Craft 3.2.3. Craft has obviously changed a lot since then!

So if you were updating from a Craft 3 website, you probably should have run all of the updates & migrations on the latest version of Craft 3, before making the leap to Craft 4. That would ensure all of the plugins can do the Craft 3 magic they need.

If you somehow got this when freshly installing Ad Wizard into a Craft 4 site, then something else went wrong. The initial Install migration should not have triggered any of the m* numbered migrations.

In any case, I'll be deleting these migration files for Craft 5 compatibility. If they are still giving you trouble, feel free to just delete those migration files from the vendor folder, and run craft up again.

Let me know if I missed anything!

cballenar commented 8 months ago

Thanks for looking into this @lindseydiloreto

This site started on Craft 2 and has received updates somewhat regularly. Now... This was an install (not update) of AdWizard but I have used it before in this site a few years ago... so maybe that's how those migrations got in the way.

I'll continue working on it this weekend but what you described should do the trick. Thanks!

lindseydiloreto commented 8 months ago

@cballenar It sounds like your very-old version of Ad Wizard may not have been completely uninstalled. Perhaps it was disabled and removed?

*Check your database for all of the `adwizard_` tables.** If they contain extremely old data, you may want to uninstall & reinstall the plugin. That should erase the old data, and ensure those tables are properly configured.

cballenar commented 8 months ago

Yup, turns out my system had Ad Wizards tables still in the database as well as a record of it in the plugins table. (Version 0.9.6!)

I was able uninstall it using craft plugin/uninstall ad-wizard --force and then I manually dropped the tables from the database.

After this I was able to install and test the plugin! Thanks for the help!

lindseydiloreto commented 8 months ago

Ok awesome, glad you got it sorted out! 👍