ethercreative / simplemap

A beautifully simple map field type for Craft CMS.
Other
137 stars 47 forks source link

"The table does not exist" when trying to save an entry #361

Open tremby opened 1 year ago

tremby commented 1 year ago

I just installed the plugin on Craft 4. The installation looked successful:

*** installing simplemap
    > create table {{%maps}} ... done (time: 0.005s)
    > create unique index idx_xpprhqrpgfgkssibzvlwmqcmptxcpomsrhqz on {{%maps}} (ownerId,ownerSiteId,fieldId) ... done (time: 0.001s)
    > create index idx_kicppoqujkcfntvatjsqvpszqdcoxkidzsnb on {{%maps}} (lat) ... done (time: 0.001s)
    > create index idx_iclvjeveureisdthmthbzkfhxtfqsxfgvfzr on {{%maps}} (lng) ... done (time: 0.001s)
    > add foreign key fk_lskoaiyxwlqzjdmxvfnnrtqaovjuagkehdel: {{%maps}} (ownerId) references {{%elements}} (id) ... done (time: 0.001s)
    > add foreign key fk_lypsrxfrqlybauxshuurkvtmxmquwpbrgwdq: {{%maps}} (ownerSiteId) references {{%sites}} (id) ... done (time: 0.001s)
    > add foreign key fk_uhsdzuuafvgkiizgovwmyniufltmhfhdaopu: {{%maps}} (fieldId) references {{%fields}} (id) ... done (time: 0.001s)
*** installed simplemap successfully (time: 0.037s)

I added a field of the Map type, added it to an entry type, then tried to save an entry. I get this error:

yii\base\InvalidConfigException: The table does not exist: {{%maps}} in /srv/myproject/vendor/yiisoft/yii2/db/ActiveRecord.php:442
Stack trace:
#0 /srv/myproject/vendor/yiisoft/yii2/db/ActiveRecord.php(266): yii\db\ActiveRecord::getTableSchema()
#1 /srv/myproject/vendor/yiisoft/yii2/db/ActiveRecord.php(238): yii\db\ActiveRecord::filterValidColumnNames(Object(craft\db\Connection), Array)
#2 /srv/myproject/vendor/yiisoft/yii2/db/ActiveRecord.php(195): yii\db\ActiveRecord::filterCondition(Array, Array)
#3 /srv/myproject/vendor/yiisoft/yii2/db/BaseActiveRecord.php(110): yii\db\ActiveRecord::findByCondition(Array)
#4 /srv/myproject/vendor/ether/simplemap/src/services/MapService.php(82): yii\db\BaseActiveRecord::findOne(Array)
#5 /srv/myproject/vendor/ether/simplemap/src/fields/MapField.php(454): ether\simplemap\services\MapService->saveField(Object(ether\simplemap\fields\MapField), Object(craft\elements\Entry))
#6 /srv/myproject/vendor/craftcms/cms/src/base/Element.php(4652): ether\simplemap\fields\MapField->afterElementSave(Object(craft\elements\Entry), false)
#7 /srv/myproject/vendor/craftcms/cms/src/elements/Entry.php(1941): craft\base\Element->afterSave(false)
#8 /srv/myproject/vendor/craftcms/cms/src/services/Elements.php(2875): craft\elements\Entry->afterSave(false)
#9 /srv/myproject/vendor/craftcms/cms/src/services/Elements.php(940): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, true, true)
#10 /srv/myproject/vendor/craftcms/cms/src/controllers/ElementsController.php(882): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#11 [internal function]: craft\controllers\ElementsController->actionSave()
#12 /srv/myproject/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /srv/myproject/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#14 /srv/myproject/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save', Array)
#15 /srv/myproject/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('elements/save', Array)
#16 /srv/myproject/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('elements/save', Array)
#17 /srv/myproject/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#18 /srv/myproject/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 /srv/myproject/web/index.php(12): yii\base\Application->run()
#20 {main}

In case it's helpful, I'm using Postgres. I have tried uninstalling and reinstalling the plugin, and removing and adding it again via composer.

tremby commented 1 year ago

Looks like the table was created in a different schema from the rest of the tables. I'm not sure why but it's likely my fault...