import { MigrationInterface, QueryRunner } from "typeorm";

export class Migrations1729060985308 implements MigrationInterface {
    name = 'Migrations1729060985308'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "youtube_videos" ("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 '', "video_id" text NOT NULL DEFAULT '', "youtube_category_id" text NOT NULL DEFAULT '', "view_counts" integer NOT NULL DEFAULT '0', "like_counts" integer NOT NULL DEFAULT '0', "comment_count" integer NOT NULL DEFAULT '0', "fevorite_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, "youtubeChannel" uuid, CONSTRAINT "PK_1a41d24a1ea34c746430493b2e6" PRIMARY KEY ("id")); COMMENT ON COLUMN "youtube_videos"."video_id" IS 'Youtube Videos Id'; COMMENT ON COLUMN "youtube_videos"."youtube_category_id" IS 'Youtube category Id'`);
        await queryRunner.query(`ALTER TABLE "youtube_videos" ADD CONSTRAINT "FK_4e10e266b12e262e6108fee1580" FOREIGN KEY ("users") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "youtube_videos" ADD CONSTRAINT "FK_046fac5eac4acaf1e61eaabf668" FOREIGN KEY ("socialMedia") REFERENCES "social_medias"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "youtube_videos" ADD CONSTRAINT "FK_3c80e0163b5e24b271d6a9bd58b" FOREIGN KEY ("youtubeChannel") REFERENCES "youtube_channels"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "youtube_videos" DROP CONSTRAINT "FK_3c80e0163b5e24b271d6a9bd58b"`);
        await queryRunner.query(`ALTER TABLE "youtube_videos" DROP CONSTRAINT "FK_046fac5eac4acaf1e61eaabf668"`);
        await queryRunner.query(`ALTER TABLE "youtube_videos" DROP CONSTRAINT "FK_4e10e266b12e262e6108fee1580"`);
        await queryRunner.query(`DROP TABLE "youtube_videos"`);
    }

}
