Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional files in migrations folder #145

Open
saveman71 opened this issue Jan 25, 2019 · 7 comments
Open

Additional files in migrations folder #145

saveman71 opened this issue Jan 25, 2019 · 7 comments

Comments

@saveman71
Copy link

saveman71 commented Jan 25, 2019

I'm currently "migrating" (🥁) our migrate installation from 0.1.6 to the latest. I have some helpers files (e.g. migrations/helpers.js that is required in almost every migration I create.

However it seems it's trying to use helpers.js as a migration file now (Migration helpers.js does not have method up), whereas this file was ignored before.

It seems this use case is confirmed to be possible in the README:

node-migrate/Readme.md

Lines 84 to 88 in ee1df14

```javascript
// db is just an object shared between the migrations
var db = require('./db');
exports.up = function (next) {

What's the best way of fixing that?

Additionally I would also like to ignore all files in a subfolder (they seemed to be ignored previously as well)

@wesleytodd
Copy link
Collaborator

Yep this is one of the breaking changes. If you want to have other things in your migrations directory now you need to provide a filter function. This isn't well documented at the moment, but you would need to use the js api and wrap it in your own cli, as the filter is not currently exposed on the cli.

I think the best way is to move the extraneous stuff out of your migrations directory. Either that or submit a PR to expose the filter on the cli :) 🤞

@saveman71
Copy link
Author

I agree moving them out seems like the better option. However I still think the doc (snippet I ref'd in #145 (comment)) is a bit misleading on that, as it seems it still should be possible without any further configuration.

Also, the breaking change wasn't mentioned in History.md :)

(no reproach at all btw, congrats on maintaining this properly already and answering this that fast 👏)

I might make a PR later in the week for these documentation fixes. If I don't do it feel free to go ahead!

@wesleytodd
Copy link
Collaborator

Hey @saveman71, no ill will taken! I changed so much in the 1.0 I am sure I missed some things in the history, which is why OSS and team work is great! A PR will be very welcome, but please be patient with me now because between my comment 6 days ago and yours 3 days ago I had a baby daughter (👶!!!) so will be a bit disconnected.

If you make a PR for the docs it would be great to also update the history file. Thanks!

@gustavopch
Copy link

If I understand correctly the issue, the desired feature already exists in the CLI as an option called matches.

migrate up --matches '^\d+-[\w-]+.js$'

See: https://github.com/tj/node-migrate/blob/master/bin/migrate-up#L25

@mkovel
Copy link

mkovel commented Mar 31, 2020

@gustavopch Unfortunately --matches logic was implemented base on minimatch and do not support full Regexp only glob and this example does not work
If i wrong, please let me know.

@monooso
Copy link

monooso commented Jul 3, 2020

@gustavopch / @mkovel The --matches flag will suffice if you place all of your "helper" files in a sub-directory. For example:

migrate up --matches '!helpers'

@mkovel
Copy link

mkovel commented Aug 18, 2020

@gustavopch / @mkovel The --matches flag will suffice if you place all of your "helper" files in a sub-directory. For example:

migrate up --matches '!helpers'

good point. tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants