import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1729060416026 implements MigrationInterface {
    name = 'Migrations1729060416026'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "youtube_channels" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "title" character varying NOT NULL DEFAULT '', "description" text NOT NULL DEFAULT '', "channel_name" text NOT NULL DEFAULT '', "published_at" text NOT NULL DEFAULT '', "thumbnails" text NOT NULL DEFAULT '', "localized" text NOT NULL DEFAULT '', "content_id" text NOT NULL DEFAULT '', "view_counts" integer NOT NULL DEFAULT '0', "subscriber_count" integer NOT NULL DEFAULT '0', "video_count" integer NOT NULL DEFAULT '0', "created_at" TIMESTAMP(0) NOT NULL DEFAULT now(), "updated_at" TIMESTAMP(0) NOT NULL DEFAULT now(), "deleted_at" TIMESTAMP(0), "users" uuid, "socialMedia" uuid, CONSTRAINT "PK_ef881d4d451d4008bcdad5a7f5f" PRIMARY KEY ("id")); COMMENT ON COLUMN "youtube_channels"."content_id" IS 'Youtube Videos playlist Id'`);
        await queryRunner.query(`ALTER TABLE "youtube_channels" ADD CONSTRAINT "FK_b610d6c0781b889265105b106e3" FOREIGN KEY ("users") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "youtube_channels" ADD CONSTRAINT "FK_14d3d3d5c74b9e63b0ec0c2b6c7" FOREIGN KEY ("socialMedia") REFERENCES "social_medias"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

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

}
