0

I know there are similar questions asked several times and i looked almost each and every answers but didn't find this issue resolved in my case.

I am getting this error:

1215 - Cannot add foreign key constraint

When I am importing an exact copy of the database which i had exported from the same server few minutes ago.

Please see the error information below:

Error

SQL query:

--
-- Constraints for table `lof_gallery_album_post`
--
ALTER TABLE `lof_gallery_album_post` 
  ADD CONSTRAINT `LOF_GALLERY_ALBUM_POST_ALBUM_ID_LOF_GALLERY_ALBUM_ALBUM_ID` 
    FOREIGN KEY ( `album_id` ) REFERENCES `lof_gallery_album` ( `album_id` ) 
    ON DELETE CASCADE ,
  ADD CONSTRAINT `LOF_GALLERY_ALBUM_STORE_POST_ID_VES_BLOG_POST_POST_ID` 
    FOREIGN KEY ( `post_id` ) REFERENCES `ves_blog_post` ( `post_id` ) 
    ON DELETE CASCADE ;

MySQL said: Documentation

1215 - Cannot add foreign key constraint

Any idea what's wrong with that and how to solve this issue?

Community
  • 1
  • 1
orbnexus
  • 737
  • 1
  • 9
  • 38
  • if you share complete error, then it will help to understand – Ravi Feb 08 '18 at 18:57
  • 1
    There are several possible causes of the error. See the checklist for foreign keys in the top answer of https://stackoverflow.com/questions/1457305/mysql-creating-tables-with-foreign-keys-giving-errno-150 and see if one applies to you. – Bill Karwin Feb 08 '18 at 18:57
  • The following answer from the same question mentioned by @BillKarwin is also important since it shows you how to get the real cause for the error from MySQL: https://stackoverflow.com/a/18180299/5389997 – Shadow Feb 08 '18 at 19:21

0 Answers0