const config = require('../../config'); const providers = config.providers; const crypto = require('crypto'); const bcrypt = require('bcrypt'); const moment = require('moment'); module.exports = function(sequelize, DataTypes) { const environment_variables = sequelize.define( 'environment_variables', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, var_name: { type: DataTypes.TEXT, }, var_value: { type: DataTypes.TEXT, }, value_hash: { type: DataTypes.TEXT, }, value_type: { type: DataTypes.ENUM, values: [ "string", "number", "json", "path", "url", "unknown" ], }, is_present: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, }, importHash: { type: DataTypes.STRING(255), allowNull: true, unique: true, }, }, { timestamps: true, paranoid: true, freezeTableName: true, }, ); environment_variables.associate = (db) => { /// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity //end loop db.environment_variables.belongsTo(db.environment_snapshots, { as: 'snapshot', foreignKey: { name: 'snapshotId', }, constraints: false, }); db.environment_variables.belongsTo(db.users, { as: 'createdBy', }); db.environment_variables.belongsTo(db.users, { as: 'updatedBy', }); }; return environment_variables; };