import { MigrationInterface, QueryRunner } from "typeorm";

export class AddBookingWindowGlobalRules1861000000000 implements MigrationInterface {
    name = "AddBookingWindowGlobalRules1861000000000";

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            ALTER TABLE freight.train_scheduling_global_rules
                ADD COLUMN import_window_lead_days integer NOT NULL DEFAULT 3,
                ADD COLUMN export_booking_lead_hours integer NOT NULL DEFAULT 24,
                ADD COLUMN window_open_hour integer NOT NULL DEFAULT 8,
                ADD COLUMN window_duration_hours numeric(4, 2) NOT NULL DEFAULT 3,
                ADD COLUMN doc_review_minutes integer NOT NULL DEFAULT 30,
                ADD COLUMN payment_window_minutes integer NOT NULL DEFAULT 60,
                ADD COLUMN reopen_delay_minutes integer NOT NULL DEFAULT 90;
        `);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            ALTER TABLE freight.train_scheduling_global_rules
                DROP COLUMN IF EXISTS import_window_lead_days,
                DROP COLUMN IF EXISTS export_booking_lead_hours,
                DROP COLUMN IF EXISTS window_open_hour,
                DROP COLUMN IF EXISTS window_duration_hours,
                DROP COLUMN IF EXISTS doc_review_minutes,
                DROP COLUMN IF EXISTS payment_window_minutes,
                DROP COLUMN IF EXISTS reopen_delay_minutes;
        `);
    }
}
