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!

Fred
  • 3,365
  • 4
  • 36
  • 57
Atalaia
  • 45
  • 1
  • 6

2 Answers2

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.

Atalaia
  • 45
  • 1
  • 6
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".