r2
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const AuditLog = sequelize.define('AuditLog', {
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
organizationId: { type: DataTypes.INTEGER },
|
||||
userId: { type: DataTypes.INTEGER },
|
||||
userRole: { type: DataTypes.STRING },
|
||||
action: { type: DataTypes.STRING, allowNull: false },
|
||||
entityType: { type: DataTypes.STRING },
|
||||
entityId: { type: DataTypes.INTEGER },
|
||||
details: {
|
||||
type: DataTypes.TEXT,
|
||||
get() { try { return JSON.parse(this.getDataValue('details') || '{}'); } catch { return {}; } },
|
||||
set(v) { this.setDataValue('details', JSON.stringify(v)); },
|
||||
},
|
||||
ipAddress: { type: DataTypes.STRING },
|
||||
userAgent: { type: DataTypes.STRING },
|
||||
}, {
|
||||
updatedAt: false,
|
||||
createdAt: 'createdAt',
|
||||
});
|
||||
|
||||
return { AuditLog };
|
||||
};
|
||||
Reference in New Issue
Block a user