4

We have a PostgreSQL database, and have defined JavaScript ORM classes using Objection.js. As our database structure has evolved, we have been defining database migrations using Knex. We would now like to 'squash' the migrations, e.g. into a 'latest' migration.

How can we 'squash' Knex migrations and/or generate a new migration using the Objection database classes?

Brylie Christopher Oxley
  • 1,684
  • 1
  • 17
  • 34

1 Answers1

3

You can take SQL dump of you database, drop migration tables and delete all old migration files. Then always use the stored SQL dump to initialize your database and then you can start creating new migration files on top of that dump.

As far as I know there is no way to do this cross database compatible way without running commandline tools for taking / restoring dumps.

Mikael Lepistö
  • 18,909
  • 3
  • 68
  • 70