Files
pp-tcms/backend/migrations/20240316201158-create-cases-attachments.js
2024-03-16 21:14:59 +09:00

49 lines
1.1 KiB
JavaScript

"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("caseAttachments", {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: "cases",
key: "id",
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
},
attachmentId: {
type: Sequelize.INTEGER,
references: {
model: "attachments",
key: "id",
},
onUpdate: "CASCADE",
onDelete: "CASCADE",
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex("caseAttachments", ["caseId", "attachmentId"], {
unique: true,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable("caseAttachments");
},
};