import { MigrationInterface, QueryRunner } from "typeorm";

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

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            ALTER TABLE freight.payments
            ALTER COLUMN refunded_at TYPE timestamp
            USING refunded_at::timestamp;
        `);

        await queryRunner.query(`
            ALTER TABLE freight.payments
            ALTER COLUMN expires_at TYPE timestamp
            USING expires_at::timestamp;
        `);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
            ALTER TABLE freight.payments
            ALTER COLUMN refunded_at TYPE timestamptz
            USING refunded_at::timestamptz;
        `);

        await queryRunner.query(`
            ALTER TABLE freight.payments
            ALTER COLUMN expires_at TYPE timestamptz
            USING expires_at::timestamptz;
        `);
    }
}