Over time, projects can accumulate numerous migrations, making them harder to manage and potentially slowing down the migration process. By squashing older migrations into a single file, the migration process becomes more streamlined and manageable.
This PR introduces three core function for squashing multiple migrations into a single migration file, which simplifies the management of large migration histories.
Core Functions
squashing-list: Takes from-id and to-id as inputs (both inclusive) and returns the list of migrations to be squashed.
create-squash: Reads files within the specified id range and generates a new squashed migration file. It removes the original migration files and creates a new one with the last ID from the range and a user-provided name.
squash: Updates the migration table by marking the old IDs as squashed and replacing them with the new ID. No actual migration is applied, assuming they were previously applied.
The squashing process is broken down into three distinct steps to reduce the risk of human errors, to preview before applying changes.
Validations
Mixed migration formats (EDN and SQL) are not supported: If there is a mix of EDN (code-based) and SQL (SQL-based) migrations in the specified range, an exception is thrown.
EDN migration squashing is not implemented yet, and this functionality has been added to the backlog for future development.
If there are unapplied migrations, an exception will be raised to prevent squashing incomplete migrations, ensuring database consistency.
resolves #263
Why?
Over time, projects can accumulate numerous migrations, making them harder to manage and potentially slowing down the migration process. By squashing older migrations into a single file, the migration process becomes more streamlined and manageable. This PR introduces three core function for squashing multiple migrations into a single migration file, which simplifies the management of large migration histories.
Core Functions
The squashing process is broken down into three distinct steps to reduce the risk of human errors, to preview before applying changes.
Validations