create attachment file table
This commit is contained in:
27
backend/models/caseAttachments.js
Normal file
27
backend/models/caseAttachments.js
Normal 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;
|
||||
Reference in New Issue
Block a user