56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
|
|
module.exports = function(sequelize, DataTypes) {
|
|
const retailer_programs = sequelize.define(
|
|
'retailer_programs',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
name: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: false,
|
|
},
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
retailer_programs.associate = (db) => {
|
|
db.retailer_programs.belongsTo(db.tenants, {
|
|
as: 'tenant',
|
|
foreignKey: {
|
|
name: 'tenantId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.retailer_programs.belongsTo(db.organizations, {
|
|
as: 'organizations',
|
|
foreignKey: {
|
|
name: 'organizationsId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.retailer_programs.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.retailer_programs.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
return retailer_programs;
|
|
};
|