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

Added migrationsList helper to easily build a valid list of migrations #199

Merged
merged 4 commits into from
Mar 17, 2020

Conversation

nicolas-van
Copy link
Contributor

@nicolas-van nicolas-van commented Mar 6, 2020

Hello,

This PR brings a solution to a problem that has already been reported, notably in this issue: #184 . This older PR also attempts to bring a solution for that: #188 .

This issue is that the documentation specifies that it is possible to avoid using an automatic file loader for migrations and to specify a list of migrations instead. (Notable use case where we need to do this is when we use Webpack, where a file loader usually won't work as expected.) Unfortunately this is not particularly easy to do. The Migration class is not exposed in the index.js file and, even by importing it anyway, it's still not easy to use because it is very oriented toward that migration-file-loading behavior.

This PR simply adds an utility function named migrationsList() that allow to specify a list of migrations this way:

const umzug = new Umzug({
  migrations: Umzug.migrationsList([
    {
      name: '00-first-migration',
      up: ...,
      down: ...
    }
  ], 
  // a facultative list of parameters that will be sent to the `up` and `down` functions
  [sequelize.getQueryInterface()])
})

I added a test and documented the feature.

@sushantdhiman sushantdhiman merged commit 9022d4c into sequelize:master Mar 17, 2020
@nicolas-van
Copy link
Contributor Author

Thank you.

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

Successfully merging this pull request may close these issues.

2 participants