Files
outline/server/migrations/20170827182423-improve-references.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

56 lines
1.7 KiB
JavaScript

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.changeColumn("documents", "atlasId", {
type: Sequelize.UUID,
allowNull: true,
onDelete: "cascade",
references: {
model: "collections",
},
});
await queryInterface.changeColumn("documents", "userId", {
type: Sequelize.UUID,
allowNull: true,
references: {
model: "users",
},
});
await queryInterface.changeColumn("documents", "parentDocumentId", {
type: Sequelize.UUID,
allowNull: true,
references: {
model: "documents",
},
});
await queryInterface.changeColumn("documents", "teamId", {
type: Sequelize.UUID,
allowNull: true,
onDelete: "cascade",
references: {
model: "teams",
},
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.query(
'ALTER TABLE documents DROP CONSTRAINT "atlasId_foreign_idx";'
);
await queryInterface.removeIndex("documents", "atlasId_foreign_idx");
await queryInterface.sequelize.query(
'ALTER TABLE documents DROP CONSTRAINT "userId_foreign_idx";'
);
await queryInterface.removeIndex("documents", "userId_foreign_idx");
await queryInterface.sequelize.query(
'ALTER TABLE documents DROP CONSTRAINT "parentDocumentId_foreign_idx";'
);
await queryInterface.removeIndex(
"documents",
"parentDocumentId_foreign_idx"
);
await queryInterface.sequelize.query(
'ALTER TABLE documents DROP CONSTRAINT "teamId_foreign_idx";'
);
await queryInterface.removeIndex("documents", "teamId_foreign_idx");
},
};