mailtrain/server/setup/knex/migrations/20191007120000_add_updated_to_subscriptions.js
Gernot Pansy e2a69ef76d Added subscription changed trigger
Is very useful if some subscription data is updated by API and you want to trigger after that because segments (filters) have changed.
2019-12-03 09:08:40 +01:00

10 lines
446 B
JavaScript

exports.up = (knex, Promise) => (async() => {
const lists = await knex('lists');
for (const list of lists) {
await knex.schema.raw('ALTER TABLE `subscription__' + list.id + '` ADD COLUMN `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `created`');
await knex.schema.raw('CREATE INDEX updated ON `subscription__' + list.id + '` (`updated`)');
}
})();
exports.down = (knex, Promise) => (async() => {
})();