export default (sequelize, DataTypes) => {
  const AuditLog = sequelize.define("AuditLog", {
    userId: {
      type: DataTypes.UUID,
      allowNull: true, // Null if system action or unauthenticated
    },
    userType: {
      type: DataTypes.ENUM("admin", "merchant", "system"),
      allowNull: false,
    },
    action: {
      type: DataTypes.STRING,
      allowNull: false, // e.g., "UPDATE_FEE", "REGENERATE_KEYS"
    },
    details: {
      type: DataTypes.TEXT, // JSON stringified details
      allowNull: true,
    },
    ipAddress: {
      type: DataTypes.STRING,
      allowNull: true,
    },
  }, {
    tableName: "AuditLogs",
    timestamps: true,
  });

  return AuditLog;
};
