From a0343d3b6526f2897b1669df6319fa66d4e8004d Mon Sep 17 00:00:00 2001 From: Matt Fancher <142915944+FancMa01@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:36:18 -0700 Subject: [PATCH] update integration_mapping --- server/models/integration_mapping.js | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/server/models/integration_mapping.js b/server/models/integration_mapping.js index e69de29bb..7d06447e9 100644 --- a/server/models/integration_mapping.js +++ b/server/models/integration_mapping.js @@ -0,0 +1,58 @@ +"use strict"; +module.exports = (sequelize, DataTypes) => { + const IntegrationMapping = sequelize.define( + "integration_mapping", + { + id: { + type: DataTypes.UUID, + primaryKey: true, + defaultValue: DataTypes.UUIDV4, + allowNull: false, + }, + integration_id: { + type: DataTypes.UUID, + references: { + model: "integrations", + key: "id", + }, + onUpdate: "CASCADE", + onDelete: "CASCADE", + }, + application_id: { + type: DataTypes.UUID, + references: { + model: "application", + key: "id", + }, + onUpdate: "CASCADE", + onDelete: "CASCADE", + }, + metaData: { + type: DataTypes.JSON, + allowNull: true, + }, + createdAt: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: DataTypes.NOW, + }, + updatedAt: { + type: DataTypes.DATE, + allowNull: false, + defaultValue: DataTypes.NOW, + }, + }, + { freezeTableName: true } + ); + + IntegrationMapping.associate = (models) => { + IntegrationMapping.belongsTo(models.integrations, { + foreignKey: "integration_id", + }); + IntegrationMapping.belongsTo(models.application, { + foreignKey: "application_id", + }); + }; + + return IntegrationMapping; +};