What happened?
Description
In my SEO plugin, I'm listening for Sites::EVENT_AFTER_SAVE_SITE to add default values in my now table for the new site. (here)
When installing the plugin on its own, that works - but when installing from existing project config files, that contain the plugin, this failed because the table can't be found - (yet?)
Exception: The table does not exist: {{%seofields_data}} (/var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php:442)
#0 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(266): yii\db\ActiveRecord::getTableSchema()
#1 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(238): yii\db\ActiveRecord::filterValidColumnNames(Object(craft\db\Connection), Array)
#2 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(195): yii\db\ActiveRecord::filterCondition(Array, Array)
#3 /var/www/html/vendor/yiisoft/yii2/db/BaseActiveRecord.php(110): yii\db\ActiveRecord::findByCondition(Array)
#4 /var/www/html/vendor/studioespresso/craft-seo-fields/src/services/DefaultsService.php(115): yii\db\BaseActiveRecord::findOne(Array)
#5 /var/www/html/vendor/studioespresso/craft-seo-fields/src/services/DefaultsService.php(63): studioespresso\seofields\services\DefaultsService->getRecordForSiteId(NULL)
#6 /var/www/html/vendor/studioespresso/craft-seo-fields/src/services/DefaultsService.php(123): studioespresso\seofields\services\DefaultsService->getDataBySiteId(NULL)
#7 /var/www/html/vendor/studioespresso/craft-seo-fields/src/SeoFields.php(319): studioespresso\seofields\services\DefaultsService->copyDefaultsForSite(Object(craft\models\Site), NULL)
Checking the database I see that table doesn't exist yet, and in the plugins table I can see that the plugin isn't actually installed yet - I think.
I tried wrapping my event listeners in Craft::$app->onInit(function () {}); but the error still happens.
What would be the best way to fix this? Thanks!
Craft CMS version
5.3.0.3
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
What happened?
Description
In my SEO plugin, I'm listening for
Sites::EVENT_AFTER_SAVE_SITEto add default values in my now table for the new site. (here)When installing the plugin on its own, that works - but when installing from existing project config files, that contain the plugin, this failed because the table can't be found - (yet?)
Exception: The table does not exist: {{%seofields_data}} (/var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php:442) #0 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(266): yii\db\ActiveRecord::getTableSchema() #1 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(238): yii\db\ActiveRecord::filterValidColumnNames(Object(craft\db\Connection), Array) #2 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(195): yii\db\ActiveRecord::filterCondition(Array, Array) #3 /var/www/html/vendor/yiisoft/yii2/db/BaseActiveRecord.php(110): yii\db\ActiveRecord::findByCondition(Array) #4 /var/www/html/vendor/studioespresso/craft-seo-fields/src/services/DefaultsService.php(115): yii\db\BaseActiveRecord::findOne(Array) #5 /var/www/html/vendor/studioespresso/craft-seo-fields/src/services/DefaultsService.php(63): studioespresso\seofields\services\DefaultsService->getRecordForSiteId(NULL) #6 /var/www/html/vendor/studioespresso/craft-seo-fields/src/services/DefaultsService.php(123): studioespresso\seofields\services\DefaultsService->getDataBySiteId(NULL) #7 /var/www/html/vendor/studioespresso/craft-seo-fields/src/SeoFields.php(319): studioespresso\seofields\services\DefaultsService->copyDefaultsForSite(Object(craft\models\Site), NULL)Checking the database I see that table doesn't exist yet, and in the plugins table I can see that the plugin isn't actually installed yet - I think.
I tried wrapping my event listeners in
Craft::$app->onInit(function () {});but the error still happens.What would be the best way to fix this? Thanks!
Craft CMS version
5.3.0.3
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions