30 lines
1.5 KiB
SQL
30 lines
1.5 KiB
SQL
-- Planla diyaloğunun taslak karşılama planı: talep kaleminin onaylanmamış dağıtımı (iç transfer: kaynak konum, satınalma: tedarikçi) ve
|
||
-- miktarı. Onay (Prc_P_MaterialRequestPlanConfirm) satırları teklif talebine ya da iç transfere çevirir ve siler.
|
||
CREATE TABLE IF NOT EXISTS public."Prc_T_MaterialRequestPlanLine"
|
||
(
|
||
"Id" uuid NOT NULL DEFAULT gen_random_uuid(),
|
||
"TenantId" uuid NULL,
|
||
"MaterialRequestItemId" uuid NOT NULL,
|
||
"PlanMethod" varchar(16) NOT NULL,
|
||
"SupplierId" uuid NULL,
|
||
"SourceLocationId" uuid NULL,
|
||
"Quantity" numeric(18, 4) NOT NULL DEFAULT 0,
|
||
"CreationTime" timestamp NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
|
||
"CreatorId" uuid NULL,
|
||
"LastModificationTime" timestamp NULL,
|
||
"LastModifierId" uuid NULL,
|
||
"IsDeleted" boolean NOT NULL DEFAULT FALSE,
|
||
"DeletionTime" timestamp NULL,
|
||
"DeleterId" uuid NULL,
|
||
CONSTRAINT "PK_Prc_T_MaterialRequestPlanLine" PRIMARY KEY ("Id")
|
||
);
|
||
|
||
CREATE INDEX IF NOT EXISTS "IX_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId" ON public."Prc_T_MaterialRequestPlanLine" ("MaterialRequestItemId");
|
||
|
||
DO $$
|
||
BEGIN
|
||
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'FK_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId') THEN
|
||
ALTER TABLE public."Prc_T_MaterialRequestPlanLine" ADD CONSTRAINT "FK_Prc_T_MaterialRequestPlanLine_MaterialRequestItemId" FOREIGN KEY ("MaterialRequestItemId") REFERENCES public."Prc_T_MaterialRequestItem" ("Id") ON DELETE CASCADE ON UPDATE NO ACTION;
|
||
END IF;
|
||
END
|
||
$$;
|