init
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class InitProductsCrud1777811112018 implements MigrationInterface {
|
||||
name = 'InitProductsCrud1777811112018';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "digital_stock_items" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "content" text NOT NULL, "isSold" boolean NOT NULL DEFAULT false, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, "productId" uuid, CONSTRAINT "PK_bfffac39999d57b14d445abeb2f" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(`CREATE TYPE "public"."products_priceunit_enum" AS ENUM('USD')`);
|
||||
await queryRunner.query(`CREATE TYPE "public"."products_type_enum" AS ENUM('digital')`);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "products" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "title" character varying NOT NULL, "price" numeric(12,2) NOT NULL, "priceUnit" "public"."products_priceunit_enum" NOT NULL DEFAULT 'USD', "type" "public"."products_type_enum" NOT NULL DEFAULT 'digital', "thumbnailUrl" character varying NOT NULL, "descriptionHtml" text NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, CONSTRAINT "PK_0806c755e0aca124e67c0cf6d7d" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "digital_stock_items" ADD CONSTRAINT "FK_f3ee7be0d350b6954b5d3c8bf32" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "digital_stock_items" DROP CONSTRAINT "FK_f3ee7be0d350b6954b5d3c8bf32"`);
|
||||
await queryRunner.query(`DROP TABLE "products"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."products_type_enum"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."products_priceunit_enum"`);
|
||||
await queryRunner.query(`DROP TABLE "digital_stock_items"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class MakeProductAsDraftInitialy1778247115870 implements MigrationInterface {
|
||||
name = 'MakeProductAsDraftInitialy1778247115870';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "products" ADD "isDraft" boolean NOT NULL DEFAULT true`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "title" SET DEFAULT ''`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "price" SET DEFAULT '0'`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "thumbnailUrl" SET DEFAULT ''`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "descriptionHtml" SET DEFAULT ''`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "descriptionHtml" DROP DEFAULT`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "thumbnailUrl" DROP DEFAULT`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "price" DROP DEFAULT`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "title" DROP DEFAULT`);
|
||||
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "isDraft"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddPhysicalProductType1779658508834 implements MigrationInterface {
|
||||
name = 'AddPhysicalProductType1779658508834';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "products" ADD "stockQuantity" integer`);
|
||||
await queryRunner.query(`ALTER TYPE "public"."products_type_enum" RENAME TO "products_type_enum_old"`);
|
||||
await queryRunner.query(`CREATE TYPE "public"."products_type_enum" AS ENUM('digital', 'physical')`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "type" DROP DEFAULT`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "products" ALTER COLUMN "type" TYPE "public"."products_type_enum" USING "type"::"text"::"public"."products_type_enum"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "type" SET DEFAULT 'digital'`);
|
||||
await queryRunner.query(`DROP TYPE "public"."products_type_enum_old"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TYPE "public"."products_type_enum_old" AS ENUM('digital')`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "type" DROP DEFAULT`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "products" ALTER COLUMN "type" TYPE "public"."products_type_enum_old" USING "type"::"text"::"public"."products_type_enum_old"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "type" SET DEFAULT 'digital'`);
|
||||
await queryRunner.query(`DROP TYPE "public"."products_type_enum"`);
|
||||
await queryRunner.query(`ALTER TYPE "public"."products_type_enum_old" RENAME TO "products_type_enum"`);
|
||||
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "stockQuantity"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class RemovePriceUnitProductCol1779721786152 implements MigrationInterface {
|
||||
name = 'RemovePriceUnitProductCol1779721786152';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "priceUnit"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."products_priceunit_enum"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TYPE "public"."products_priceunit_enum" AS ENUM('USD')`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "products" ADD "priceUnit" "public"."products_priceunit_enum" NOT NULL DEFAULT 'USD'`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddDiscountCodeEntity1780672489601 implements MigrationInterface {
|
||||
name = 'AddDiscountCodeEntity1780672489601';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TYPE "public"."discount_codes_type_enum" AS ENUM('percent', 'fixed')`);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "discount_codes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying NOT NULL, "type" "public"."discount_codes_type_enum" NOT NULL, "value" numeric(12,2) NOT NULL, "isActive" boolean NOT NULL DEFAULT true, "validFrom" TIMESTAMP WITH TIME ZONE, "validUntil" TIMESTAMP WITH TIME ZONE, "maxRedemptions" integer, "redemptionCount" integer NOT NULL DEFAULT '0', "minOrderAmount" numeric(12,2), "isExclusive" boolean NOT NULL DEFAULT false, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, CONSTRAINT "UQ_b967edd0d46547d4a92b4a1c6b3" UNIQUE ("code"), CONSTRAINT "PK_c0170a28d937472e9ce50fdce17" PRIMARY KEY ("id"))`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "discount_codes"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."discount_codes_type_enum"`);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class UsePartialUniqueIndexInsteadOfUniqueConstraintOnDiscount1781106764300 implements MigrationInterface {
|
||||
name = 'UsePartialUniqueIndexInsteadOfUniqueConstraintOnDiscount1781106764300';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "discount_codes" DROP CONSTRAINT "UQ_b967edd0d46547d4a92b4a1c6b3"`);
|
||||
await queryRunner.query(
|
||||
`CREATE UNIQUE INDEX "UQ_discount_codes_code_active" ON "discount_codes" ("code") WHERE "deletedAt" IS NULL`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX "public"."UQ_discount_codes_code_active"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes" ADD CONSTRAINT "UQ_b967edd0d46547d4a92b4a1c6b3" UNIQUE ("code")`
|
||||
);
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddManyToManyDiscountsToProducts1781195026200 implements MigrationInterface {
|
||||
name = 'AddManyToManyDiscountsToProducts1781195026200';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "discount_codes_products" ("discountCodeId" uuid NOT NULL, "productId" uuid NOT NULL, CONSTRAINT "PK_ddb3803ddbde34f384005c7e83c" PRIMARY KEY ("discountCodeId", "productId"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_9c88bd20ae9779f6ffe41989f5" ON "discount_codes_products" ("discountCodeId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_fc3c8861bdc81589f933b5cee5" ON "discount_codes_products" ("productId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_products" ADD CONSTRAINT "FK_9c88bd20ae9779f6ffe41989f5a" FOREIGN KEY ("discountCodeId") REFERENCES "discount_codes"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_products" ADD CONSTRAINT "FK_fc3c8861bdc81589f933b5cee5e" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_products" DROP CONSTRAINT "FK_fc3c8861bdc81589f933b5cee5e"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_products" DROP CONSTRAINT "FK_9c88bd20ae9779f6ffe41989f5a"`
|
||||
);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_fc3c8861bdc81589f933b5cee5"`);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_9c88bd20ae9779f6ffe41989f5"`);
|
||||
await queryRunner.query(`DROP TABLE "discount_codes_products"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddProductCategories1781785655067 implements MigrationInterface {
|
||||
name = 'AddProductCategories1781785655067';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "categories" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "sortOrder" integer NOT NULL DEFAULT '0', "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_8b0be371d28245da6e4f4b61878" UNIQUE ("name"), CONSTRAINT "PK_24dbc6126a28ff948da33e97d3b" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "products_categories" ("productId" uuid NOT NULL, "categoryId" uuid NOT NULL, CONSTRAINT "PK_ac147b513b3ed1671ef3577e098" PRIMARY KEY ("productId", "categoryId"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_b7bcf72f50cb6aca555a72eb63" ON "products_categories" ("productId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_10e0ebf99c4b77d7d726036d8e" ON "products_categories" ("categoryId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "products_categories" ADD CONSTRAINT "FK_b7bcf72f50cb6aca555a72eb630" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "products_categories" ADD CONSTRAINT "FK_10e0ebf99c4b77d7d726036d8ec" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "products_categories" DROP CONSTRAINT "FK_10e0ebf99c4b77d7d726036d8ec"`);
|
||||
await queryRunner.query(`ALTER TABLE "products_categories" DROP CONSTRAINT "FK_b7bcf72f50cb6aca555a72eb630"`);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_10e0ebf99c4b77d7d726036d8e"`);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_b7bcf72f50cb6aca555a72eb63"`);
|
||||
await queryRunner.query(`DROP TABLE "products_categories"`);
|
||||
await queryRunner.query(`DROP TABLE "categories"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddDiscountToCategory1781849627565 implements MigrationInterface {
|
||||
name = 'AddDiscountToCategory1781849627565';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "discount_codes_categories" ("discountCodeId" uuid NOT NULL, "categoryId" uuid NOT NULL, CONSTRAINT "PK_a1d001587e1735737d233e956a5" PRIMARY KEY ("discountCodeId", "categoryId"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_3126372e862e29a5374a8594b0" ON "discount_codes_categories" ("discountCodeId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_1bcf070115fa8dc5ebb57d0fee" ON "discount_codes_categories" ("categoryId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_categories" ADD CONSTRAINT "FK_3126372e862e29a5374a8594b0c" FOREIGN KEY ("discountCodeId") REFERENCES "discount_codes"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_categories" ADD CONSTRAINT "FK_1bcf070115fa8dc5ebb57d0fee8" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_categories" DROP CONSTRAINT "FK_1bcf070115fa8dc5ebb57d0fee8"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_categories" DROP CONSTRAINT "FK_3126372e862e29a5374a8594b0c"`
|
||||
);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_1bcf070115fa8dc5ebb57d0fee"`);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_3126372e862e29a5374a8594b0"`);
|
||||
await queryRunner.query(`DROP TABLE "discount_codes_categories"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddProductVariantsTable1782151519819 implements MigrationInterface {
|
||||
name = 'AddProductVariantsTable1782151519819';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "product_variants" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "title" character varying NOT NULL, "price" numeric(12,2) NOT NULL DEFAULT '0', "stockQuantity" integer, "isDefault" boolean NOT NULL DEFAULT false, "sortOrder" integer NOT NULL DEFAULT '0', "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "productId" uuid, CONSTRAINT "PK_281e3f2c55652d6a22c0aa59fd7" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE UNIQUE INDEX "UQ_product_variants_default_per_product" ON "product_variants" ("productId") WHERE "isDefault" = true`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "price"`);
|
||||
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "stockQuantity"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "product_variants" ADD CONSTRAINT "FK_f515690c571a03400a9876600b5" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "product_variants" DROP CONSTRAINT "FK_f515690c571a03400a9876600b5"`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ADD "stockQuantity" integer`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ADD "price" numeric(12,2) NOT NULL DEFAULT '0'`);
|
||||
await queryRunner.query(`DROP INDEX "public"."UQ_product_variants_default_per_product"`);
|
||||
await queryRunner.query(`DROP TABLE "product_variants"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddDiscountCodeVariantsM2m1782652984862 implements MigrationInterface {
|
||||
name = 'AddDiscountCodeVariantsM2m1782652984862';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "discount_codes_variants" ("discountCodeId" uuid NOT NULL, "variantId" uuid NOT NULL, CONSTRAINT "PK_64381aa5f72cc68f7fdea1f43cc" PRIMARY KEY ("discountCodeId", "variantId"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_e7995d0deea26f2a89662b81ad" ON "discount_codes_variants" ("discountCodeId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE INDEX "IDX_04bd8f37b20eddfd6fc1c2c8aa" ON "discount_codes_variants" ("variantId") `
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_variants" ADD CONSTRAINT "FK_e7995d0deea26f2a89662b81ada" FOREIGN KEY ("discountCodeId") REFERENCES "discount_codes"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_variants" ADD CONSTRAINT "FK_04bd8f37b20eddfd6fc1c2c8aa0" FOREIGN KEY ("variantId") REFERENCES "product_variants"("id") ON DELETE CASCADE ON UPDATE CASCADE`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_variants" DROP CONSTRAINT "FK_04bd8f37b20eddfd6fc1c2c8aa0"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes_variants" DROP CONSTRAINT "FK_e7995d0deea26f2a89662b81ada"`
|
||||
);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_04bd8f37b20eddfd6fc1c2c8aa"`);
|
||||
await queryRunner.query(`DROP INDEX "public"."IDX_e7995d0deea26f2a89662b81ad"`);
|
||||
await queryRunner.query(`DROP TABLE "discount_codes_variants"`);
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class MoveDigitalStockItemsToVariantScope1782821226132 implements MigrationInterface {
|
||||
name = 'MoveDigitalStockItemsToVariantScope1782821226132';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "digital_stock_items" DROP CONSTRAINT "FK_f3ee7be0d350b6954b5d3c8bf32"`);
|
||||
await queryRunner.query(`ALTER TABLE "digital_stock_items" RENAME COLUMN "productId" TO "variantId"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "digital_stock_items" ADD CONSTRAINT "FK_f93fdc4b42cf0410d8bb0c66778" FOREIGN KEY ("variantId") REFERENCES "product_variants"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "digital_stock_items" DROP CONSTRAINT "FK_f93fdc4b42cf0410d8bb0c66778"`);
|
||||
await queryRunner.query(`ALTER TABLE "digital_stock_items" RENAME COLUMN "variantId" TO "productId"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "digital_stock_items" ADD CONSTRAINT "FK_f3ee7be0d350b6954b5d3c8bf32" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class RemoveDefaultVariant1782839159240 implements MigrationInterface {
|
||||
name = 'RemoveDefaultVariant1782839159240';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX "public"."UQ_product_variants_default_per_product"`);
|
||||
await queryRunner.query(`ALTER TABLE "product_variants" DROP COLUMN "isDefault"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "product_variants" ADD "isDefault" boolean NOT NULL DEFAULT false`);
|
||||
await queryRunner.query(
|
||||
`CREATE UNIQUE INDEX "UQ_product_variants_default_per_product" ON "product_variants" ("productId") WHERE ("isDefault" = true)`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddVariantImages1783206651562 implements MigrationInterface {
|
||||
name = 'AddVariantImages1783206651562';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "variant_images" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "url" character varying NOT NULL, "sortOrder" integer NOT NULL DEFAULT '0', "isThumbnail" boolean NOT NULL DEFAULT false, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "variantId" uuid, CONSTRAINT "PK_e12e3f22db0e085fb8cb0a43fb7" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "thumbnailUrl"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "variant_images" ADD CONSTRAINT "FK_a64680112bb0dc25d6cc0747d4c" FOREIGN KEY ("variantId") REFERENCES "product_variants"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "variant_images" DROP CONSTRAINT "FK_a64680112bb0dc25d6cc0747d4c"`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ADD "thumbnailUrl" character varying NOT NULL DEFAULT ''`);
|
||||
await queryRunner.query(`DROP TABLE "variant_images"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class ProductTypeRework1783522977172 implements MigrationInterface {
|
||||
name = 'ProductTypeRework1783522977172';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "products" RENAME COLUMN "type" TO "deliveryMode"`);
|
||||
await queryRunner.query(`ALTER TYPE "public"."products_type_enum" RENAME TO "products_deliverymode_enum"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TYPE "public"."products_deliverymode_enum" RENAME TO "products_deliverymode_enum_old"`
|
||||
);
|
||||
await queryRunner.query(`CREATE TYPE "public"."products_deliverymode_enum" AS ENUM('auto', 'manual')`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "deliveryMode" DROP DEFAULT`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "products" ALTER COLUMN "deliveryMode" TYPE "public"."products_deliverymode_enum" USING "deliveryMode"::"text"::"public"."products_deliverymode_enum"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "deliveryMode" SET DEFAULT 'auto'`);
|
||||
await queryRunner.query(`DROP TYPE "public"."products_deliverymode_enum_old"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TYPE "public"."products_deliverymode_enum_old" AS ENUM('digital', 'physical')`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "deliveryMode" DROP DEFAULT`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "products" ALTER COLUMN "deliveryMode" TYPE "public"."products_deliverymode_enum_old" USING "deliveryMode"::"text"::"public"."products_deliverymode_enum_old"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "products" ALTER COLUMN "deliveryMode" SET DEFAULT 'digital'`);
|
||||
await queryRunner.query(`DROP TYPE "public"."products_deliverymode_enum"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TYPE "public"."products_deliverymode_enum_old" RENAME TO "products_deliverymode_enum"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TYPE "public"."products_deliverymode_enum" RENAME TO "products_type_enum"`);
|
||||
await queryRunner.query(`ALTER TABLE "products" RENAME COLUMN "deliveryMode" TO "type"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddDigitalStockAttachments1783610487305 implements MigrationInterface {
|
||||
name = 'AddDigitalStockAttachments1783610487305';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "digital_stock_item_attachments" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "storageKey" character varying NOT NULL, "originalFilename" character varying NOT NULL, "mimeType" character varying NOT NULL, "sizeBytes" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "digitalStockItemId" uuid, CONSTRAINT "PK_8ba50fc3e4cc64e54fb7494f5a1" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "digital_stock_item_attachments" ADD CONSTRAINT "FK_0cc31f343c2efcd598b53e9537d" FOREIGN KEY ("digitalStockItemId") REFERENCES "digital_stock_items"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "digital_stock_item_attachments" DROP CONSTRAINT "FK_0cc31f343c2efcd598b53e9537d"`
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "digital_stock_item_attachments"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class RemoveSoftDeleteCols1783701820648 implements MigrationInterface {
|
||||
name = 'RemoveSoftDeleteCols1783701820648';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX "public"."UQ_discount_codes_code_active"`);
|
||||
await queryRunner.query(`ALTER TABLE "digital_stock_items" DROP COLUMN "deletedAt"`);
|
||||
await queryRunner.query(`ALTER TABLE "products" DROP COLUMN "deletedAt"`);
|
||||
await queryRunner.query(`ALTER TABLE "discount_codes" DROP COLUMN "deletedAt"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "discount_codes" ADD CONSTRAINT "UQ_b967edd0d46547d4a92b4a1c6b3" UNIQUE ("code")`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "discount_codes" DROP CONSTRAINT "UQ_b967edd0d46547d4a92b4a1c6b3"`);
|
||||
await queryRunner.query(`ALTER TABLE "discount_codes" ADD "deletedAt" TIMESTAMP`);
|
||||
await queryRunner.query(`ALTER TABLE "products" ADD "deletedAt" TIMESTAMP`);
|
||||
await queryRunner.query(`ALTER TABLE "digital_stock_items" ADD "deletedAt" TIMESTAMP`);
|
||||
await queryRunner.query(
|
||||
`CREATE UNIQUE INDEX "UQ_discount_codes_code_active" ON "discount_codes" ("code") WHERE ("deletedAt" IS NULL)`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddShopSettings1783806278430 implements MigrationInterface {
|
||||
name = 'AddShopSettings1783806278430';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "shop_settings" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "logoStorageKey" character varying, "simplexLink" character varying, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_96c0aa2a327de09ebe0fd54ae5a" PRIMARY KEY ("id"))`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "shop_settings"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddShippingNote1783912100000 implements MigrationInterface {
|
||||
name = 'AddShippingNote1783912100000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" ADD "shippingNote" text`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" DROP COLUMN "shippingNote"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddCommerceTables1784030873071 implements MigrationInterface {
|
||||
name = 'AddCommerceTables1784030873071';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
// --- invoices ---
|
||||
await queryRunner.query(`CREATE TYPE "public"."invoices_reason_enum" AS ENUM('checkout', 'shipping')`);
|
||||
await queryRunner.query(`CREATE TYPE "public"."invoices_paymentmethod_enum" AS ENUM('xmr')`);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "invoices" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "reason" "public"."invoices_reason_enum" NOT NULL, "paymentMethod" "public"."invoices_paymentmethod_enum" NOT NULL, "amountFiat" numeric(12,2) NOT NULL, "fiatCurrency" character varying(3) NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE NOT NULL, "paymentAddress" character varying(255) NOT NULL, "expectedTotalAtomic" bigint NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_invoices_payment_address" UNIQUE ("paymentAddress"), CONSTRAINT "PK_invoices" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "invoice_payments" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "txHash" character varying(64) NOT NULL, "amountAtomic" bigint NOT NULL, "confirmations" integer NOT NULL DEFAULT '0', "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "invoiceId" uuid, CONSTRAINT "UQ_invoice_payments_tx_hash" UNIQUE ("txHash"), CONSTRAINT "PK_invoice_payments" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "invoice_monero_details" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "paymentAddressIndex" integer NOT NULL, "fiatPerXmrAtCreation" numeric(12,2) NOT NULL, "requiredConfirmations" integer NOT NULL, "invoiceId" uuid, CONSTRAINT "UQ_invoice_monero_details_invoice_id" UNIQUE ("invoiceId"), CONSTRAINT "PK_invoice_monero_details" PRIMARY KEY ("id"))`
|
||||
);
|
||||
|
||||
// --- orders ---
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."orders_failurereason_enum" AS ENUM('stock_unavailable', 'discount_exhausted')`
|
||||
);
|
||||
await queryRunner.query(`CREATE TYPE "public"."order_lines_deliverymode_enum" AS ENUM('auto', 'manual')`);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."order_line_manual_fulfillments_status_enum" AS ENUM('pending', 'fulfilled')`
|
||||
);
|
||||
await queryRunner.query(`CREATE TYPE "public"."order_messages_sender_enum" AS ENUM('buyer', 'staff')`);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "orders" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "accessTokenLookup" character varying(64) NOT NULL, "accessToken" text NOT NULL, "failureReason" "public"."orders_failurereason_enum", "accessTokenSavedConfirmedAt" TIMESTAMP WITH TIME ZONE, "quotedAt" TIMESTAMP WITH TIME ZONE, "checkoutSessionId" uuid, "checkoutInvoiceId" uuid, "shippingInvoiceId" uuid, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_43a3cd3d7373e9013a08a6a65b6" UNIQUE ("accessTokenLookup"), CONSTRAINT "UQ_orders_checkout_session_id" UNIQUE ("checkoutSessionId"), CONSTRAINT "UQ_orders_checkout_invoice_id" UNIQUE ("checkoutInvoiceId"), CONSTRAINT "UQ_orders_shipping_invoice_id" UNIQUE ("shippingInvoiceId"), CONSTRAINT "PK_710e2d4957aa5878dfe94e4ac2f" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "order_lines" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "variantId" uuid NOT NULL, "productId" uuid NOT NULL, "productTitle" character varying NOT NULL, "variantTitle" character varying NOT NULL, "thumbnailUrl" character varying, "qty" integer NOT NULL, "unitPriceFiat" numeric(12,2) NOT NULL, "lineSubtotalFiat" numeric(12,2) NOT NULL, "deliveryMode" "public"."order_lines_deliverymode_enum" NOT NULL, "orderId" uuid, CONSTRAINT "PK_order_lines" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "order_discounts" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying(32) NOT NULL, "amountFiat" numeric(12,2) NOT NULL, "orderId" uuid, CONSTRAINT "PK_order_discounts" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "order_line_auto_fulfillment_items" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "sortOrder" integer NOT NULL, "contentSnapshot" text NOT NULL, "sourceDigitalStockItemId" uuid NOT NULL, "orderLineId" uuid, CONSTRAINT "PK_order_line_auto_fulfillment_items" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "order_line_auto_fulfillment_item_attachments" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "storageKey" character varying NOT NULL, "sourceDigitalStockAttachmentId" uuid NOT NULL, "originalFilename" character varying NOT NULL, "mimeType" character varying NOT NULL, "sizeBytes" integer NOT NULL, "itemId" uuid, CONSTRAINT "PK_order_line_auto_fulfillment_item_attachments" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "order_line_manual_fulfillments" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "status" "public"."order_line_manual_fulfillments_status_enum" NOT NULL DEFAULT 'pending', "fulfilledAt" TIMESTAMP WITH TIME ZONE, "orderLineId" uuid, CONSTRAINT "REL_order_line_manual_fulfillments_line" UNIQUE ("orderLineId"), CONSTRAINT "PK_order_line_manual_fulfillments" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "order_messages" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "orderId" uuid, "sender" "public"."order_messages_sender_enum" NOT NULL, "body" text NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_order_messages_id" PRIMARY KEY ("id"))`
|
||||
);
|
||||
|
||||
// --- checkout sessions (kept after order materialization for lookup) ---
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."checkout_session_lines_deliverymode_enum" AS ENUM('auto', 'manual')`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "checkout_session_discounts" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying(32) NOT NULL, "amountFiat" numeric(12,2) NOT NULL, "sessionId" uuid, CONSTRAINT "PK_0378497bbff0d9ff832535f92c7" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "checkout_session_lines" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "variantId" uuid NOT NULL, "productId" uuid NOT NULL, "productTitle" character varying NOT NULL, "variantTitle" character varying NOT NULL, "thumbnailUrl" character varying, "qty" integer NOT NULL, "unitPriceFiat" numeric(12,2) NOT NULL, "lineSubtotalFiat" numeric(12,2) NOT NULL, "deliveryMode" "public"."checkout_session_lines_deliverymode_enum" NOT NULL, "sessionId" uuid, CONSTRAINT "PK_ca6db5cbf05b43e759bc4593ca2" PRIMARY KEY ("id"))`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "checkout_sessions" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "cancelledAt" TIMESTAMP WITH TIME ZONE, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "invoiceId" uuid, CONSTRAINT "UQ_checkout_sessions_invoice_id" UNIQUE ("invoiceId"), CONSTRAINT "PK_5730b2bbc190203a94941d82bd1" PRIMARY KEY ("id"))`
|
||||
);
|
||||
|
||||
// --- foreign keys ---
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "invoice_payments" ADD CONSTRAINT "FK_3b2a25d4269ebe9d7ca0c1001d4" FOREIGN KEY ("invoiceId") REFERENCES "invoices"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "invoice_monero_details" ADD CONSTRAINT "FK_48fcc6226a94ae8cebc91dd9864" FOREIGN KEY ("invoiceId") REFERENCES "invoices"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "orders" ADD CONSTRAINT "FK_ca23270a0d1bfb35b8d8c42346e" FOREIGN KEY ("checkoutInvoiceId") REFERENCES "invoices"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "orders" ADD CONSTRAINT "FK_f4061f63babeff4a3a48cad4708" FOREIGN KEY ("shippingInvoiceId") REFERENCES "invoices"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_lines" ADD CONSTRAINT "FK_307e8091afc1a959953d06d5ad1" FOREIGN KEY ("orderId") REFERENCES "orders"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_f2655f79325cfb8a9711968f65d" FOREIGN KEY ("orderId") REFERENCES "orders"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_line_auto_fulfillment_items" ADD CONSTRAINT "FK_e9919aa158c30955c372dfce284" FOREIGN KEY ("orderLineId") REFERENCES "order_lines"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_line_auto_fulfillment_item_attachments" ADD CONSTRAINT "FK_2f4f82681c575092f1d11dcb222" FOREIGN KEY ("itemId") REFERENCES "order_line_auto_fulfillment_items"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_line_manual_fulfillments" ADD CONSTRAINT "FK_f34278a339a91c0663fb31fd66f" FOREIGN KEY ("orderLineId") REFERENCES "order_lines"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_messages" ADD CONSTRAINT "FK_cc8ace314be4d8e541ca2e6b730" FOREIGN KEY ("orderId") REFERENCES "orders"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "checkout_session_discounts" ADD CONSTRAINT "FK_5e4f76deb4b4325876c6bbcfe75" FOREIGN KEY ("sessionId") REFERENCES "checkout_sessions"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "checkout_session_lines" ADD CONSTRAINT "FK_4a85a0cc8356f6b2a7e5802a373" FOREIGN KEY ("sessionId") REFERENCES "checkout_sessions"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "checkout_sessions" ADD CONSTRAINT "FK_d795185057be72c7d4053175ba4" FOREIGN KEY ("invoiceId") REFERENCES "invoices"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "orders" ADD CONSTRAINT "FK_a50ab800c2c16d9ca50e9cda29e" FOREIGN KEY ("checkoutSessionId") REFERENCES "checkout_sessions"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "orders" DROP CONSTRAINT "FK_a50ab800c2c16d9ca50e9cda29e"`);
|
||||
await queryRunner.query(`ALTER TABLE "checkout_sessions" DROP CONSTRAINT "FK_d795185057be72c7d4053175ba4"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "checkout_session_lines" DROP CONSTRAINT "FK_4a85a0cc8356f6b2a7e5802a373"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "checkout_session_discounts" DROP CONSTRAINT "FK_5e4f76deb4b4325876c6bbcfe75"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "order_messages" DROP CONSTRAINT "FK_cc8ace314be4d8e541ca2e6b730"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_line_manual_fulfillments" DROP CONSTRAINT "FK_f34278a339a91c0663fb31fd66f"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_line_auto_fulfillment_item_attachments" DROP CONSTRAINT "FK_2f4f82681c575092f1d11dcb222"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "order_line_auto_fulfillment_items" DROP CONSTRAINT "FK_e9919aa158c30955c372dfce284"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_f2655f79325cfb8a9711968f65d"`);
|
||||
await queryRunner.query(`ALTER TABLE "order_lines" DROP CONSTRAINT "FK_307e8091afc1a959953d06d5ad1"`);
|
||||
await queryRunner.query(`ALTER TABLE "orders" DROP CONSTRAINT "FK_f4061f63babeff4a3a48cad4708"`);
|
||||
await queryRunner.query(`ALTER TABLE "orders" DROP CONSTRAINT "FK_ca23270a0d1bfb35b8d8c42346e"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "invoice_monero_details" DROP CONSTRAINT "FK_48fcc6226a94ae8cebc91dd9864"`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "invoice_payments" DROP CONSTRAINT "FK_3b2a25d4269ebe9d7ca0c1001d4"`);
|
||||
|
||||
await queryRunner.query(`DROP TABLE "checkout_sessions"`);
|
||||
await queryRunner.query(`DROP TABLE "checkout_session_lines"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."checkout_session_lines_deliverymode_enum"`);
|
||||
await queryRunner.query(`DROP TABLE "checkout_session_discounts"`);
|
||||
|
||||
await queryRunner.query(`DROP TABLE "order_messages"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."order_messages_sender_enum"`);
|
||||
await queryRunner.query(`DROP TABLE "order_line_manual_fulfillments"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."order_line_manual_fulfillments_status_enum"`);
|
||||
await queryRunner.query(`DROP TABLE "order_line_auto_fulfillment_item_attachments"`);
|
||||
await queryRunner.query(`DROP TABLE "order_line_auto_fulfillment_items"`);
|
||||
await queryRunner.query(`DROP TABLE "order_discounts"`);
|
||||
await queryRunner.query(`DROP TABLE "order_lines"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."order_lines_deliverymode_enum"`);
|
||||
await queryRunner.query(`DROP TABLE "orders"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."orders_failurereason_enum"`);
|
||||
|
||||
await queryRunner.query(`DROP TABLE "invoice_monero_details"`);
|
||||
await queryRunner.query(`DROP TABLE "invoice_payments"`);
|
||||
await queryRunner.query(`DROP TABLE "invoices"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."invoices_paymentmethod_enum"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."invoices_reason_enum"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddOrderStaffChatLastReadAt1784500000000 implements MigrationInterface {
|
||||
name = 'AddOrderStaffChatLastReadAt1784500000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "orders" ADD "staffChatLastReadAt" TIMESTAMP WITH TIME ZONE`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "orders" DROP COLUMN "staffChatLastReadAt"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddShopNotificationSettings1784600000000 implements MigrationInterface {
|
||||
name = 'AddShopNotificationSettings1784600000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "shop_settings" ADD "notificationsEnabled" boolean NOT NULL DEFAULT false`
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" ADD "notifyOnNewOrder" boolean NOT NULL DEFAULT true`);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" ADD "notifyOnOrderMessage" boolean NOT NULL DEFAULT true`);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" ADD "simplexNotificationContactId" integer`);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" ADD "simplexNotificationLink" varchar`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" DROP COLUMN "simplexNotificationLink"`);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" DROP COLUMN "simplexNotificationContactId"`);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" DROP COLUMN "notifyOnOrderMessage"`);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" DROP COLUMN "notifyOnNewOrder"`);
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" DROP COLUMN "notificationsEnabled"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class InitializeShopSettings1784600000001 implements MigrationInterface {
|
||||
name = 'InitializeShopSettings1784600000001';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "shop_settings" ("id")
|
||||
SELECT uuid_generate_v4()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM "shop_settings")
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(): Promise<void> {}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddFaviconStorageKey1784700000000 implements MigrationInterface {
|
||||
name = 'AddFaviconStorageKey1784700000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" ADD "faviconStorageKey" character varying`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "shop_settings" DROP COLUMN "faviconStorageKey"`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user