export default (sequelize, DataTypes) => {
  const EmailTemplate = sequelize.define("EmailTemplate", {
    id: {
      type: DataTypes.UUID,
      defaultValue: DataTypes.UUIDV4,
      primaryKey: true,
    },
    slug: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: true,
      comment: "Unique identifier like 'merchant_welcome'",
    },
    name: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: "Human readable name",
    },
    subject: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    bodyHtml: {
      type: DataTypes.TEXT("long"),
      allowNull: false,
      comment: "HTML body content. Variables can be interpolated using {{variableName}}",
    },
    availableVariables: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: "Comma separated list of available variables, e.g., '{{businessName}}, {{otp}}'",
    },
  }, {
    tableName: "EmailTemplates",
    timestamps: true,
  });

  return EmailTemplate;
};
