-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend routes, models and and migration files for integration_mapping (
#702) * backend routes, models and and migration files for integration_mapping * update integration.js * update integration_mapping * remove integration creation * add error messages, validation, and testing to all routes * remove lines
- Loading branch information
Showing
13 changed files
with
362 additions
and
671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
server/migrations/20240301202952-remove_integration_columns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.removeColumn("integrations", "config"); | ||
await queryInterface.removeColumn("integrations", "metadata"); | ||
await queryInterface.removeColumn("integrations", "active"); | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
await queryInterface.addColumn("integrations", "config", { | ||
type: Sequelize.STRING, | ||
allowNull: true, | ||
}); | ||
await queryInterface.addColumn("integrations", "metadata", { | ||
type: Sequelize.STRING, | ||
allowNull: true, | ||
}); | ||
await queryInterface.addColumn("integrations", "active", { | ||
type: Sequelize.BOOLEAN, | ||
defaultValue: true, | ||
}); | ||
}, | ||
}; |
49 changes: 49 additions & 0 deletions
49
server/migrations/20240301203455-create_integration_application_mapping.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use strict"; | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable("integration_mapping", { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
defaultValue: Sequelize.UUIDV4, | ||
}, | ||
integration_id: { | ||
type: Sequelize.UUID, | ||
references: { | ||
model: "integrations", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
application_id: { | ||
type: Sequelize.UUID, | ||
references: { | ||
model: "application", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
metaData: { | ||
type: Sequelize.JSON, | ||
allowNull: true, | ||
}, | ||
createdAt: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.NOW, | ||
}, | ||
updatedAt: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.NOW, | ||
}, | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable("integration_mapping"); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
Oops, something went wrong.