Files
outline/server/migrations/20160626175224-add-revisions.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

67 lines
1.5 KiB
JavaScript

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("revisions", {
id: {
type: "UUID",
allowNull: false,
primaryKey: true,
},
title: {
type: "CHARACTER VARYING",
allowNull: false,
},
text: {
type: "TEXT",
allowNull: true,
},
html: {
type: "TEXT",
allowNull: true,
},
preview: {
type: "TEXT",
allowNull: true,
},
createdAt: {
type: "TIMESTAMP WITH TIME ZONE",
allowNull: false,
},
updatedAt: {
type: "TIMESTAMP WITH TIME ZONE",
allowNull: false,
},
userId: {
type: "UUID",
allowNull: false,
references: {
model: "users",
},
},
documentId: {
type: "UUID",
allowNull: false,
references: {
model: "documents",
onDelete: "CASCADE",
},
},
});
await queryInterface.addColumn("documents", "lastModifiedById", {
type: "UUID",
allowNull: false,
references: {
model: "users",
},
});
await queryInterface.addColumn("documents", "revisionCount", {
type: "INTEGER",
defaultValue: 0,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("revisions");
await queryInterface.removeColumn("documents", "lastModifiedById");
await queryInterface.removeColumn("documents", "revisionCount");
},
};