import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1770359132497 implements MigrationInterface {
    name = 'Migrations1770359132497'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "country_payment_methods" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "created_at" TIMESTAMP(0) NOT NULL DEFAULT now(), "updated_at" TIMESTAMP(0) NOT NULL DEFAULT now(), "deleted_at" TIMESTAMP(0), "country_id" uuid NOT NULL, "payment_method_id" uuid NOT NULL, CONSTRAINT "UQ_c4474857631c5f6340b40b8e4cd" UNIQUE ("country_id", "payment_method_id"), CONSTRAINT "PK_2a7c4c28561aa6177481c931a5b" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "country_payment_methods" ADD CONSTRAINT "FK_219c424acb552738ca8e0a607eb" FOREIGN KEY ("country_id") REFERENCES "countries"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "country_payment_methods" ADD CONSTRAINT "FK_1ffe81b5137168c3c62fcc5aabb" FOREIGN KEY ("payment_method_id") REFERENCES "payment_methods"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "country_payment_methods" DROP CONSTRAINT "FK_1ffe81b5137168c3c62fcc5aabb"`);
        await queryRunner.query(`ALTER TABLE "country_payment_methods" DROP CONSTRAINT "FK_219c424acb552738ca8e0a607eb"`);
        await queryRunner.query(`DROP TABLE "country_payment_methods"`);
    }

}
