Files
outline/server/migrations/20170604052346-add-views.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

40 lines
951 B
JavaScript

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("views", {
id: {
type: Sequelize.UUID,
allowNull: false,
primaryKey: true,
},
documentId: {
type: Sequelize.UUID,
allowNull: false,
},
userId: {
type: Sequelize.UUID,
allowNull: false,
},
count: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 1,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex("views", ["documentId", "userId"], {
indicesType: "UNIQUE",
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.removeIndex("views", ["documentId", "userId"]);
await queryInterface.dropTable("views");
},
};