Skip to content

Releases: sequelize/umzug

v3.3.1

03 Aug 07:39
Compare
Choose a tag to compare
  • Revert "feat: remove uniqueness from sequelize storage (#602)" e849968 (see #614)

Amended release notes from 3.3.0 (and comparison with v3.2.1):

What's Changed

v3.3.0...v3.3.1

v3.3.0

02 Aug 14:44
Compare
Choose a tag to compare

⚠️ ⚠️ ⚠️ This version is deprecated, please use 3.3.1 - but note that #602 was reverted and is not included in 3.3.1 ⚠️ ⚠️ ⚠️

Original release notes ## What's Changed * Fix false positive Confusing Ordering warning by @rpominov in https://github.com//pull/575 * async template function by @ccamensuli in https://github.com//pull/591 * Fix typo in readme by @sdepold in https://github.com//pull/604 * feat: remove uniqueness from sequelize storage by @mau31415 in https://github.com//pull/602

New Contributors

Full Changelog: v3.2.1...v3.3.0

v3.2.1

13 Aug 09:11
Compare
Choose a tag to compare

What's Changed

  • fix: verify pending correctly for custom templates by @mmkal in #565

Full Changelog: v3.2.0...v3.2.1

v3.2.0

12 Aug 18:15
Compare
Choose a tag to compare

What's Changed

  • refactor(sequelize): syncModel() by @mmkal in #564

Full Changelog: v3.1.2...v3.2.0

v3.1.2

12 Aug 17:55
Compare
Choose a tag to compare

What's Changed

  • chore(deps): bump moment from 2.29.1 to 2.29.2 by @dependabot in #552
  • chore: bump dependencies (incl pony-cause -> v2.1.2) by @mmkal in #562 (see #561)

Full Changelog: v3.1.1...v3.1.2

v3.1.1

02 Apr 15:01
Compare
Choose a tag to compare

v3.1.0...v3.1.1

v3.1.0

26 Mar 22:03
Compare
Choose a tag to compare

What's Changed

See #545

Full Changelog: v3.0.0...v3.1.0

v3.0.0

17 Dec 13:00
Compare
Choose a tag to compare

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 MigrationMeta type, which is returned by umzug.executed() and umzug.pending(), no longer has a file property - it has a name and optional path - since migrations are not necessarily bound to files on the file system.

The migrations.glob parameter replaces path, pattern and traverseDirectories. It can be used, in combination with cwd and ignore to do much more flexible file lookups. See https://npmjs.com/package/glob for more information on the syntax.

The migrations.resolve parameter replaces customResolver. Explicit support for wrap and nameFormatter has been removed - these can be easily implemented in a resolve function.

The constructor option logging is replaced by logger to allow for warn and error messages in future. NodeJS's global console object can be passed to this. To disable logging, replace logging: false with logger: undefined.

Breaking change to storages: remove string parameter (#429) b6414ba

  • Custom storage implementations must update logMigration(name) { ... } to logMigration({ name }) { ...}. Likewise with unlogMigration. This is to allow receiving context and path properties in the same arg object.
    Note that this may break external storage implementations too. To adapt, you can just modify or extend the logMigration and unlogMigration implementations (something like logMigration: ({ name }) => oldStorage.logMigration(name)).

Events have moved from the default nodejs EventEmitter to 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:

umzug.on('migrating', (name, m) => console.log({ name, path: m.path }))

After:

umzug.on('migrating', ev => console.log({ name: ev.name, path: ev.path }))

The Umzug#execute method is removed. Use Umzug#up or Umzug#down.

The options for Umguz#up and Umzug#down have changed:

  • umzug.up({ to: 'some-name' }) and umzug.down({ to: 'some-name' }) are still valid.
  • umzug.up({ from: '...' }) and umzug.down({ from: '...' }) are no longer supported. To run migrations out-of-order (which is not generally recommended), you can explicitly use umzug.up({ migrations: ['...'] }) and umzug.down({ migrations: ['...'] }).
  • name matches must be exact. umzug.up({ to: 'some-n' }) will no longer match a migration called some-name.
  • umzug.down({ to: 0 }) is still valid but umzug.up({ to: 0 }) is not.
  • umzug.up({ migrations: ['m1', 'm2'] }) is still valid but the shorthand umzug.up(['m1', 'm2']) has been removed.
  • umzug.down({ migrations: ['m1', 'm2'] }) is still valid but the shorthand umzug.down(['m1', 'm2']) has been removed.
  • umzug.up({ migrations: ['m1', 'already-run'] }) will throw an error, if already-run is not found in the list of pending migrations.
  • umzug.down({ migrations: ['m1', 'has-not-been-run'] }) will throw an error, if has-not-been-run is not found in the list of executed migrations.
  • umzug.up({ migrations: ['m1', 'm2'], rerun: 'ALLOW' }) will re-apply migrations m1 and m2 even if they've already been run.
  • umzug.up({ migrations: ['m1', 'm2'], rerun: 'SKIP' }) will skip migrations m1 and m2 if they've already been run.
  • umzug.down({ migrations: ['m1', 'm2'], rerun: 'ALLOW' }) will "revert" migrations m1 and m2 even if they've never been run.
  • umzug.down({ migrations: ['m1', 'm2'], rerun: 'SKIP' }) will skip reverting migrations m1 and m2 if 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 not rerun: 'ALLOW' is added.

The context parameter replaces params, and is passed in as a property to migration functions as an options object, alongs side name and path. 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 resolve function can also be used to upgrade your umzug version to v3 when you have existing v2-compatible migrations:

const { Umzug } = require('umzug');

const umzug = new Umzug({
  migrations: {
    glob: 'migrations/umzug-v2-format/*.js',
    resolve: ({name, path, context}) => {
      // Adjust the migration from the new signature to the v2 signature, making easier to upgrade to v3
      const migration = require(path)
      return { name, up: async () => migration.up(context), down: async () => migration.down(context) }
    }
  },
  context: sequelize.getQueryInterface(),
  logger: console,
});

Similarly, you no longer need migrationSorting, you can instantiate a new Umzug instance to manipulate migration lists directly:

const { Umzug } = require('umzug');

const parent = new Umzug({
  migrations: { glob: 'migrations/**/*.js' },
  context: sequelize.getQueryInterface(),
})

const umzug = new Umzug({
  ...parent.options,
  migrations: ctx => (await parent.migrations()).sort((a, b) => b.path.localeCompare(a.path))
})

👇 full, generated changelog

What's Changed

Read more

v3.0.0-beta-cli.18

16 Dec 02:58
Compare
Choose a tag to compare
v3.0.0-beta-cli.18 Pre-release
Pre-release
  • Create post-release.yml 7448d3f
  • Sequelize v6 (#527) ca2db34
  • Separate lint dependencies (#526) 0bea5d1
  • rm yarn.lock e0cb83d
  • chore(deps): update devdependencies (major) (#432) e5a511a
  • chore(deps): update devdependencies (#446) ec2c572
  • chore(deps): update dependency json-schema to 0.4.0 [security] (#524) b9dd193
  • Remove .extend(...) in favour of constructor (#523) 2911d20
  • fix(deps): update dependency type-fest to v2 (#517) 20b769d
  • chore(deps): update codecov/codecov-action action to v2 (#515) fbec984
  • Create FUNDING.yml 47aa6b2
  • fix(deps): update dependency emittery to ^0.10.0 (#481) f749e5e
  • Bump sqlite3 version to avoid node-gyp error (#516) 457d57b
  • Drop support for node <12 (#511) 555f481
  • chore(deps): update dependency sequelize to v5.22.4 (#448) e1cec9c
  • chore(deps): update dependency ansi-regex to 5.0.1 [security] (#510) dcc8fc5
  • chore(deps): update dependency path-parse to 1.0.7 [security] (#508) ac43ae9
  • Update umzug.mjs (#509) e739e1f
  • Add documentation for configuring Umzug migration parameters (#493) f7d4692
  • chore(deps): update dependency tmpl to 1.0.5 [security] (#506) 946e496
  • fix #491. replace removeOne with deleteOne (#492) cd7a1ad
  • docs: fix code example (#489) db34970

v3.0.0-beta-cli.17...v3.0.0-beta-cli.18

v3.0.0-beta.16

23 May 22:54
Compare
Choose a tag to compare
v3.0.0-beta.16 Pre-release
Pre-release
  • fix(deps): update dependency type-fest to v1 (#463) f7226db
  • Add ability to retrieve context asynchronously before the migrations run (#453) ea214fd
  • Fix create migration command docs (#449) cd6a604

v3.0.0-beta.15...v3.0.0-beta.16