-- Modify "McuSrc" table
ALTER TABLE "public"."McuSrc" DROP CONSTRAINT "fk_McuSrc_Item", DROP COLUMN "Item_Id", ALTER COLUMN "Item_Code" TYPE character varying(50), ADD CONSTRAINT "fk_McuSrc_Item" FOREIGN KEY ("Item_Code") REFERENCES "public"."Item" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "McuSubSrc" table
ALTER TABLE "public"."McuSubSrc" DROP CONSTRAINT "fk_McuSubSrc_McuSrc", DROP COLUMN "McuSrc_Id", ALTER COLUMN "McuSrc_Code" TYPE character varying(20), ADD COLUMN "Item_Code" text NULL, ADD CONSTRAINT "fk_McuSubSrc_McuSrc" FOREIGN KEY ("McuSrc_Code") REFERENCES "public"."McuSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "MedicalActionSrc" table
ALTER TABLE "public"."MedicalActionSrc" DROP CONSTRAINT "fk_MedicalActionSrc_Item", DROP COLUMN "Item_Id", ALTER COLUMN "Item_Code" TYPE character varying(50), ADD CONSTRAINT "fk_MedicalActionSrc_Item" FOREIGN KEY ("Item_Code") REFERENCES "public"."Item" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "MedicalActionSrcItem" table
ALTER TABLE "public"."MedicalActionSrcItem" DROP CONSTRAINT "fk_MedicalActionSrcItem_Item", DROP CONSTRAINT "fk_MedicalActionSrcItem_MedicalActionSrc", DROP CONSTRAINT "fk_MedicalActionSrcItem_ProcedureSrc", DROP COLUMN "MedicalActionSrc_Id", DROP COLUMN "ProcedureSrc_Id", DROP COLUMN "Item_Id", ALTER COLUMN "MedicalActionSrc_Code" TYPE character varying(20), ALTER COLUMN "ProcedureSrc_Code" TYPE character varying(10), ALTER COLUMN "Item_Code" TYPE character varying(50), ADD CONSTRAINT "fk_MedicalActionSrcItem_Item" FOREIGN KEY ("Item_Code") REFERENCES "public"."Item" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_MedicalActionSrcItem_MedicalActionSrc" FOREIGN KEY ("MedicalActionSrc_Code") REFERENCES "public"."MedicalActionSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_MedicalActionSrcItem_ProcedureSrc" FOREIGN KEY ("ProcedureSrc_Code") REFERENCES "public"."ProcedureSrc" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
