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

Multi dotted migration file extension #421

Open
DocAmaroo opened this issue Dec 15, 2022 · 0 comments
Open

Multi dotted migration file extension #421

DocAmaroo opened this issue Dec 15, 2022 · 0 comments

Comments

@DocAmaroo
Copy link

DocAmaroo commented Dec 15, 2022

Is your feature request related to a problem? Please describe.

I tried to use a multi dotted extension filename in my config, such as:

migrationFileExtension: '.migration.ts',

But the app couldn't retrieve them when using

migrate-mongo status

why ?

It appears this is due to the filter condition returned in migrationDir.getFilenames().

The condition: path.extname(file) === migrationExt will resolve by '.ts' === '.migration.ts' and return false.

Describe the solution you'd like

Maybe this has not been implemented for some purposes, but it would be great if we want to keep consistency in our project filenames or event custom them. Otherwise, I have to manually rename each of my migration file myself.

Describe alternatives you've considered

The simple way, I guess, will be to use a cute reg expression to test if the filename match the migrationExt.

async getFilenames() {
  ...
  const matchExt = (filename) => new RegExp(`.*${migrationExt}$`).test(filename);
  return files.filter(file => matchExt(file) && path.basename(file) !== sampleMigrationFileName).sort();
}

or in one line (which is uglier)

async getFilenames() {
  ...
  return files.filter(file => new RegExp(`.*${migrationExt}$`).test(filename) && path.basename(file) !== sampleMigrationFileName).sort();
}

Additional context
Add any other context or screenshots about the feature request here.

@DocAmaroo DocAmaroo changed the title Custom extension filename Multi dotted migration file extension Dec 15, 2022
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

1 participant