-- Create "McuSubSrc" table
CREATE TABLE "public"."McuSubSrc" (
  "Id" bigserial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Code" character varying(20) NULL,
  "Name" character varying(50) NULL,
  "McuSrc_Id" bigint NULL,
  "Item_Id" bigint NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "uni_McuSubSrc_Code" UNIQUE ("Code"),
  CONSTRAINT "fk_McuSubSrc_Item" FOREIGN KEY ("Item_Id") REFERENCES "public"."Item" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT "fk_McuSubSrc_McuSrc" FOREIGN KEY ("McuSrc_Id") REFERENCES "public"."McuSrc" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "McuOrderSubItem" table
CREATE TABLE "public"."McuOrderSubItem" (
  "Id" bigserial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "McuSubSrc_Id" bigint NULL,
  "McuOrderItem_Id" bigint NULL,
  "Result" text NULL,
  "Status_Code" text NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "fk_McuOrderSubItem_McuOrderItem" FOREIGN KEY ("McuOrderItem_Id") REFERENCES "public"."McuOrderItem" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT "fk_McuOrderSubItem_McuSubSrc" FOREIGN KEY ("McuSubSrc_Id") REFERENCES "public"."McuSubSrc" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create index "idx_order_sub_src" to table: "McuOrderSubItem"
CREATE UNIQUE INDEX "idx_order_sub_src" ON "public"."McuOrderSubItem" ("McuSubSrc_Id", "McuOrderItem_Id");
