-- Create "InsuranceCompany" table
CREATE TABLE "public"."InsuranceCompany" (
  "Id" serial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Code" character varying(20) NULL,
  "Name" character varying(50) NULL,
  "Regency_Code" character varying(4) NULL,
  "Address" character varying(100) NULL,
  "PhoneNumber" character varying(20) NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "uni_InsuranceCompany_Code" UNIQUE ("Code"),
  CONSTRAINT "fk_InsuranceCompany_Regency" FOREIGN KEY ("Regency_Code") REFERENCES "public"."Regency" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Create "Ethnic" table
CREATE TABLE "public"."Ethnic" (
  "Id" serial NOT NULL,
  "CreatedAt" timestamptz NULL,
  "UpdatedAt" timestamptz NULL,
  "DeletedAt" timestamptz NULL,
  "Code" character varying(20) NULL,
  "Name" character varying(50) NULL,
  PRIMARY KEY ("Id"),
  CONSTRAINT "uni_Ethnic_Code" UNIQUE ("Code")
);
-- Modify "Person" table
ALTER TABLE "public"."Person" ALTER COLUMN "Ethnic_Code" TYPE character varying(20), ADD CONSTRAINT "fk_Person_Ethnic" FOREIGN KEY ("Ethnic_Code") REFERENCES "public"."Ethnic" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
