Magento 2 upgrade 2.1.7 to 2.3.2 give error Foreign key constraint is incorrectly formed modify column customer_group_id in table of customer_group
-
09-03-2021 - |
質問
Can anyone please explain about this type of error Like http://prntscr.com/oow1oz
Also, I refer to this link Magento 2 failed database rollback cannot add foreign key constraints but not working for me.
so please anyone help me.
Thank you in advance.
解決 2
I am searching for the various post but not working for me.at last find the solution by me. If Anyone fetches that type of error occur solution is given step by step.
STEP: 1 Upgrade Magento 2.1.7 to 2.2.5
STEP: 2 Upgrade Magento 2.2.5 to Latest Version
May helpfull this answer... Thank You... Happy Codding...
他のヒント
You can try this solution. Run the following query in your mysql database
SET FOREIGN_KEY_CHECKS = 0;
Truncate table customer_group
After the upgrade process finished run following query:
SET FOREIGN_KEY_CHECKS = 1;
To fix that I followed those steps:
1) Found the referenced foreign key:
SELECT
TABLE_NAME,
COLUMN_NAME,
CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME
FROM
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_SCHEMA = 'db_name'
AND REFERENCED_TABLE_NAME = 'table_name';
My result was:
+----------------+----------------+----------------------------------------------------------------+-----------------------+------------------------+
| TABLE_NAME | COLUMN_NAME | CONSTRAINT_NAME | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+----------------+----------------+----------------------------------------------------------------+-----------------------+------------------------+
| amasty_fpc_log | customer_group | AMASTY_FPC_LOG_CUSTOMER_GROUP_CUSTOMER_GROUP_CUSTOMER_GROUP_ID | customer_group | customer_group_id |
+----------------+----------------+----------------------------------------------------------------+-----------------------+------------------------+
2) Remove foreign key:
ALTER TABLE `amasty_fpc_log`
DROP FOREIGN KEY `AMASTY_FPC_LOG_CUSTOMER_GROUP_CUSTOMER_GROUP_CUSTOMER_GROUP_ID`;
3) Execute the alter script (or setup:upgrade)
ALTER TABLE `customer_group` MODIFY COLUMN `customer_group_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
NOTE: Do a backup before executing any query on database. NOTE2: You my loose column data after removing foreign key.
I hope it helps.