
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "AdmissionPackageId";

ALTER TABLE IF EXISTS public."LabServices"
    ADD COLUMN "AdmissionPackageId" integer;

-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "PackageModuleDetailId";

ALTER TABLE IF EXISTS public."LabServices"
    ADD COLUMN "PackageModuleDetailId" integer;

-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "UsedQuantity";

ALTER TABLE IF EXISTS public."LabServices"
    ADD COLUMN "UsedQuantity" integer;

-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "UsedCost";

ALTER TABLE IF EXISTS public."LabServices"
    ADD COLUMN "UsedCost" numeric(10,2);

-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP CONSTRAINT IF EXISTS "FK_ServiceOrder_AdmissionPackageId";

ALTER TABLE IF EXISTS public."LabServices"
    ADD CONSTRAINT "FK_LabServices_AdmissionPackageId" FOREIGN KEY ("AdmissionPackageId")
    REFERENCES public."AdmissionPackage" ("AdmissionPackageId") MATCH SIMPLE
    ON UPDATE NO ACTION
    ON DELETE NO ACTION
    NOT VALID;

-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP CONSTRAINT IF EXISTS "FK_ServiceOrder_PackageModuleDetailId";

ALTER TABLE IF EXISTS public."LabServices"
    ADD CONSTRAINT "FK_LabServices_PackageModuleDetailId" FOREIGN KEY ("PackageModuleDetailId")
    REFERENCES public."PackageModuleDetail" ("PackageModuleDetailId") MATCH SIMPLE
    ON UPDATE NO ACTION
    ON DELETE NO ACTION
    NOT VALID;