Files
edr-platform/apps/edr-freight-api/src/migrations/1792000000002-CreateBookingOrders.ts
Marshal b6d5047d27 feat: Implement general contract booking orders functionality
- Add DTOs for creating booking orders and viewing contract quantities.
- Create entities for booking orders and booking order lines.
- Implement service for managing general contract operations, including activation after payment and retrieving quantity lines.
- Develop UI components for contract detail and list pages, including order placement dialog.
- Integrate API service for booking orders, enabling listing and creating orders against contracts.
- Enhance contract status display and quantity pool visualization in the UI.
2026-06-20 19:31:51 +00:00

75 lines
3.0 KiB
TypeScript

import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';
export class CreateBookingOrders1792000000002 implements MigrationInterface {
name = 'CreateBookingOrders1792000000002';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
schema: 'freight',
name: 'booking_orders',
columns: [
{ name: 'id', type: 'uuid', isPrimary: true, generationStrategy: 'uuid', default: 'gen_random_uuid()' },
{ name: 'reference', type: 'varchar', length: '64', isUnique: true },
{ name: 'contract_booking_id', type: 'uuid' },
{ name: 'booking_id', type: 'uuid', isNullable: true },
{ name: 'company_id', type: 'uuid', isNullable: true },
{ name: 'scheduled_date', type: 'timestamptz' },
{ name: 'status', type: 'varchar', length: '40', default: "'PAID'" },
{ name: 'scheduling_status', type: 'varchar', length: '30', default: "'NOT_SCHEDULED'" },
{ name: 'train_schedule_id', type: 'uuid', isNullable: true },
{ name: 'created_at', type: 'timestamptz', default: 'now()' },
{ name: 'updated_at', type: 'timestamptz', default: 'now()' },
{ name: 'deleted_at', type: 'timestamptz', isNullable: true },
],
}),
true,
);
await queryRunner.createIndex(
'freight.booking_orders',
new TableIndex({ name: 'idx_booking_orders_contract', columnNames: ['contract_booking_id'] }),
);
await queryRunner.createIndex(
'freight.booking_orders',
new TableIndex({ name: 'idx_booking_orders_company', columnNames: ['company_id'] }),
);
await queryRunner.createTable(
new Table({
schema: 'freight',
name: 'booking_order_lines',
columns: [
{ name: 'id', type: 'uuid', isPrimary: true, generationStrategy: 'uuid', default: 'gen_random_uuid()' },
{ name: 'order_id', type: 'uuid' },
{ name: 'container_type_id', type: 'uuid', isNullable: true },
{ name: 'quantity', type: 'numeric', precision: 12, scale: 3 },
{ name: 'created_at', type: 'timestamptz', default: 'now()' },
{ name: 'updated_at', type: 'timestamptz', default: 'now()' },
{ name: 'deleted_at', type: 'timestamptz', isNullable: true },
],
foreignKeys: [
{
columnNames: ['order_id'],
referencedSchema: 'freight',
referencedTableName: 'booking_orders',
referencedColumnNames: ['id'],
onDelete: 'CASCADE',
},
],
}),
true,
);
await queryRunner.createIndex(
'freight.booking_order_lines',
new TableIndex({ name: 'idx_booking_order_lines_order', columnNames: ['order_id'] }),
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('freight.booking_order_lines', true);
await queryRunner.dropTable('freight.booking_orders', true);
}
}