import { AutoIncrement, Column, CreatedAt, DataType, Min, Model, PrimaryKey, Table, UpdatedAt } from "sequelize-typescript";
import { VISIBILITY } from "../types/common.types";

@Table({
    tableName: 'channel',
    timestamps: true,
    paranoid: true,
})
export default class Channel extends Model<Channel> {
    @PrimaryKey
    @AutoIncrement
    @Column({
        type: DataType.INTEGER({ length: 11 }),
    })
    id!: number;

    @Column({
        type: DataType.STRING({ length: 100 }),
        allowNull:false,
    })
    name !: string;

    @Column({
        type: DataType.STRING({ length: 255 }),
        allowNull: true
    })
    logo !: string;

    @Column({
        type: DataType.STRING({ length: 255 }),
        allowNull: true
    })
    banner !: string;

    @Column({
        type: DataType.INTEGER({ length: 11 }),
        allowNull: true
    })
    category_id !: number;

    @Column({
        type: DataType.INTEGER({ length: 3 }),
        validate : {
            min:0,
            max : 999,
        },
        defaultValue : 0
    })
    rank !: number;

    @Column({
        type: DataType.ENUM(...Object.values(VISIBILITY)),
        defaultValue : VISIBILITY.VISIBLE
    })
    status !: VISIBILITY;
}