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

LinkField throws error when running craft\migrations\Install #250

Open
TomDeSmet opened this issue Jan 9, 2023 · 3 comments
Open

LinkField throws error when running craft\migrations\Install #250

TomDeSmet opened this issue Jan 9, 2023 · 3 comments

Comments

@TomDeSmet
Copy link

TomDeSmet commented Jan 9, 2023

What I'm trying to do:
I have some custom project configs that I want Craft to use by default when installing Craft. So these configs are in my project folder of my boilerplate. These configs use Typed Link Field extensively.

What is happening:
If I run craft/setup with my project configs in place, it errors every time it comes across a Typed Link Field. I tested it by removing some of those fields and than it just continuous until it reaches another Typed Link Field.

Possible leads:
The YAML files show columnSuffix: null for the Link field whereas the migration targets prbospbe as sufix of the field.
Enabling/disabling the new cache option doesn't resolve it, but it seems from the code it may have something to do with it nonetheless.

Logs:

> applying existing project config ... Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'content.field_cta_showInBottomMenu_prbospbe' in 'field list'
The SQL being executed was: SELECT `elements`.`id`, `elements`.`canonicalId`, `elements`.`fieldLayoutId`, `elements`.`uid`, `elements`.`enabled`, `elements`.`archived`, `elements`.`dateLastMerged`, `elements`.`dateCreated`, `elements`.`dateUpdated`, `elements_sites`.`id` AS `siteSettingsId`, `elements_sites`.`slug`, `elements_sites`.`siteId`, `elements_sites`.`uri`, `elements_sites`.`enabled` AS `enabledForSite`, `entries`.`sectionId`, `entries`.`typeId`, `entries`.`authorId`, `entries`.`postDate`, `entries`.`expiryDate`, `content`.`id` AS `contentId`, `content`.`title`, `content`.`field_cta_showInBottomMenu_prbospbe`, `content`.`field_cta_caption_nfeapczo`, `content`.`field_cta_embedCode_esqnrbas`, `content`.`field_cta_showInFunctionalMenu_xbljkaqd`, `content`.`field_cta_showInMainMenu_stwyktch`, `content`.`field_cta_intro_icylapkn`, `content`.`field_cta_seo_bntxdvfi`, `content`.`field_cta_text_jrfpyfge`, `content`.`field_cta_pageTitle_nhableqa`, `structureelements`.`root`, `structureelements`.`lft`, `structureelements`.`rgt`, `structureelements`.`level`, `structureelements`.`structureId`
FROM (SELECT `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `elementsSitesId`, `content`.`id` AS `contentId`, `structureelements`.`structureId`
FROM `elements` `elements`
INNER JOIN `entries` `entries` ON `entries`.`id` = `elements`.`id`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`elementId` = `elements`.`id`
INNER JOIN `content` `content` ON `content`.`elementId` = `elements`.`id`
LEFT JOIN `structureelements` `structureelements` ON (`structureelements`.`elementId` = `elements`.`id`) AND (EXISTS (SELECT *
FROM `structures` use index(primary)
WHERE (`id` = `structureelements`.`structureId`) AND (`dateDeleted` IS NULL)))
WHERE (`entries`.`postDate` > '2023-01-09 13:38:51') AND (`elements`.`archived`=FALSE) AND (`elements`.`dateDeleted` IS NULL) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)
ORDER BY `postDate`
LIMIT 1) `subquery`
INNER JOIN `elements` `elements` ON `elements`.`id` = `subquery`.`elementsId`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`id` = `subquery`.`elementsSitesId`
INNER JOIN `entries` `entries` ON `entries`.`id` = `subquery`.`elementsId`
INNER JOIN `content` `content` ON `content`.`id` = `subquery`.`contentId`
LEFT JOIN `structureelements` `structureelements` ON (`structureelements`.`elementId` = `subquery`.`elementsId`) AND (`structureelements`.`structureId` = `subquery`.`structureId`)
ORDER BY `postDate` (/Users/tomds/Sites/test9/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'SELECT `element...')
#1 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT `element...')
#2 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/db/Command.php(424): yii\db\Command->queryInternal('fetch', NULL)
#3 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/db/Query.php(287): yii\db\Command->queryOne()
#4 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/db/Query.php(275): yii\db\Query->one(NULL)
#5 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1506): craft\db\Query->one(NULL)
#6 /Users/tomds/Sites/test9/vendor/sebastianlenz/linkfield/src/listeners/ElementListenerState.php(233): craft\elements\db\ElementQuery->one()
#7 /Users/tomds/Sites/test9/vendor/sebastianlenz/linkfield/src/listeners/ElementListenerState.php(153): lenz\linkfield\listeners\ElementListenerState->loadNextEntryChangeDate()
#8 /Users/tomds/Sites/test9/vendor/sebastianlenz/linkfield/src/listeners/ElementListenerState.php(47): lenz\linkfield\listeners\ElementListenerState->reset()
#9 /Users/tomds/Sites/test9/vendor/sebastianlenz/linkfield/src/listeners/ElementListenerState.php(283): lenz\linkfield\listeners\ElementListenerState->__construct()
#10 /Users/tomds/Sites/test9/vendor/sebastianlenz/linkfield/src/fields/LinkField.php(102): lenz\linkfield\listeners\ElementListenerState::getInstance()
#11 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/services/Fields.php(1712): lenz\linkfield\fields\LinkField->afterSave(true)
#12 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/services/Matrix.php(312): craft\services\Fields->applyFieldSave('10e4843b-8733-4...', Array, 'matrixBlockType...')
#13 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/base/ApplicationTrait.php(1695): craft\services\Matrix->handleChangedBlockType(Object(craft\events\ConfigEvent))
#14 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/services/ProjectConfig.php(1125): craft\console\Application->craft\base\{closure}(Object(craft\events\ConfigEvent))
#15 [internal function]: craft\services\ProjectConfig->handleChangeEvent(Object(craft\events\ConfigEvent))
#16 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/Component.php(633): call_user_func(Array, Object(craft\events\ConfigEvent))
#17 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/models/ProjectConfigData.php(82): yii\base\Component->trigger('updateItem', Object(craft\events\ConfigEvent))
#18 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/services/ProjectConfig.php(1231): craft\models\ProjectConfigData->commitChanges(Array, Array, 'matrixBlockType...', true, NULL, true)
#19 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/services/ProjectConfig.php(1253): craft\services\ProjectConfig->craft\services\{closure}('matrixBlockType...', true)
#20 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/services/ProjectConfig.php(577): craft\services\ProjectConfig->_applyChanges(Array, Object(craft\models\ProjectConfigData), Object(craft\models\ReadOnlyProjectConfigData))
#21 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/migrations/Install.php(1131): craft\services\ProjectConfig->applyExternalChanges()
#22 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/migrations/Install.php(78): craft\migrations\Install->insertDefaultData()
#23 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/db/Migration.php(49): craft\migrations\Install->safeUp()
#24 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/db/MigrationManager.php(233): craft\db\Migration->up(true)
#25 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/controllers/InstallController.php(213): craft\db\MigrationManager->migrateUp(Object(craft\migrations\Install))
#26 [internal function]: craft\console\controllers\InstallController->actionCraft()
#27 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#28 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#29 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('craft', Array)
#30 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/Controller.php(227): yii\console\Controller->runAction('craft', Array)
#31 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('craft', Array)
#32 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('install/craft', Array)
#33 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('install/craft', Array)
#34 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/Controller.php(212): craft\console\Application->runAction('install/craft', Array)
#35 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/Controller.php(218): yii\base\Controller->run('install/craft', Array)
#36 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/controllers/SetupController.php(131): craft\console\Controller->run('install/craft')
#37 [internal function]: craft\console\controllers\SetupController->actionIndex()
#38 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#39 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#40 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('', Array)
#41 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/Controller.php(227): yii\console\Controller->runAction('', Array)
#42 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('', Array)
#43 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('setup', Array)
#44 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('setup', Array)
#45 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('setup', Array)
#46 /Users/tomds/Sites/test9/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#47 /Users/tomds/Sites/test9/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#48 /Users/tomds/Sites/test9/craft(13): yii\base\Application->run()
#49 {main}
@TomDeSmet TomDeSmet changed the title LinkField throws error when running craft\migrations\Install LinkField throws error when running craft\migrations\Install due to columnSuffix: null Jan 9, 2023
@TomDeSmet TomDeSmet changed the title LinkField throws error when running craft\migrations\Install due to columnSuffix: null LinkField throws error when running craft\migrations\Install due to columnSuffix being null Jan 9, 2023
@TomDeSmet TomDeSmet changed the title LinkField throws error when running craft\migrations\Install due to columnSuffix being null LinkField throws error when running craft\migrations\Install Jan 9, 2023
@dgrigg
Copy link

dgrigg commented Mar 6, 2023

any update on this error, running into the same error code while attempting to upgrade from Craft 3 to Craft 4.

@mandrasch
Copy link

+1 also had this problem, I could provide an reproducible example (via DDEV) if this would be helpful for debugging

@mandrasch
Copy link

mandrasch commented Jun 14, 2023

Ah, just saw #254 - would this also fix this issue? 🙂 (i can test it also next week if test is needed)

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

3 participants