Files
dh-inspeccion-v2/api-v3/src/database/entities/inspection-act-version.entity.ts
T

40 lines
1.1 KiB
TypeScript

import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
export enum InspectionActVersionEvent {
CREATED = 'CREATED',
UPDATED = 'UPDATED',
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;
}