Repository navigation
db-migrate 1.8.1: what's new since 1.0.0
1.1 to 1.8 make v2 migrations usable for data as well as schema. You get reversible data migrations, background jobs, soft deletes, releases with deprecations, and a status command. Scopes can now have a database of their own. v1 migrations keep working unchanged.
Highlights
- DML migrations (1.3): reversible data changes inside v2 migrations. Transactions run per batch, and soft delete and purge are supported (1.4). They need
db-migrate-base2.5.0 or newer. - Background migrations (1.4, 1.6): long-running data changes run as jobs, started by
db-migrate workorexecuteWork(). Jobs pause while migrations run, anddownreverts them. - Releases and deprecations (1.5): tables and columns can be marked as deprecated. Rows deleted in soft mode are purged with a later release.
db-migrate status(1.7): shows what db-migrate knows about the database.- Static seeds (1.3): data you can rerun for development and tests. These replace the seeders that were dropped in 1.0.
- Adopt existing objects (1.1):
db.adopt.createTable,addColumn,addIndex,addForeignKeyand the other create/add instructions declare objects without executing anything. That covers objects made by v1 migrations or by hand. After that, v2 migrations can revert them fully. - Scopes with their own database (1.1): a scope's
config.jsonwith connection settings connects that scope on its own. Lock, recovery progress and the learned schema are kept per scope. - v1 migrations without a transaction (1.2):
exports._meta = { transactions: false }, e.g. forCREATE INDEX CONCURRENTLY. - Defaults for environment variables in the config (1.8).
- Backups of data migrations are dropped once they are final (1.7).
⚠ Upgrade notes
- Option precedence (1.8.1): options given on the command line or to an API instance now win over rc files. rc files only replace the defaults.
- Scope state (1.1): a scope whose
config.jsonsets a database or schema now keeps its state in that database. If its v2 migrations ran before, rundb-migrate fix:<scope>once. - Jobs of scopes with their own database (1.8.1): run them with
db-migrate work:<scope>orexecuteWork({ scope }).work:allis refused. - Dropping unknown objects (1.1): dropping a table, column or foreign key that db-migrate doesn't know needs
{ irreversible: true }. Such a migration is not rolled back, anddownrefuses it. - Drivers: DML migrations need
db-migrate-base≥ 2.5.0._meta.transactions: falsewith MySQL needsdb-migrate-mysql≥ 3.1.2. The pg settingschemais applied again withdb-migrate-pg≥ 1.6.1.
Bug fixes
Scopes and commands
up:alland the otherall-scope commands ran only the top-level migrations.syncandfixof a scope didn't find its migrations (#471).create:<scope> --sql-fileput the SQL files into the wrong folder.- Migrations created with
--sql-fileno longer print their SQL (#775, #829, #805, #422). db:createanddb:dropresolved before they were done, and exited the process when called through the API.
Config and API
- rc aliases (
state-table,migration-table) and--ignore-completed-migrationsare honored again. The app's own arguments are parsed correctly in module mode. - Calls on one API instance start from that instance's options (#474).
- Plugins are found when hoisted, and a broken plugin is skipped (#826).
v2, DML and background jobs
changeColumnis reverted to the column's previous spec.fixlearns the steps of releases again. It learns migration records once, from an empty schema.- A deprecated table keeps its deprecation when it is renamed for it.
- A job runs in the scope of its migration, is not run again once its migration is recorded, and keeps its record when recovered by rollback.
work --dry-runlists the jobs that would run.fix --backup-statekeeps jobs and DML migration records.--non-transactionalalso turns off transactions in DML migrations.- Soft delete: the mark is matched as a whole. On MySQL a soft delete is refused if its mark would be cut off.
Full changelog: v1.0.0...v1.8.1