merges migration files

This commit is contained in:
olivermrbl
2021-06-08 08:24:00 +02:00
parent 1edee26e7b
commit c8b134c488
3 changed files with 4 additions and 48 deletions

View File

@@ -4,8 +4,8 @@ export class draftOrders1613384784316 implements MigrationInterface {
name = 'draftOrders1613384784316'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TYPE "draft_order_status_enum" AS ENUM('open', 'awaiting', 'completed')`);
await queryRunner.query(`CREATE TABLE "draft_order" ("id" character varying NOT NULL, "status" "draft_order_status_enum" NOT NULL DEFAULT 'open', "display_id" SERIAL NOT NULL, "cart_id" character varying, "order_id" character varying, "canceled_at" TIMESTAMP WITH TIME ZONE, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "metadata" jsonb, "idempotency_key" character varying, CONSTRAINT "REL_5bd11d0e2a9628128e2c26fd0a" UNIQUE ("cart_id"), CONSTRAINT "REL_8f6dd6c49202f1466ebf21e77d" UNIQUE ("order_id"), CONSTRAINT "PK_f478946c183d98f8d88a94cfcd7" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TYPE "draft_order_status_enum" AS ENUM('open', 'completed')`);
await queryRunner.query(`CREATE TABLE "draft_order" ("id" character varying NOT NULL, "status" "draft_order_status_enum" NOT NULL DEFAULT 'open', "display_id" SERIAL NOT NULL, "cart_id" character varying, "order_id" character varying, "canceled_at" TIMESTAMP WITH TIME ZONE, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "completed_at" TIMESTAMP WITH TIME ZONE NOT NULL, "metadata" jsonb, "idempotency_key" character varying, CONSTRAINT "REL_5bd11d0e2a9628128e2c26fd0a" UNIQUE ("cart_id"), CONSTRAINT "REL_8f6dd6c49202f1466ebf21e77d" UNIQUE ("order_id"), CONSTRAINT "PK_f478946c183d98f8d88a94cfcd7" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_e87cc617a22ef4edce5601edab" ON "draft_order" ("display_id") `);
await queryRunner.query(`CREATE INDEX "IDX_5bd11d0e2a9628128e2c26fd0a" ON "draft_order" ("cart_id") `);
await queryRunner.query(`CREATE INDEX "IDX_8f6dd6c49202f1466ebf21e77d" ON "draft_order" ("order_id") `);
@@ -22,6 +22,7 @@ export class draftOrders1613384784316 implements MigrationInterface {
await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_8f6dd6c49202f1466ebf21e77da" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "order" ADD CONSTRAINT "FK_727b872f86c7378474a8fa46147" FOREIGN KEY ("draft_order_id") REFERENCES "draft_order"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "store" ADD "payment_link_template" character varying`);
await queryRunner.query(`ALTER TABLE "shipping_option" ADD "admin_only" boolean NOT NULL DEFAULT false`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
@@ -43,6 +44,7 @@ export class draftOrders1613384784316 implements MigrationInterface {
await queryRunner.query(`DROP TABLE "draft_order"`);
await queryRunner.query(`DROP TYPE "draft_order_status_enum"`);
await queryRunner.query(`ALTER TABLE "store" DROP COLUMN "payment_link_template"`);
await queryRunner.query(`ALTER TABLE "shipping_option" DROP COLUMN "admin_only"`)
}
}

View File

@@ -1,18 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm"
export class shippingOptionAdminOnly1613896971521
implements MigrationInterface {
name = "shippingOptionAdminOnly1613896971521"
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "shipping_option" ADD "admin_only" boolean NOT NULL DEFAULT false`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "shipping_option" DROP COLUMN "admin_only"`
)
}
}

View File

@@ -1,28 +0,0 @@
import {MigrationInterface, QueryRunner} from "typeorm";
export class draftOrderCompletedAt1623063141210 implements MigrationInterface {
name = 'draftOrderCompletedAt1623063141210'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "draft_order" ADD "completed_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()`);
await queryRunner.query(`ALTER TYPE "public"."draft_order_status_enum" RENAME TO "draft_order_status_enum_old"`);
await queryRunner.query(`CREATE TYPE "draft_order_status_enum" AS ENUM('open', 'completed')`);
await queryRunner.query(`ALTER TABLE "draft_order" ALTER COLUMN "status" DROP DEFAULT`);
await queryRunner.query(`ALTER TABLE "draft_order" ALTER COLUMN "status" TYPE "draft_order_status_enum" USING "status"::"text"::"draft_order_status_enum"`);
await queryRunner.query(`ALTER TABLE "draft_order" ALTER COLUMN "status" SET DEFAULT 'open'`);
await queryRunner.query(`DROP TYPE "draft_order_status_enum_old"`);
await queryRunner.query(`COMMENT ON COLUMN "draft_order"."status" IS NULL`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`COMMENT ON COLUMN "draft_order"."status" IS NULL`);
await queryRunner.query(`CREATE TYPE "draft_order_status_enum_old" AS ENUM('open', 'awaiting', 'completed')`);
await queryRunner.query(`ALTER TABLE "draft_order" ALTER COLUMN "status" DROP DEFAULT`);
await queryRunner.query(`ALTER TABLE "draft_order" ALTER COLUMN "status" TYPE "draft_order_status_enum_old" USING "status"::"text"::"draft_order_status_enum_old"`);
await queryRunner.query(`ALTER TABLE "draft_order" ALTER COLUMN "status" SET DEFAULT 'open'`);
await queryRunner.query(`DROP TYPE "draft_order_status_enum"`);
await queryRunner.query(`ALTER TYPE "draft_order_status_enum_old" RENAME TO "draft_order_status_enum"`);
await queryRunner.query(`ALTER TABLE "draft_order" DROP COLUMN "completed_at"`);
}
}