Files
2025-11-06 12:17:49 +07:00

91 lines
4.1 KiB
SQL

-- Create "AdmEmployeeHist" table
CREATE TABLE "public"."AdmEmployeeHist" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Encounter_Id" bigint NULL,
"Employee_Id" bigint NULL,
"StartedAt" timestamptz NULL,
"FinishedAt" timestamptz NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_AdmEmployeeHist_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "InstallationPosition" table
CREATE TABLE "public"."InstallationPosition" (
"Id" serial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Installation_Id" integer NOT NULL,
"Code" character varying(10) NOT NULL,
"Name" character varying(30) NOT NULL,
"HeadStatus" boolean NULL,
"Employee_Id" bigint NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_InstallationPosition_Code" UNIQUE ("Code"),
CONSTRAINT "fk_InstallationPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_InstallationPosition_Installation" FOREIGN KEY ("Installation_Id") REFERENCES "public"."Installation" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "ResponsibleDoctorHist" table
CREATE TABLE "public"."ResponsibleDoctorHist" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Encounter_Id" bigint NULL,
"Doctor_Id" bigint NULL,
"StartedAt" timestamptz NULL,
"FinishedAt" timestamptz NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "fk_ResponsibleDoctorHist_Doctor" FOREIGN KEY ("Doctor_Id") REFERENCES "public"."Doctor" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "SpecialistPosition" table
CREATE TABLE "public"."SpecialistPosition" (
"Id" serial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Specialist_Id" integer NOT NULL,
"Code" character varying(10) NOT NULL,
"Name" character varying(30) NOT NULL,
"HeadStatus" boolean NULL,
"Employee_Id" bigint NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_SpecialistPosition_Code" UNIQUE ("Code"),
CONSTRAINT "fk_SpecialistPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_SpecialistPosition_Specialist" FOREIGN KEY ("Specialist_Id") REFERENCES "public"."Specialist" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "SubspecialistPosition" table
CREATE TABLE "public"."SubspecialistPosition" (
"Id" serial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Subspecialist_Id" integer NOT NULL,
"Code" character varying(10) NOT NULL,
"Name" character varying(30) NOT NULL,
"HeadStatus" boolean NULL,
"Employee_Id" bigint NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_SubspecialistPosition_Code" UNIQUE ("Code"),
CONSTRAINT "fk_SubspecialistPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_SubspecialistPosition_Subspecialist" FOREIGN KEY ("Subspecialist_Id") REFERENCES "public"."Subspecialist" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "UnitPosition" table
CREATE TABLE "public"."UnitPosition" (
"Id" serial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Unit_Id" integer NOT NULL,
"Code" character varying(10) NOT NULL,
"Name" character varying(30) NOT NULL,
"HeadStatus" boolean NULL,
"Employee_Id" bigint NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_UnitPosition_Code" UNIQUE ("Code"),
CONSTRAINT "fk_UnitPosition_Employee" FOREIGN KEY ("Employee_Id") REFERENCES "public"."Employee" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_UnitPosition_Unit" FOREIGN KEY ("Unit_Id") REFERENCES "public"."Unit" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);