38216-vm/backend/src/db/models/feature_flags.js
2026-02-05 14:14:42 +00:00

134 lines
1.7 KiB
JavaScript

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 feature_flags = sequelize.define(
'feature_flags',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
key: {
type: DataTypes.TEXT,
},
enabled: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
value_json: {
type: DataTypes.TEXT,
},
created_at_time: {
type: DataTypes.DATE,
},
updated_at_time: {
type: DataTypes.DATE,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
feature_flags.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.feature_flags.belongsTo(db.trainer_profiles, {
as: 'trainer_profile',
foreignKey: {
name: 'trainer_profileId',
},
constraints: false,
});
db.feature_flags.belongsTo(db.organizations, {
as: 'organizations',
foreignKey: {
name: 'organizationsId',
},
constraints: false,
});
db.feature_flags.belongsTo(db.users, {
as: 'createdBy',
});
db.feature_flags.belongsTo(db.users, {
as: 'updatedBy',
});
};
return feature_flags;
};