Repository navigation
v3.0.0
#531
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Major release with some breaking changes since v2.x, see migration guide here: https://github.com/sequelize/umzug#upgrading-from-v2x
Several new features, including a new built-in CLI, typescript support, templating, improved events, logging and error messages, and more.
Find usage examples under https://github.com/sequelize/umzug/tree/master/examples
Migration guide at time of writing copied here for covenience:
Upgrading from v2.x
The Umzug class should be imported as a named import, i.e.
import { Umzug } from 'umzug'.The
MigrationMetatype, which is returned byumzug.executed()andumzug.pending(), no longer has afileproperty - it has anameand optionalpath- since migrations are not necessarily bound to files on the file system.The
migrations.globparameter replacespath,patternandtraverseDirectories. It can be used, in combination withcwdandignoreto do much more flexible file lookups. See https://npmjs.com/package/glob for more information on the syntax.The
migrations.resolveparameter replacescustomResolver. Explicit support forwrapandnameFormatterhas been removed - these can be easily implemented in aresolvefunction.The constructor option
loggingis replaced byloggerto allow forwarnanderrormessages in future. NodeJS's globalconsoleobject can be passed to this. To disable logging, replacelogging: falsewithlogger: undefined.Events have moved from the default nodejs
EventEmitterto emittery. It has better design for async code, a less bloated API surface and strong types. But, it doesn't allow passing multiple arguments to callbacks, so listeners have to change slightly, as well as.addListener(...)and.removeListener(...)no longer being supported (.on(...)and.off(...)should now be used):Before:
After:
The
Umzug#executemethod is removed. UseUmzug#uporUmzug#down.The options for
Umguz#upandUmzug#downhave changed:umzug.up({ to: 'some-name' })andumzug.down({ to: 'some-name' })are still valid.umzug.up({ from: '...' })andumzug.down({ from: '...' })are no longer supported. To run migrations out-of-order (which is not generally recommended), you can explicitly useumzug.up({ migrations: ['...'] })andumzug.down({ migrations: ['...'] }).umzug.up({ to: 'some-n' })will no longer match a migration calledsome-name.umzug.down({ to: 0 })is still valid butumzug.up({ to: 0 })is not.umzug.up({ migrations: ['m1', 'm2'] })is still valid but the shorthandumzug.up(['m1', 'm2'])has been removed.umzug.down({ migrations: ['m1', 'm2'] })is still valid but the shorthandumzug.down(['m1', 'm2'])has been removed.umzug.up({ migrations: ['m1', 'already-run'] })will throw an error, ifalready-runis not found in the list of pending migrations.umzug.down({ migrations: ['m1', 'has-not-been-run'] })will throw an error, ifhas-not-been-runis not found in the list of executed migrations.umzug.up({ migrations: ['m1', 'm2'], rerun: 'ALLOW' })will re-apply migrationsm1andm2even if they've already been run.umzug.up({ migrations: ['m1', 'm2'], rerun: 'SKIP' })will skip migrationsm1andm2if they've already been run.umzug.down({ migrations: ['m1', 'm2'], rerun: 'ALLOW' })will "revert" migrationsm1andm2even if they've never been run.umzug.down({ migrations: ['m1', 'm2'], rerun: 'SKIP' })will skip reverting migrationsm1andm2if they haven't been run or are already reverted.umzug.up({ migrations: ['m1', 'does-not-exist', 'm2'] })will throw an error if the migration name is not found. Note that the error will be thrown and no migrations run unless all migration names are found - whether or notrerun: 'ALLOW'is added.The
contextparameter replacesparams, and is passed in as a property to migration functions as an options object, alongs sidenameandpath. This means the signature for migrations, which in v2 was(context) => Promise<void>, has changed slightly in v3, to({ name, path, context }) => Promise<void>.Handling existing v2-format migrations
The
resolvefunction can also be used to upgrade your umzug version to v3 when you have existing v2-compatible migrations:Similarly, you no longer need
migrationSorting, you can instantiate a newUmzuginstance to manipulate migration lists directly:👇 full, generated changelog
What's Changed
stepin up and down options by @mmkal in Supportstepin up and down options #386unlogMigrationby @husa in fix #491. Fix MongoStorageunlogMigration#492.extend(...)in favour of constructor by @mmkal in Remove.extend(...)in favour of constructor #523New Contributors
unlogMigration#492Full Changelog: v2.3.0...v3.0.0
This discussion was created from the release v3.0.0.
All reactions