42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
|
|
export enum InspectionActVersionEvent {
|
|
CREATED = 'CREATED',
|
|
UPDATED = 'UPDATED',
|
|
LOCKED = 'LOCKED',
|
|
SEALED = 'SEALED',
|
|
READY = 'READY',
|
|
REOPENED = 'REOPENED',
|
|
CLOSED = 'CLOSED',
|
|
CANCELLED = 'CANCELLED',
|
|
}
|
|
|
|
@Entity({ name: 'inspection_act_versions' })
|
|
@Index('uq_inspection_act_versions_number', ['actId', 'versionNumber'], { unique: true })
|
|
@Index('idx_inspection_act_versions_created_at', ['createdAt'])
|
|
export class InspectionActVersion {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'act_id', type: 'uuid' })
|
|
actId!: string;
|
|
|
|
@Column({ name: 'version_number', type: 'integer' })
|
|
versionNumber!: number;
|
|
|
|
@Column({ type: 'varchar', length: 24 })
|
|
event!: InspectionActVersionEvent;
|
|
|
|
@Column({ type: 'jsonb' })
|
|
snapshot!: Record<string, unknown>;
|
|
|
|
@Column({ name: 'actor_user_id', type: 'uuid', nullable: true })
|
|
actorUserId!: string | null;
|
|
|
|
@Column({ name: 'actor_username', type: 'varchar', length: 80, nullable: true })
|
|
actorUsername!: string | null;
|
|
|
|
@Column({ name: 'created_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
}
|