mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 09:30:59 +00:00
fix(portal): show declaration, T1 and Djibouti clearance documents to the customer
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Clearance charges are no longer one-of-each in a fixed order: GL Ethiopia
|
||||
* may raise several MISCELLANEOUS charges, and either level may be created
|
||||
* first. Port charges stay unique per booking (one port bill per shipment),
|
||||
* enforced by a partial index instead of the old blanket (booking_id, type)
|
||||
* uniqueness that also capped miscellaneous at one.
|
||||
*/
|
||||
export class MultipleMiscClearanceCharges3610000000000
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'MultipleMiscClearanceCharges3610000000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
DROP INDEX IF EXISTS "freight"."uq_booking_clearance_charge_booking_type"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "uq_booking_clearance_charge_port"
|
||||
ON "freight"."booking_clearance_charge" ("booking_id")
|
||||
WHERE "type" = 'PORT_CHARGES' AND "deleted_at" IS NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
CREATE INDEX IF NOT EXISTS "idx_booking_clearance_charge_booking"
|
||||
ON "freight"."booking_clearance_charge" ("booking_id")
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
// No-op on the uniqueness: restoring the blanket (booking_id, type) index
|
||||
// would fail on any booking that has since raised a second miscellaneous
|
||||
// charge, which is exactly what this migration set out to allow.
|
||||
await queryRunner.query(`
|
||||
DROP INDEX IF EXISTS "freight"."uq_booking_clearance_charge_port"
|
||||
`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user