create attachment file table

This commit is contained in:
Takeshi Kimata
2024-03-16 21:14:59 +09:00
parent f5a2eb24fb
commit afb58585fa
12 changed files with 273 additions and 6 deletions

View File

@@ -0,0 +1,27 @@
function defineCaseAttachment(sequelize, DataTypes) {
const CaseAttachment = sequelize.define("CaseAttachment", {
caseId: {
type: DataTypes.INTEGER,
allowNull: false,
},
attachmentId: {
type: DataTypes.INTEGER,
allowNull: false,
},
});
CaseAttachment.associate = (models) => {
CaseAttachment.belongsTo(models.Case, {
foreignKey: "caseId",
onDelete: "CASCADE",
});
CaseAttachment.belongsTo(models.Attachment, {
foreignKey: "attachmentId",
onDelete: "CASCADE",
});
};
return CaseAttachment;
}
module.exports = defineCaseAttachment;