module.exports = (sequelize, DataTypes) => {
  const { UUID, UUIDV4, STRING, DATE, INTEGER } = DataTypes;
  const OTP = sequelize.define(
    'OTP',
    {
      id: {
        type: UUID,
        defaultValue: UUIDV4,
        allowNull: false,
        primaryKey: true,
      },
      otp: {
        type: STRING,
        allowNull: false,
      },
      email_or_phone: {
        type: STRING,
        allowNull: false,
      },
      expiry: {
        type: DATE,
        allowNull: false,
      },
      attempts: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
      },
    },
    {
      tableName: 'otps',
      timestamps: false,
    },
  );

  return OTP;
};
