Search code examples
migrationtypeorm

migrating down your latest migrations


First a theoritical background:

If I create 3 new migration files that would change 3 tables after I migrate up , should migrate down revert all 3 tables effected by the latest migration or just the last table that was effected?
(my guess the former should happen)

The problem:

In typeorm when I typeorm migrate:revert , it only effects the last table that was effected by the latest migration, so I'm wondering if my guess was correct or not. What is the usual behaviour for migrate down in general(irrespective of the ORM used).

Is this an expected behaviour or there a possible solution for typeorm to keep track of the latest migration changes to revert all the changes in latest migration?

I have found this in their documentation:

If for some reason you want to revert the changes, you can run: typeorm migration:revert This command will execute down in the latest executed migration. If you need to revert multiple migrations you must call this command multiple times.

But, if what I expect is true, then an orm should already have the tools to do so.


Solution

  • AFAIK, typeorm doesn't have this feature as of yet, you migrate down your stuff migration by migration(one migration file content at a time).