Mailspring/migrations/01-expirationDate-metadata.es6
Karim Hamidou e55c36a79a [cloud-api] Add support for database migrations
Summary:
This diff adds support for database migration to our cloud API. It's partially inspired by Halla's local-sync migration diff (D3809). You can run a migration by calling "node-babel scripts/migrate-db up|down" or by calling "npm script upgrade-db|downgrade-db".

Note that for simplicity reasons we assume that we're only writing migrations for our MySQL database – people developing locally may have to blow up there dbs whenever there's a schema change, though in practice `ALTER TABLE ADD COLUMN`statements work the same on both dbs.

Test Plan: Tested locally. Will run the metadata migration on staging.

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D3840
2017-02-06 13:38:59 -08:00

11 lines
395 B
JavaScript

module.exports = {
up: async (queryInterface, Sequelize) => {
const {sequelize} = queryInterface;
console.log("querying db");
await sequelize.query("ALTER TABLE metadata ADD COLUMN `expiration` DATETIME");
},
down: async (queryInterface, Sequelize) => {
const {sequelize} = queryInterface;
await sequelize.query("ALTER TABLE metadata DROP COLUMN `expiration`");
},
}