import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1780998267336 implements MigrationInterface {
    name = 'Migrations1780998267336'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "country_recommended_categories" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "order_by" integer NOT NULL DEFAULT '1', "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, "category_id" uuid NOT NULL, CONSTRAINT "UQ_cc196a2da0a79ebd5cfbfeee238" UNIQUE ("country_id", "category_id"), CONSTRAINT "PK_40a61976a9d63ee2e16b8663854" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "country_recommended_categories" ADD CONSTRAINT "FK_3739a9b91446dd03cdb4d3e88bf" FOREIGN KEY ("country_id") REFERENCES "countries"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "country_recommended_categories" ADD CONSTRAINT "FK_ddbcc68e5446858fcc357424dfc" FOREIGN KEY ("category_id") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
    }

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

}
