Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yadhap/integration seeder #703

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions server/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ require('dotenv').config({ path: ENVPath});

const logger = require('./logger');
const dbConfigOptions = {
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
host: process.env.DB_HOSTNAME,
dialect: 'mysql',
seederStorage: 'json',
logging: (msg) => logger.debug(msg), // change winston settings to 'debug' to see this log
}
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
host: process.env.DB_HOSTNAME,
dialect: "mysql",
seedStorage: "sequelize",
logging: (msg) => logger.debug(msg), // change winston settings to 'debug' to see this log
};

if(process.env.MYSQL_SSL_ENABLED === "true"){
dbConfigOptions.ssl = true;
Expand Down
17 changes: 6 additions & 11 deletions server/migrations/20230907145012-create-integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@ module.exports = {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
},
application_id: {
type: Sequelize.UUID,
},
name: {
allowNull: false,
unique: true,
type: Sequelize.STRING,
},
description: {
allowNull: false,
unique: true,
type: Sequelize.STRING,
},
active: {
type: Sequelize.BOOLEAN,
},
config: {
type: Sequelize.JSON,
},
metaData: {
type: Sequelize.JSON,
metaData:{
allowNull: true,
type: Sequelize.JSON,
},
createdAt: {
allowNull: false,
Expand Down
24 changes: 0 additions & 24 deletions server/migrations/20240301202952-remove_integration_columns.js

This file was deleted.

1 change: 1 addition & 0 deletions server/models/integration_mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = (sequelize, DataTypes) => {
{ freezeTableName: true }
);

// Association to integrations and application
IntegrationMapping.associate = (models) => {
IntegrationMapping.belongsTo(models.integrations, {
foreignKey: "integration_id",
Expand Down
29 changes: 6 additions & 23 deletions server/models/integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,23 @@ module.exports = (sequelize, DataTypes) => {
name: {
allowNull: false,
type: DataTypes.STRING,
unique: false,
unique: true,
},
description: {
allowNull: false,
type: DataTypes.STRING,
unique: false,
},
active: {
allowNull: false,
type: DataTypes.BOOLEAN,
},
config: {
type: DataTypes.JSON,
metaData:{
allowNull: true,
},
metaData: {
type: DataTypes.JSON,
allowNull: true,
},
application_id: {
allowNull: false,
type: DataTypes.UUID,
},
},
{ freezeTableName: true }
);
integrations.associate = function (models) {
// Define association here
integrations.belongsTo(models.application, {
foreignKey: "application_id",
});
integrations.hasMany(models.monitoring_notifications, {
foreignKey: "application_id",
onDelete: "CASCADE",
// Association to integration_mapping
integrations.associate = (models) => {
integrations.hasMany(models.integration_mapping, {
foreignKey: "integration_id",
});
};
return integrations;
Expand Down
21 changes: 21 additions & 0 deletions server/seeders/20240305192508-insert-ASR-integration-details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";
const { v4: uuidv4 } = require("uuid");

module.exports = {
up: async (queryInterface, Sequelize) => {
return queryInterface.bulkInsert("integrations", [
{
id: uuidv4(),
name: "ASR",
description:
"This integration enables ASR-related features in Tombolo and facilitates connections to Orbit servers, enhancing user capabilities and data accessibility",
createdAt: new Date(),
updatedAt: new Date(),
},
]);
},

down: async (queryInterface, Sequelize) => {
return queryInterface.bulkDelete("integrations", null, {});
},
};
Loading