mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 09:58:12 +00:00
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
|
|
/**
|
|
* A train schedule can be dedicated to one shipping line.
|
|
*
|
|
* NULL = a normal train, visible and bookable to customers as before. Set =
|
|
* the departure exists for that shipping line alone: it is excluded from every
|
|
* customer-facing read (booking windows, day pools, portal home cards) and
|
|
* surfaces only in the assigned line's portal (home page + booking detail).
|
|
*/
|
|
export class TrainScheduleShippingLine3510000000000 implements MigrationInterface {
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`
|
|
ALTER TABLE freight.train_schedules
|
|
ADD COLUMN IF NOT EXISTS shipping_line_company_id uuid
|
|
REFERENCES freight.shipping_line_companies (id)
|
|
`);
|
|
await queryRunner.query(`
|
|
CREATE INDEX IF NOT EXISTS idx_train_schedules_shipping_line_company_id
|
|
ON freight.train_schedules (shipping_line_company_id)
|
|
WHERE shipping_line_company_id IS NOT NULL
|
|
`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`
|
|
DROP INDEX IF EXISTS freight.idx_train_schedules_shipping_line_company_id
|
|
`);
|
|
await queryRunner.query(`
|
|
ALTER TABLE freight.train_schedules
|
|
DROP COLUMN IF EXISTS shipping_line_company_id
|
|
`);
|
|
}
|
|
}
|