import { MigrationInterface, QueryRunner } from 'typeorm'; export class AddRawRetailerProductEntity1659144212843 implements MigrationInterface { name = 'AddRawRetailerProductEntity1659144212843'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query( `CREATE TABLE "google_shopping_offer_history" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "googleShoppingId" character varying NOT NULL, "url" character varying NOT NULL, "price" double precision NOT NULL, CONSTRAINT "PK_6a9274d4ab112c0950ab3ce6e38" PRIMARY KEY ("id"))` ); await queryRunner.query( `CREATE TYPE "public"."raw_retailer_product_kind_enum" AS ENUM('WAYFAIR', 'AMAZON', 'ALL_MODERN', 'LULU_AND_GEORGIA', 'PERIGOLD', 'URBAN_OUTFITTERS')` ); await queryRunner.query( `CREATE TABLE "raw_retailer_product" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL DEFAULT '1', "kind" "public"."raw_retailer_product_kind_enum" NOT NULL, "rawData" jsonb NOT NULL, CONSTRAINT "PK_8925c58c74e7dabb2fb7fa585d4" PRIMARY KEY ("id"))` ); await queryRunner.query( `ALTER TABLE "pages" ALTER COLUMN "lastScrapedAt" SET DEFAULT 'NOW()'` ); await queryRunner.query( `ALTER TABLE "products" ALTER COLUMN "lastScrapedAt" SET DEFAULT 'NOW()'` ); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query( `ALTER TABLE "products" ALTER COLUMN "lastScrapedAt" SET DEFAULT '2022-07-30 01:19:55.296243+00'` ); await queryRunner.query( `ALTER TABLE "pages" ALTER COLUMN "lastScrapedAt" SET DEFAULT '2022-07-30 01:19:55.296243+00'` ); await queryRunner.query(`DROP TABLE "raw_retailer_product"`); await queryRunner.query( `DROP TYPE "public"."raw_retailer_product_kind_enum"` ); await queryRunner.query(`DROP TABLE "google_shopping_offer_history"`); } }