module.exports = function(sequelize, DataTypes) {
  const intake_leads = sequelize.define(
    "intake_leads",
    {
      id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
      name: { type: DataTypes.TEXT },
      email: { type: DataTypes.TEXT },
      company: { type: DataTypes.TEXT },
      role_title: { type: DataTypes.TEXT },
      package_name: { type: DataTypes.TEXT },
      preferred_time: { type: DataTypes.TEXT },
      goal: { type: DataTypes.TEXT },
      challenge: { type: DataTypes.TEXT },
      desired_outcome: { type: DataTypes.TEXT },
      source: { type: DataTypes.TEXT },
      status: { type: DataTypes.ENUM("new", "reviewed", "invited", "converted", "archived"), defaultValue: "new" },
      consent_ai_notes: { type: DataTypes.BOOLEAN, defaultValue: false },
      importHash: { type: DataTypes.STRING(255), allowNull: true, unique: true },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  intake_leads.associate = (db) => {
    db.intake_leads.belongsTo(db.users, { as: "createdBy", constraints: false });
    db.intake_leads.belongsTo(db.users, { as: "updatedBy", constraints: false });
  };

  return intake_leads;
};
