mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 01:48:12 +00:00
New Transit Agents admin table (name, valid-from/to, active/suspended, validity badge) — DJ assign step now picks from it, active+valid only.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
/**
|
||||
* GL Ethiopia ↔ GL Djibouti document exchange. The documents are ordinary
|
||||
* `freight.files` rows (resource `gl_exchange`), so they only need the metadata
|
||||
* a free-form upload has and a catalog-driven one does not: the uploader's own
|
||||
* title, who uploaded it (the only user allowed to change it afterwards) and
|
||||
* whether the customer may see it in the portal.
|
||||
*/
|
||||
export class AddGlExchangeDocumentFields3030000000000
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddGlExchangeDocumentFields3030000000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.files
|
||||
ADD COLUMN IF NOT EXISTS title varchar(300),
|
||||
ADD COLUMN IF NOT EXISTS visible_to_customer boolean NOT NULL DEFAULT false,
|
||||
ADD COLUMN IF NOT EXISTS uploaded_by_user_id uuid,
|
||||
ADD COLUMN IF NOT EXISTS uploaded_by_name varchar(200);`,
|
||||
);
|
||||
// Every read of a thread is "all files of one resource" — index the pair.
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX IF NOT EXISTS idx_files_resource_lookup
|
||||
ON freight.files (resource, resource_id);`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`DROP INDEX IF EXISTS freight.idx_files_resource_lookup;`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.files
|
||||
DROP COLUMN IF EXISTS title,
|
||||
DROP COLUMN IF EXISTS visible_to_customer,
|
||||
DROP COLUMN IF EXISTS uploaded_by_user_id,
|
||||
DROP COLUMN IF EXISTS uploaded_by_name;`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTransitAgents3040000000000 implements MigrationInterface {
|
||||
name = "AddTransitAgents3040000000000";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE IF NOT EXISTS freight.transit_agents (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name varchar(150) NOT NULL,
|
||||
valid_from date NOT NULL,
|
||||
valid_to date NOT NULL,
|
||||
is_active boolean NOT NULL DEFAULT true,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
deleted_at timestamptz
|
||||
)
|
||||
`);
|
||||
|
||||
await queryRunner.query(`
|
||||
CREATE INDEX IF NOT EXISTS ix_transit_agents_is_active
|
||||
ON freight.transit_agents (is_active)
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE IF EXISTS freight.transit_agents`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user