boldenamsterdam / htmlcache

Cache pages to HTML and boost website performance on Craft CMS 3
MIT License
31 stars 21 forks source link

Cannot add foreign key constraint on plugin install #13

Closed mrksmts closed 5 years ago

mrksmts commented 5 years ago

When installing the plugin I get the following error:

*** installing html-cache
    > dropping {{%htmlcache_caches}} if it exists ... done (time: 0.002s)
    > dropping {{%htmlcache_elements}} if it exists ... done (time: 0.001s)
    > create table {{%htmlcache_caches}} ... done (time: 0.012s)
    > create unique index htmlcache_caches_uri_siteId_idx on {{%htmlcache_caches}} (uri,siteId) ... done (time: 0.009s)
    > add foreign key htmlcache_caches_siteId_fk: {{%htmlcache_caches}} (siteId) references {{%sites}} (id) ... done (time: 0.018s)
    > create table {{%htmlcache_elements}} ... done (time: 0.009s)
    > create unique index htmlcache_caches_elementId_cacheId_idx on {{%htmlcache_elements}} (elementId,cacheId) ... done (time: 0.013s)
    > add foreign key htmlcache_elements_elementId_fk: {{%htmlcache_elements}} (elementId) references {{%htmlcache_elements}} (id) ...Exception: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
The SQL being executed was: ALTER TABLE `htmlcache_elements` ADD CONSTRAINT `htmlcache_elements_elementId_fk` FOREIGN KEY (`elementId`) REFERENCES `htmlcache_elements` (`id`) ON DELETE CASCADE (/app/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /app/vendor/yiisoft/yii2/db/Command.php(1263): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE `ht...')
#1 /app/vendor/yiisoft/yii2/db/Command.php(1075): yii\db\Command->internalExecute('ALTER TABLE `ht...')
#2 /app/vendor/yiisoft/yii2/db/Migration.php(467): yii\db\Command->execute()
#3 /app/vendor/craftcms/cms/src/db/Migration.php(382): yii\db\Migration->addForeignKey('htmlcache_eleme...', '{{%htmlcache_el...', Array, '{{%htmlcache_el...', Array, 'CASCADE', NULL)
#4 /app/vendor/bolden/htmlcache/src/migrations/Install.php(58): craft\db\Migration->addForeignKey('htmlcache_eleme...', '{{%htmlcache_el...', Array, '{{%htmlcache_el...', Array, 'CASCADE')
#5 /app/vendor/craftcms/cms/src/db/Migration.php(56): bolden\htmlcache\migrations\Install->safeUp()
#6 /app/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#7 /app/vendor/craftcms/cms/src/base/Plugin.php(152): craft\db\MigrationManager->migrateUp(Object(bolden\htmlcache\migrations\Install))
#8 /app/vendor/craftcms/cms/src/services/Plugins.php(513): craft\base\Plugin->install()
#9 /app/vendor/craftcms/cms/src/console/controllers/InstallController.php(191): craft\services\Plugins->installPlugin('html-cache')
#10 [internal function]: craft\console\controllers\InstallController->actionPlugin('html-cache')
#11 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /app/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#13 /app/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('plugin', Array)
#14 /app/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('plugin', Array)
#15 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('install/plugin', Array)
#16 /app/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('install/plugin', Array)
#17 /app/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('install/plugin', Array)
#18 /app/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#19 /app/craft(22): yii\base\Application->run()
#20 {main}
*** installed html-cache successfully (time: 0.115s)
Software Version
PHP version 7.1.26
MySQL 5.7.25
Imagick 3.4.3 (ImageMagick 6.8.9-9)
Craft Solo 3.1.5