Files
outline/server/migrations/20181124000438-add-notifications.js
Tom Moor 15b1069bcc chore: Move to Typescript (#2783)
This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously.

closes #1282
2021-11-29 06:40:55 -08:00

78 lines
1.8 KiB
JavaScript

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("notifications", {
id: {
type: Sequelize.UUID,
allowNull: false,
primaryKey: true,
},
actorId: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "users",
},
},
userId: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "users",
},
},
event: {
type: Sequelize.STRING,
},
email: {
type: Sequelize.BOOLEAN,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.createTable("notification_settings", {
id: {
type: Sequelize.UUID,
allowNull: false,
primaryKey: true,
},
userId: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "users",
},
},
teamId: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "teams",
},
},
event: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex("notification_settings", [
"teamId",
"userId",
]);
await queryInterface.addIndex("notification_settings", ["event"]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("notifications");
await queryInterface.dropTable("notification_settings");
await queryInterface.removeIndex("notification_settings", [
"teamId",
"userId",
]);
await queryInterface.removeIndex("notification_settings", ["event"]);
},
};