Feat: draft order api (#6797)
This commit is contained in:
@@ -33,16 +33,8 @@ export class Migration20240219102530 extends Migration {
|
||||
"customer_id" TEXT NULL,
|
||||
"version" INTEGER NOT NULL DEFAULT 1,
|
||||
"sales_channel_id" TEXT NULL,
|
||||
"status" text check (
|
||||
"status" IN (
|
||||
'pending',
|
||||
'completed',
|
||||
'draft',
|
||||
'archived',
|
||||
'canceled',
|
||||
'requires_action'
|
||||
)
|
||||
) NOT NULL DEFAULT 'pending',
|
||||
"status" text NOT NULL,
|
||||
"is_draft_order" BOOLEAN NOT NULL DEFAULT false,
|
||||
"email" text NULL,
|
||||
"currency_code" text NOT NULL,
|
||||
"shipping_address_id" text NULL,
|
||||
@@ -59,6 +51,28 @@ export class Migration20240219102530 extends Migration {
|
||||
ALTER TABLE "order"
|
||||
ADD COLUMN if NOT exists "deleted_at" timestamptz NULL;
|
||||
|
||||
ALTER TABLE "order"
|
||||
ADD COLUMN if NOT exists "is_draft_order" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
ALTER TABLE "order"
|
||||
ADD COLUMN if NOT exists "version" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
|
||||
ALTER TABLE "order" ALTER COLUMN status TYPE text;
|
||||
DROP TYPE IF EXISTS order_status_enum CASCADE;
|
||||
CREATE TYPE order_status_enum AS ENUM (
|
||||
'pending',
|
||||
'completed',
|
||||
'draft',
|
||||
'archived',
|
||||
'canceled',
|
||||
'requires_action'
|
||||
);
|
||||
ALTER TABLE "order" ALTER COLUMN status DROP DEFAULT;
|
||||
ALTER TABLE "order" ALTER COLUMN status TYPE order_status_enum USING (status::text::order_status_enum);
|
||||
ALTER TABLE "order" ALTER COLUMN status SET DEFAULT 'pending';
|
||||
|
||||
|
||||
ALTER TABLE "order" DROP constraint if EXISTS "FK_6ff7e874f01b478c115fdd462eb" CASCADE;
|
||||
|
||||
ALTER TABLE "order" DROP constraint if EXISTS "FK_19b0c6293443d1b464f604c3316" CASCADE;
|
||||
@@ -129,6 +143,10 @@ export class Migration20240219102530 extends Migration {
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "IDX_order_deleted_at" ON "order" (
|
||||
deleted_at
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "IDX_order_is_draft_order" ON "order" (
|
||||
is_draft_order
|
||||
)
|
||||
WHERE deleted_at IS NOT NULL;
|
||||
|
||||
@@ -284,6 +302,7 @@ export class Migration20240219102530 extends Migration {
|
||||
"raw_compare_at_unit_price" JSONB NULL,
|
||||
"unit_price" NUMERIC NOT NULL,
|
||||
"raw_unit_price" JSONB NOT NULL,
|
||||
"metadata" JSONB NULL,
|
||||
"created_at" TIMESTAMPTZ NOT NULL DEFAULT Now(),
|
||||
"updated_at" TIMESTAMPTZ NOT NULL DEFAULT Now(),
|
||||
CONSTRAINT "order_line_item_pkey" PRIMARY KEY ("id")
|
||||
@@ -423,14 +442,12 @@ export class Migration20240219102530 extends Migration {
|
||||
ALTER TABLE if exists "order"
|
||||
ADD CONSTRAINT "order_shipping_address_id_foreign" FOREIGN KEY ("shipping_address_id") REFERENCES "order_address" ("id") ON
|
||||
UPDATE CASCADE ON
|
||||
DELETE
|
||||
SET NULL;
|
||||
DELETE CASCADE;
|
||||
|
||||
ALTER TABLE if exists "order"
|
||||
ADD CONSTRAINT "order_billing_address_id_foreign" FOREIGN KEY ("billing_address_id") REFERENCES "order_address" ("id") ON
|
||||
UPDATE CASCADE ON
|
||||
DELETE
|
||||
SET NULL;
|
||||
DELETE CASCADE;
|
||||
|
||||
ALTER TABLE if exists "order_change"
|
||||
ADD CONSTRAINT "order_change_order_id_foreign" FOREIGN KEY ("order_id") REFERENCES "order" ("id") ON
|
||||
|
||||
Reference in New Issue
Block a user