Plugin for the serverless framework to run DynamoDB migrations using umzug.
npm install --save serverless-plugin-umzug
Enable the plugin:
plugins:
- serverless-plugin-additional-stacks
By default, the plugin will create a DynamoDB table called migrations
. This
can be overidden by providing a custom configuration:
custom:
umzug:
tablename: my-migrations-table
$ serverless migrations pending
No pending migrations
Create a new file under migrations/
with a timestamp prefix, e.g.:
migrations/2019-06-05-15-39-04-dummy-migration.js
module.exports = {
up: function () {
// Describe how to achieve the task.
return Promise.resolve();
},
down: function () {
// Describe how to revert the task.
return Promise.resolve();
},
};
$ serverless migrations pending
Pending migrations
--------------------------------------
2019-06-05-15-39-04-dummy-migration.js
$ serverless migrations up
..
Executed 'up' of 1 migrations
--------------------------------------
2019-06-05-15-39-04-dummy-migration.js
$ serverless migrations history
Executed migrations
--------------------------------------
2019-06-05-15-39-04-dummy-migration.js
$ serverless migrations down
...
Executed 'down' of 1 migrations
--------------------------------------
2019-06-05-15-39-04-dummy-migration.js