0

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.

1

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;
  • Thank you for the response but still not working give an error like prntscr.com/oow1oz – Vishal Baraiya Aug 6 at 5:51
  • 1
    Can you try this once again by truncating table customer_group – Mitro Aug 6 at 6:13
  • truncate table query not working because of the foreign key constraint prntscr.com/oowfjb – Vishal Baraiya Aug 6 at 6:29
  • You have to first unset the foreign key check and after that truncate the table, and again set a foreign key check to 1. Read the above answer again. – Mitro Aug 6 at 7:02
  • I understand and do as you said but still issue available – Vishal Baraiya Aug 6 at 7:34
1

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...

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.