module.exports = function(sequelize, DataTypes) {
  const reminders = sequelize.define(
    "coaching_reminder_deliveries",
    {
      id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
      clientId: { type: DataTypes.UUID, allowNull: false },
      session_at: { type: DataTypes.DATE, allowNull: false },
      scheduled_for: { type: DataTypes.DATE, allowNull: false },
      status: { type: DataTypes.STRING(16), allowNull: false, defaultValue: "ready" },
      dismissed_at: { type: DataTypes.DATE },
    },
    { timestamps: true, freezeTableName: true },
  );

  reminders.associate = (db) => {
    db.coaching_reminder_deliveries.belongsTo(db.clients, { as: "client", foreignKey: "clientId", constraints: false });
  };

  return reminders;
};
