import {
  AllowNull,
  BelongsTo,
  Column,
  DataType,
  Default,
  ForeignKey,
  Table,
} from "sequelize-typescript";
import { TimestampModel } from "src/database/models/timestamp.model";
import { User } from "./user.model";

@Table({ timestamps: true, tableName: "user_verifications" })
export class UserVerification extends TimestampModel {
  @ForeignKey(() => User)
  @Column({ field: "user_id" })
  userId: number;

  @AllowNull(false)
  @Column(DataType.ENUM("Email","Phone"))
  type: string;

  @AllowNull(true)
  @Column({ field: "phone_number" })
  phoneNumber: string;

  @AllowNull(true)
  @Column
  email: string;

  @AllowNull(false)
  @Column
  token: string;

  @AllowNull(false)
  @Column({ field: "expired_at" })
  expiredAt: Date;

  @BelongsTo(() => User)
  user: User;
}
