import { Model, Table, Column, BelongsToMany, CreatedAt, UpdatedAt, DataType, ForeignKey, BeforeCreate } from "sequelize-typescript"; import { CronLog } from "./CronLog"; import { v4 as uuidv4 } from 'uuid'; @Table({ tableName: "OrderLogs"}) export class OrderLog extends Model { @Column({ primaryKey: true }) id: string; @ForeignKey(() => CronLog) @Column cronLogId: string; @Column orderId: string; @Column shop: string; @Column type: string; @Column status: string; @Column(DataType.TEXT) message: string; @CreatedAt createdAt: Date; @UpdatedAt updatedAt: Date; @BeforeCreate static generateGuid(instance) { if (!instance.id) { instance.id = uuidv4(); } } }