Kuma/db/knex_migrations/2025-05-11-0000-feat-notification-trigger.js

25 lines
779 B
JavaScript

exports.up = async function (knex) {
await knex.schema.alterTable("notification", function (table) {
table.text("trigger").notNullable().defaultTo("up,down,certificate");
});
await knex("notification").whereNull("trigger").update({
trigger: "up,down,certificate",
});
const notifications = await knex("notification").select("*");
for (let n of notifications) {
await knex("notification").where("id", n.id).update({
config: JSON.stringify({
...JSON.parse(n.config),
trigger: "up,down,certificate",
}),
});
}
};
exports.down = function (knex) {
return knex.schema.alterTable("notification", function (table) {
table.dropColumn("trigger");
});
};