add person-insurance, adjust person

This commit is contained in:
dpurbosakti
2025-10-16 08:12:54 +07:00
parent 8b2f03f5d1
commit a8e41f055c
8 changed files with 73 additions and 32 deletions

No files matched your search

@@ -0,0 +1,17 @@
-- Create "PersonInsurance" table
CREATE TABLE "public"."PersonInsurance" (
"Id" bigserial NOT NULL,
"CreatedAt" timestamptz NULL,
"UpdatedAt" timestamptz NULL,
"DeletedAt" timestamptz NULL,
"Person_Id" bigint NULL,
"InsuranceCompany_Id" bigint NULL,
"Ref_Number" character varying(20) NULL,
"DefaultStatus" boolean NULL,
PRIMARY KEY ("Id"),
CONSTRAINT "uni_PersonInsurance_Ref_Number" UNIQUE ("Ref_Number"),
CONSTRAINT "fk_PersonInsurance_InsuranceCompany" FOREIGN KEY ("InsuranceCompany_Id") REFERENCES "public"."InsuranceCompany" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "fk_Person_Insurances" FOREIGN KEY ("Person_Id") REFERENCES "public"."Person" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create index "idx_person_insurance" to table: "PersonInsurance"
CREATE UNIQUE INDEX "idx_person_insurance" ON "public"."PersonInsurance" ("Person_Id", "DefaultStatus");