-- Modify "Specialist" table
ALTER TABLE "public"."Specialist" DROP COLUMN "Unit_Code";
-- Rename a column from "SrcUnit_Code" to "Specialist_Code"
ALTER TABLE "public"."Chemo" RENAME COLUMN "SrcUnit_Code" TO "Specialist_Code";
-- Modify "Chemo" table
ALTER TABLE "public"."Chemo" DROP CONSTRAINT "fk_Chemo_SrcUnit", ADD CONSTRAINT "fk_Chemo_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "Doctor" table
ALTER TABLE "public"."Doctor" DROP COLUMN "Unit_Code";
-- Rename a column from "DstUnit_Code" to "Specialist_Code"
ALTER TABLE "public"."Consultation" RENAME COLUMN "DstUnit_Code" TO "Specialist_Code";
-- Rename a column from "DstDoctor_Code" to "Doctor_Code"
ALTER TABLE "public"."Consultation" RENAME COLUMN "DstDoctor_Code" TO "Doctor_Code";
-- Modify "Consultation" table
ALTER TABLE "public"."Consultation" DROP CONSTRAINT "fk_Consultation_DstDoctor", DROP CONSTRAINT "fk_Consultation_DstUnit", ADD CONSTRAINT "fk_Consultation_Doctor" FOREIGN KEY ("Doctor_Code") REFERENCES "public"."Doctor" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Consultation_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Rename a column from "Unit_Code" to "Specialist_Code"
ALTER TABLE "public"."InternalReference" RENAME COLUMN "Unit_Code" TO "Specialist_Code";
-- Modify "InternalReference" table
ALTER TABLE "public"."InternalReference" DROP CONSTRAINT "fk_InternalReference_Unit", ADD CONSTRAINT "fk_InternalReference_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Rename a column from "Unit_Code" to "Specialist_Code"
ALTER TABLE "public"."Nurse" RENAME COLUMN "Unit_Code" TO "Specialist_Code";
-- Modify "Nurse" table
ALTER TABLE "public"."Nurse" DROP CONSTRAINT "fk_Nurse_Unit", ADD CONSTRAINT "fk_Nurse_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Rename a column from "Unit_Code" to "Specialist_Code"
ALTER TABLE "public"."PracticeSchedule" RENAME COLUMN "Unit_Code" TO "Specialist_Code";
-- Modify "PracticeSchedule" table
ALTER TABLE "public"."PracticeSchedule" DROP CONSTRAINT "fk_PracticeSchedule_Unit", ADD CONSTRAINT "fk_PracticeSchedule_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "ControlLetter" table
ALTER TABLE "public"."ControlLetter" DROP COLUMN "Unit_Code";
-- Modify "Encounter" table
ALTER TABLE "public"."Encounter" DROP COLUMN "Unit_Code";
-- Modify "ProcedureRoom" table
ALTER TABLE "public"."ProcedureRoom" DROP COLUMN "Unit_Code";
-- Drop "UnitPosition" table
DROP TABLE "public"."UnitPosition";
-- Drop "Unit" table
DROP TABLE "public"."Unit";
