Dave Wize's avatar

Error on migrate

I'm getting this migration error

 SQLSTATE[HY000]: General error: 1822 Failed to add the foreign key constraint. Missing index for constraint 'account_payment_payment_type_foreign' in the referenced table 'item_master' 
0 likes
2 replies
LaryAI's avatar
Level 58

The error message suggests that there is a missing index for the foreign key constraint 'account_payment_payment_type_foreign' in the referenced table 'item_master'. To fix this, you need to make sure that the referenced column in the 'item_master' table has an index.

You can add an index to the column by running the following SQL command:

ALTER TABLE item_master ADD INDEX index_name (column_name);

Replace 'index_name' with a name for the index and 'column_name' with the name of the column that is being referenced in the foreign key constraint.

Once the index has been added, try running the migration again.

siangboon's avatar

may also consider the sequence of the migration, the referenced table have to exist before the foreign key constraint creation...

Please or to participate in this conversation.