db-migrate/node-db-migrate

Scoped migration not running from scoped directory

joezappie opened this issue · 3 comments

I'm submitting a...

  • Bug report
  • Feature request
  • Question

Current behavior

When trying to use scopes, its not finding the migration files in the scoped directory and is instead running files in the ./migrations folder. This happens with both the CLI and through the API.

Expected behavior

Migrations should be run in the scoped folder.

Minimal reproduction of the problem with instructions

db-migrate create:client_1 users
// migrations/client_1/20211010214023-users.js created successfully

db-migrate up:client_1
// [migration] Nothing to run

db-migrate create users
// migrations/20211010215341-user.js created successfully

db-migrate up:client_1
// runs migrations/20211010215341-user

Looking at the code in walker.js up function, its loading the files from the filesystem with File.loadFromFileystem(this.directory, this.prefix, this.internals). "this.directory" is a path to only the migrations directory which I imagine should have the scoped folder name there as well.

Environment

Windows 10
Node v14.16.0
db-migrate: 1.0.0-beta.16
db-migrate-mongodb: 1.5.0

Looking at up.js it appears that migrator.migrationsDir is correct with the scoped directory.

Changing walker.js to File.loadFromFileystem(this.migrationsDir, this.prefix, this.internals) makes it work. This would have to be changed in a lot of places, but is correct?

We found the same problem (in 1.0.0-beta.16, like the OP) - scoped migrations no longer work, it re-runs the migrations at the root for every scoped invocation. We've reverted to 0.11.6 to be able to use this again. We're using MySQL

I've noticed this issue too and it was introduced in version 0.11.12. Unfortunately, this version only seems to be pinned at npm and not listed as a release here?