-- 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");
