import { BelongsTo, Column, CreatedAt, DataType, DeletedAt, ForeignKey, Index, Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript';
import { InstanceDAO } from '../../../../instances/infrastructure/dataAccessObjects/instanceDAO';
import { ShiftRotationDayDAO } from './shiftRotationDay';

export interface ShiftRotationDayShiftDAOCreationFields {
    id: string;
    instanceId: number;
    shiftRotationDayId: string;
    shiftCode: string;
}

@Table({ tableName: 'ShiftRotationDayShifts' })
export class ShiftRotationDayShiftDAO extends Model<ShiftRotationDayShiftDAO, ShiftRotationDayShiftDAOCreationFields> {
    @PrimaryKey
    @Column(DataType.UUID)
    id!: string;

    @Index('ShiftRotationDayShifts_instanceId_index')
    @ForeignKey(() => InstanceDAO)
    @Column
    instanceId!: number;

    @Index('ShiftRotationDayShifts_shiftRotationDayId_index')
    @ForeignKey(() => ShiftRotationDayDAO)
    @Column(DataType.UUID)
    shiftRotationDayId!: string;

    @Index('ShiftRotationDayShifts_shiftCode_index')
    @Column(DataType.STRING)
    shiftCode!: string;

    @BelongsTo(() => ShiftRotationDayDAO)
    day!: ShiftRotationDayDAO;

    @CreatedAt
    @Column(DataType.DATE)
    createdAt!: Date;

    @UpdatedAt
    @Column(DataType.DATE)
    updatedAt!: Date;

    @DeletedAt
    @Column(DataType.DATE)
    deletedAt!: Date | null;
}
