Skip to content

Commit

Permalink
feat: migrationsList helper to easily build a valid list of migrations (
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-van authored Mar 17, 2020
1 parent ae37f74 commit 9022d4c
Show file tree
Hide file tree
Showing 7 changed files with 1,023 additions and 904 deletions.
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

0 comments on commit 9022d4c

Please sign in to comment.