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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const umzug = new Umzug({
// The name of the negative method in migrations.
downName: 'down',

// (advanced) you can pass an array of Migration instances instead of the options below
// (advanced) you can pass an array of migrations built with `migrationsList()` instead of the options below
migrations: {
// The params that gets passed to the migrations.
// Might be an array or a synchronous function which returns an array.
Expand Down Expand Up @@ -262,6 +262,10 @@ await umzug.down(['20141101203500-task', '20141101203501-task-2'])

### Migrations

There are two ways to specify migrations.

#### Migration files

A migration file ideally exposes an `up` and a `down` async functions. They will perform the task of upgrading or downgrading the database.

```js
Expand All @@ -276,6 +280,28 @@ module.exports = {
};
```

Migration files should be located in the same directory, according to the info you gave to the `Umzug` constructor.

#### Direct migrations list

You can also specify directly a list of migrations to the `Umzug` constructor. We recommend the usage of the `Umzug.migrationsList()` function
as bellow:

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

### Storages

Storages define where the migration data is stored.
Expand Down
Loading