import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1739353047237 implements MigrationInterface {
    name = 'Migrations1739353047237'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "advertisements" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "advertisement_for" character varying NOT NULL DEFAULT 'brand', "button_lable" character varying, "link" text, "banner" character varying, "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), "created_by" uuid, "updated_by" uuid, CONSTRAINT "PK_4818a08332624787e5b2bf82302" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "advertisements" ADD CONSTRAINT "FK_49d69aaf2e6b35989ee647f85ae" FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "advertisements" ADD CONSTRAINT "FK_a391add2761f63a33f4d0feb0d7" FOREIGN KEY ("updated_by") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

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

}
