import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1770989161287 implements MigrationInterface {
    name = 'Migrations1770989161287'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "influencer_payment_methods" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "json_data" jsonb, "is_active" boolean NOT NULL DEFAULT true, "created_at" TIMESTAMP(0) NOT NULL DEFAULT now(), "updated_at" TIMESTAMP(0) NOT NULL DEFAULT now(), "deleted_at" TIMESTAMP(0), "influencer_id" uuid NOT NULL, "payment_method_id" uuid NOT NULL, CONSTRAINT "UQ_7a2d630a8ccf0eea6a13238984a" UNIQUE ("influencer_id", "payment_method_id"), CONSTRAINT "PK_ceb7a132885a2406f56161059f4" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "influencer_payment_methods" ADD CONSTRAINT "FK_6f0dc33a2c24234be4c13b89d55" FOREIGN KEY ("influencer_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "influencer_payment_methods" ADD CONSTRAINT "FK_a99834084afd72b439bf4c8fbea" 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 "influencer_payment_methods" DROP CONSTRAINT "FK_a99834084afd72b439bf4c8fbea"`);
        await queryRunner.query(`ALTER TABLE "influencer_payment_methods" DROP CONSTRAINT "FK_6f0dc33a2c24234be4c13b89d55"`);
        await queryRunner.query(`DROP TABLE "influencer_payment_methods"`);
    }

}
