mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
/** Per-booking clearance action history — drives the History tab. */
|
|
export class BookingClearanceEvent3600000000000 implements MigrationInterface {
|
|
name = 'BookingClearanceEvent3600000000000';
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`
|
|
CREATE TABLE IF NOT EXISTS "freight"."booking_clearance_event" (
|
|
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
"deleted_at" timestamptz,
|
|
"booking_id" uuid NOT NULL,
|
|
"action" character varying(64) NOT NULL,
|
|
"label" character varying(500) NOT NULL,
|
|
"actor_type" character varying(16) NOT NULL DEFAULT 'STAFF',
|
|
"actor_id" uuid,
|
|
"actor_name" character varying(150),
|
|
"metadata" jsonb,
|
|
CONSTRAINT "pk_booking_clearance_event" PRIMARY KEY ("id"),
|
|
CONSTRAINT "fk_booking_clearance_event_booking" FOREIGN KEY ("booking_id")
|
|
REFERENCES "freight"."bookings"("id") ON DELETE CASCADE
|
|
)
|
|
`);
|
|
await queryRunner.query(`
|
|
CREATE INDEX IF NOT EXISTS "idx_booking_clearance_event_booking_created"
|
|
ON "freight"."booking_clearance_event" ("booking_id", "created_at")
|
|
`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(
|
|
`DROP TABLE IF EXISTS "freight"."booking_clearance_event"`,
|
|
);
|
|
}
|
|
}
|