0

When creating a second migration and attempting to migrate up to add it, the task fails because the first migration was already run. It seems to be running (and failing) rather than skipping previously successful/complete migrations.

I have tried with --no-check-order but I don't want to do that everytime I got new migrations to add.

I have my database locally. Using node-pg-migrate and postgreSQL

Mehdi
  • 7,204
  • 1
  • 32
  • 44
lordcarnisser
  • 87
  • 2
  • 10
  • 1
    Welcome to stackOverflow. Could you edit the question to add the exact commands executed, and the error messages returned? – Mehdi Apr 15 '20 at 09:33

1 Answers1

0

In a general way, the order of migrations matters as you can e.g. alter the same type and the last run migration wins. It can happen e.g. if you have pull requests and merge them to base branch in a different order than the migrations were created. You can now e.g. rename migration so it is sorted on disk in the correct order (before not-run-migrations) and update records in pgmigrations table, or you can put new migrations aside (so they do not trigger this error) and run as many down migrations as needed, then restore migrations definitions on disk and run up migrations.