0

When trying to execute the command line 'sequelize db:migrate' I've got the following error:

ERROR: Cannot add foreign key constraint

ERROR: Cannot add foreign key constraint

I have checked my models and migration files and I could not find anything. Do you know what this error means? or what the problem is?

Thanks in advance!

2 Answers 2

1

If it can help someone, I have solved this issue by changing the numbers in the migration files (01 instead of 1, 02 instead of 2 and so on).

If not, sequelize does not execute the migration files in the right order, it jumps from 1 to 10, skipping the files from 2 to 9, and that creates foreign constraints errors.

Sign up to request clarification or add additional context in comments.

Comments

0

To be clear about the order of execution of the database tables, it is necessary to know the order of the JS files in the path of "migrations".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.