import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1732961209508 implements MigrationInterface {
    name = 'Migrations1732961209508'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "faqs" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "faq_for" character varying NOT NULL DEFAULT 'brand', "questions" text, "answers" text, "order_by" integer NOT NULL, "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_2ddf4f2c910f8e8fa2663a67bf0" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "faqs" ADD CONSTRAINT "FK_0451dfe0ab09c391088a74150d6" FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "faqs" ADD CONSTRAINT "FK_5959d82c335ea6e5e844832c688" 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 "faqs" DROP CONSTRAINT "FK_5959d82c335ea6e5e844832c688"`);
        await queryRunner.query(`ALTER TABLE "faqs" DROP CONSTRAINT "FK_0451dfe0ab09c391088a74150d6"`);
        await queryRunner.query(`DROP TABLE "faqs"`);
    }

}
