cancel
Showing results for 
Search instead for 
Did you mean: 

Foreign key constraint is incorrectly formed

Foreign key constraint is incorrectly formed

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory.
The following modules are outdated:
Magento_AuthorizenetAcceptjs schema: current version - none, required version - 1.0.0
Magento_AuthorizenetAcceptjs data: current version - none, required version - 1.0.0
Amazon_Core schema: current version - none, required version - 3.2.9
Amazon_Core data: current version - none, required version - 3.2.9
Amazon_Login schema: current version - none, required version - 3.2.9
Amazon_Login data: current version - none, required version - 3.2.9
Amazon_Payment schema: current version - none, required version - 3.2.9
Amazon_Payment data: current version - none, required version - 3.2.9
Dotdigitalgroup_Email schema: current version - none, required version - 3.1.2
Dotdigitalgroup_Email data: current version - none, required version - 3.1.2
Klarna_Core schema: current version - none, required version - 5.1.0
Klarna_Core data: current version - none, required version - 5.1.0
Klarna_Ordermanagement schema: current version - none, required version - 5.0.2
Klarna_Ordermanagement data: current version - none, required version - 5.0.2
Klarna_Kp schema: current version - none, required version - 6.1.1
Klarna_Kp data: current version - none, required version - 6.1.1
MSP_TwoFactorAuth schema: current version - none, required version - 3.1.0
MSP_TwoFactorAuth data: current version - none, required version - 3.1.0
Temando_Shipping schema: current version - none, required version - 1.5.0
Temando_Shipping data: current version - none, required version - 1.5.0
Vertex_Tax schema: current version - none, required version - 100.3.0
Vertex_Tax data: current version - none, required version - 100.3.0

Exception #0 (Magento\Framework\Exception\LocalizedException): Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory.
The following modules are outdated:
Magento_AuthorizenetAcceptjs schema: current version - none, required version - 1.0.0
Magento_AuthorizenetAcceptjs data: current version - none, required version - 1.0.0
Amazon_Core schema: current version - none, required version - 3.2.9
Amazon_Core data: current version - none, required version - 3.2.9
Amazon_Login schema: current version - none, required version - 3.2.9
Amazon_Login data: current version - none, required version - 3.2.9
Amazon_Payment schema: current version - none, required version - 3.2.9
Amazon_Payment data: current version - none, required version - 3.2.9
Dotdigitalgroup_Email schema: current version - none, required version - 3.1.2
Dotdigitalgroup_Email data: current version - none, required version - 3.1.2
Klarna_Core schema: current version - none, required version - 5.1.0
Klarna_Core data: current version - none, required version - 5.1.0
Klarna_Ordermanagement schema: current version - none, required version - 5.0.2
Klarna_Ordermanagement data: current version - none, required version - 5.0.2
Klarna_Kp schema: current version - none, required version - 6.1.1
Klarna_Kp data: current version - none, required version - 6.1.1
MSP_TwoFactorAuth schema: current version - none, required version - 3.1.0
MSP_TwoFactorAuth data: current version - none, required version - 3.1.0
Temando_Shipping schema: current version - none, required version - 1.5.0
Temando_Shipping data: current version - none, required version - 1.5.0
Vertex_Tax schema: current version - none, required version - 100.3.0
Vertex_Tax data: current version - none, required version - 100.3.0
<pre>#1 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000005b5b4a6000000000353bf9df#) called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:73]
#2 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(&Magento\Framework\App\FrontController\Interceptor#000000005b5b49c800000000353bf9df#, &Closure#000000005b5b4cf900000000353bf9df#, &Magento\Framework\App\Request\Http#000000005b5b4a6000000000353bf9df#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#3 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#000000005b5b4a6000000000353bf9df#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#4 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#000000005b5b4a6000000000353bf9df#), array(array('page_cache_from_...', 'storeCookieValid...', 'install', 'configHash'), array('front-controller...'), 'requestPreproces...')) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#5 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#000000005b5b4a6000000000353bf9df#) called at [vendor/magento/framework/App/Http.php:137]
#6 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#7 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#8 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000005b5b489700000000353bf9df#) called at [index.php:39]
</pre>

To fix the error above I'm running the following in my magento directory:

bin/magento setup:upgrade

and I'm receiving this error:

SQLSTATE[HY000]: General error: 1025 Error on rename of './dmmjr_magento2/#sql-607f_5be' to './dmmjr_magento2/customer_group' (errno: 150 "Foreign key constraint is incorrectly formed"), query was: ALTER TABLE `customer_group` MODIFY COLUMN `customer_group_id` int(10) UNSIGNED NOT NULL  AUTO_INCREMENT

I've already tried to disable foreign key checks, TRUNCATE customer_group, and reenable foreign key checks. This does not work.

1 REPLY 1

Re: Foreign key constraint is incorrectly formed

Hi @david_martini,

I have one question, are you upgrading from magento website directly from magento 2.1 to 2.3? Beacuse this error actually comes when we upgrade directly from 2.1 to 2.3. 

If yes, then you should upgrade in below sequence. 

    1. Upgrade the magento 2.1.6 to 2.1.18 ( Stable/Latest version of magento 2.1 release).
    2. Then upgrade 2.1.18 to 2.2.8 ( Stable/Latest version of magento 2.2 release).
    3. After that upgrade the magento 2.2.8 to 2.3.2 ( Stable/Latest version of magento 2.3 release).

 
I hope it will help you!