-- Name: opportunity_rfp_detail_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.opportunity_rfp_detail_id_seq OWNED BY public.opportunity_rfp_detail.id;


--
-- TOC entry 614 (class 1259 OID 27662965)
-- Name: opportunity_rfp_details_entry; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.opportunity_rfp_details_entry (
    id integer NOT NULL,
    opportunity_id integer NOT NULL,
    activity_id integer NOT NULL,
    opportunity_activity_id integer NOT NULL,
    status_lid integer NOT NULL,
    description text,
    requirements text,
    target_qcr_date date,
    multiple_brokers_involved integer,
    is_market_allocation_done integer,
    client_expectations text,
    threats_from_existing_insurer text,
    threats_from_existing_tpa text,
    extraneous_factors text,
    strategy_plan text,
    remarks text,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    deleted_at timestamp with time zone,
    created_by integer NOT NULL,
    updated_by integer NOT NULL
);


ALTER TABLE public.opportunity_rfp_details_entry OWNER TO nl2sql_ai;

--
-- TOC entry 615 (class 1259 OID 27662972)
-- Name: opportunity_rfp_details_entry_document_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.opportunity_rfp_details_entry_document_map (
    id integer NOT NULL,
    document_id integer NOT NULL,
    opportunity_rfp_details_entry_id integer NOT NULL,
    document_type_lid integer
);


ALTER TABLE public.opportunity_rfp_details_entry_document_map OWNER TO nl2sql_ai;

--
-- TOC entry 616 (class 1259 OID 27662975)
-- Name: opportunity_rfp_details_entry_document_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.opportunity_rfp_details_entry_document_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.opportunity_rfp_details_entry_document_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9175 (class 0 OID 0)
-- Dependencies: 616
-- Name: opportunity_rfp_details_entry_document_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.opportunity_rfp_details_entry_document_map_id_seq OWNED BY public.opportunity_rfp_details_entry_document_map.id;


--
-- TOC entry 617 (class 1259 OID 27662976)
-- Name: opportunity_rfp_details_entry_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.opportunity_rfp_details_entry_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.opportunity_rfp_details_entry_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9176 (class 0 OID 0)
-- Dependencies: 617
-- Name: opportunity_rfp_details_entry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.opportunity_rfp_details_entry_id_seq OWNED BY public.opportunity_rfp_details_entry.id;


--
-- TOC entry 618 (class 1259 OID 27662977)
-- Name: opportunity_rfp_insurer_detail; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.opportunity_rfp_insurer_detail (
    id integer NOT NULL,
    insurer_id integer NOT NULL,
    insurer_location_id integer,
    insurer_branch integer,
    insurer_contact_id integer,
    preference_type_lid integer NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    deleted_at timestamp with time zone,
    created_by integer NOT NULL,
    updated_by integer NOT NULL,
    opportunity_rfp_details_entry_id integer NOT NULL
);


ALTER TABLE public.opportunity_rfp_insurer_detail OWNER TO nl2sql_ai;

--
-- TOC entry 619 (class 1259 OID 27662982)
-- Name: opportunity_rfp_insurer_detail_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.opportunity_rfp_insurer_detail_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.opportunity_rfp_insurer_detail_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9177 (class 0 OID 0)
-- Dependencies: 619
-- Name: opportunity_rfp_insurer_detail_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.opportunity_rfp_insurer_detail_id_seq OWNED BY public.opportunity_rfp_insurer_detail.id;


--
-- TOC entry 620 (class 1259 OID 27662983)
-- Name: opportunity_rfp_tpa_detail; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.opportunity_rfp_tpa_detail (
    id integer NOT NULL,
    tpa_id integer NOT NULL,
    tpa_location_id integer,
    tpa_branch integer,
    tpa_contact_id integer,
    preference_type_lid integer NOT NULL,
    opportunity_rfp_details_entry_id integer NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    deleted_at timestamp with time zone,
    created_by integer NOT NULL,
    updated_by integer NOT NULL
);


ALTER TABLE public.opportunity_rfp_tpa_detail OWNER TO nl2sql_ai;

--
-- TOC entry 621 (class 1259 OID 27662988)
-- Name: opportunity_rfp_tpa_detail_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.opportunity_rfp_tpa_detail_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.opportunity_rfp_tpa_detail_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9178 (class 0 OID 0)
-- Dependencies: 621
-- Name: opportunity_rfp_tpa_detail_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.opportunity_rfp_tpa_detail_id_seq OWNED BY public.opportunity_rfp_tpa_detail.id;


--
-- TOC entry 622 (class 1259 OID 27662989)
-- Name: opportunity_risk_location_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.opportunity_risk_location_map (
    id integer NOT NULL,
    opportunity_id integer NOT NULL,
    address_id integer NOT NULL
);


ALTER TABLE public.opportunity_risk_location_map OWNER TO nl2sql_ai;

--
-- TOC entry 623 (class 1259 OID 27662992)
-- Name: opportunity_risk_location_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.opportunity_risk_location_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.opportunity_risk_location_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9179 (class 0 OID 0)
-- Dependencies: 623
-- Name: opportunity_risk_location_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.opportunity_risk_location_map_id_seq OWNED BY public.opportunity_risk_location_map.id;


--
-- TOC entry 624 (class 1259 OID 27662993)
-- Name: org_branch; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.org_branch (
    id integer NOT NULL,
    organisation_id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    created_by character varying NOT NULL,
    updated_by character varying NOT NULL,
    deleted_at timestamp with time zone,
    status_lid integer DEFAULT 16101
);


ALTER TABLE public.org_branch OWNER TO nl2sql_ai;

--
-- TOC entry 625 (class 1259 OID 27663001)
-- Name: org_sbu; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.org_sbu (
    id integer NOT NULL,
    organisation_id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp with time zone,
    created_by integer NOT NULL,
    updated_by integer,
    deleted_at timestamp with time zone,
    status_lid integer DEFAULT 16101
);


ALTER TABLE public.org_sbu OWNER TO nl2sql_ai;

--
-- TOC entry 626 (class 1259 OID 27663008)
-- Name: org_sbu_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.org_sbu_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER SEQUENCE public.org_sbu_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9180 (class 0 OID 0)
-- Dependencies: 626
-- Name: org_sbu_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.org_sbu_id_seq OWNED BY public.org_sbu.id;


--
-- TOC entry 627 (class 1259 OID 27663009)
-- Name: org_service_tat_summary; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.org_service_tat_summary (
    id bigint NOT NULL,
    org_id integer NOT NULL,
    company_id integer NOT NULL,
    policy_id integer NOT NULL,
    service_id integer NOT NULL,
    tat_bucket_id integer NOT NULL,
    snapshot_date date NOT NULL,
    event_count integer DEFAULT 0 NOT NULL,
    bucket_score numeric(14,4) DEFAULT 0 NOT NULL,
    average_tat_days numeric(10,2),
    tat_weight numeric(10,4) DEFAULT 0 NOT NULL,
    is_compliant boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone
);


ALTER TABLE public.org_service_tat_summary OWNER TO nl2sql_ai;

--
-- TOC entry 628 (class 1259 OID 27663017)
-- Name: org_service_tat_summary_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.org_service_tat_summary_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.org_service_tat_summary_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9181 (class 0 OID 0)
-- Dependencies: 628
-- Name: org_service_tat_summary_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.org_service_tat_summary_id_seq OWNED BY public.org_service_tat_summary.id;


--
-- TOC entry 629 (class 1259 OID 27663018)
-- Name: org_vertical; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.org_vertical (
    id integer NOT NULL,
    organisation_id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    created_by character varying NOT NULL,
    updated_by character varying NOT NULL,
    deleted_at timestamp with time zone,
    status_lid integer DEFAULT 16101,
    sbu_id integer
);


ALTER TABLE public.org_vertical OWNER TO nl2sql_ai;

--
-- TOC entry 630 (class 1259 OID 27663026)
-- Name: organisation; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.organisation (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    created_by character varying(255) NOT NULL,
    updated_by character varying(255) NOT NULL,
    country_id integer,
    deleted_at timestamp with time zone,
    status_lid integer DEFAULT 16101,
    parent_organisation_id integer,
    organisation_key character varying(255)
);


ALTER TABLE public.organisation OWNER TO nl2sql_ai;

--
-- TOC entry 631 (class 1259 OID 27663034)
-- Name: organisation_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.organisation_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.organisation_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9182 (class 0 OID 0)
-- Dependencies: 631
-- Name: organisation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.organisation_id_seq OWNED BY public.organisation.id;


--
-- TOC entry 632 (class 1259 OID 27663035)
-- Name: orgnisation_branch_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.orgnisation_branch_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.orgnisation_branch_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9183 (class 0 OID 0)
-- Dependencies: 632
-- Name: orgnisation_branch_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.orgnisation_branch_id_seq OWNED BY public.org_branch.id;


--
-- TOC entry 633 (class 1259 OID 27663036)
-- Name: orgnisation_vertical_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.orgnisation_vertical_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.orgnisation_vertical_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9184 (class 0 OID 0)
-- Dependencies: 633
-- Name: orgnisation_vertical_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.orgnisation_vertical_id_seq OWNED BY public.org_vertical.id;


--
-- TOC entry 634 (class 1259 OID 27663037)
-- Name: password_rules; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.password_rules (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    is_required boolean DEFAULT false,
    min_chars integer,
    max_chars integer,
    regex character varying(500),
    disallowed_chars character varying(100),
    error_message character varying(255) NOT NULL,
    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    created_by character varying(100),
    updated_by character varying(100)
);


ALTER TABLE public.password_rules OWNER TO nl2sql_ai;

--
-- TOC entry 635 (class 1259 OID 27663045)
-- Name: password_rules_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.password_rules_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.password_rules_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9185 (class 0 OID 0)
-- Dependencies: 635
-- Name: password_rules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.password_rules_id_seq OWNED BY public.password_rules.id;


--
-- TOC entry 636 (class 1259 OID 27663046)
-- Name: performance_output; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.performance_output (
    id integer NOT NULL,
    user_id integer NOT NULL,
    entity_type character varying(50),
    kpi character varying(50),
    type_of_target character varying(50),
    value_of_target numeric(15,2) DEFAULT 0,
    entity_count numeric(15,2) DEFAULT 0,
    performance_month date,
    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp without time zone
);


ALTER TABLE public.performance_output OWNER TO nl2sql_ai;

--
-- TOC entry 637 (class 1259 OID 27663052)
-- Name: performance_output_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.performance_output_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.performance_output_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9186 (class 0 OID 0)
-- Dependencies: 637
-- Name: performance_output_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.performance_output_id_seq OWNED BY public.performance_output.id;


--
-- TOC entry 638 (class 1259 OID 27663053)
-- Name: policy; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy (
    id integer NOT NULL,
    policy_name character varying(255) NOT NULL,
    policy_type_lid integer NOT NULL,
    opportunity_id integer,
    company_id integer NOT NULL,
    policy_from date NOT NULL,
    policy_to date NOT NULL,
    provisional_policy_no character varying(255),
    sum_insured bigint,
    premium_at_inception bigint,
    gst_percentage numeric(19,2),
    gst numeric(5,2),
    insurer_policy_number character varying(255),
    commission_terrorism numeric(19,2),
    policy_configuration json,
    configuration_status_lid integer,
    enrollment_status_lid integer,
    status_lid integer NOT NULL,
    created_by integer NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_by integer,
    updated_at timestamp with time zone DEFAULT now(),
    basic_brokerage_percentage numeric(5,2),
    policy_type integer,
    mig_sum_insured numeric(19,2),
    mig_premium_at_inception numeric(19,2),
    country_id integer,
    is_mined boolean DEFAULT false,
    opportunity_type character varying(2) DEFAULT 'SO'::character varying,
    brokerage_amount numeric(12,2) DEFAULT 0,
    insurer_endorsement_number character varying(255),
    date_of_income date,
    gst_amount numeric(19,2),
    net_premium numeric(19,2),
    terrorism_amount numeric(19,2),
    other_amount numeric(19,2),
    gross_premium numeric(19,2),
    brokerage_amount_asper_iwork numeric(19,2),
    brokerage_amount_asper_isg numeric(19,2),
    fee_amount numeric(19,2),
    od_percentage numeric(5,2),
    tp_percentage numeric(5,2),
    net_percentage numeric(5,2),
    share_percentage numeric(5,2),
    terrorism_brokerage_percentage numeric(5,2),
    income_type_lid integer,
    deal_confirmed_lid integer,
    policy_group_type_lid integer,
    income_month date,
    date_of_income_from_iwork date,
    owner_id integer,
    mig_ref_no character varying(255),
    premium_collected numeric DEFAULT 0,
    ingested_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    ingested_mode character varying(255) DEFAULT 'APPLICATION'::character varying,
    brokerage_collected numeric(19,2),
    rcon_status character varying(50),
    rcon_brokerage numeric(12,2),
    rcon_outcome character varying(50),
    pending_brokerage numeric(12,2),
    fee_percentage numeric(5,2),
    other_percentage numeric(5,2),
    srcc_percentage numeric(5,2),
    srcc_amount numeric(19,2),
    admin_charges_percentage numeric(5,2),
    admin_charges numeric(19,2),
    cess_percentage numeric(5,2),
    cess_amount numeric(19,2),
    total_gross_premium_inc_tax_charges numeric(19,2),
    basic_premium numeric(19,2),
    basic_premium_percentage numeric(5,2),
    tc_brokerage_amount numeric(19,2),
    basic_brokerage_amount numeric(19,2),
    srcc_brokerage_amount numeric(19,2),
    am_id integer,
    isg_id integer,
    policy_details_status_lid integer,
    policy_covers_status_lid integer,
    policy_cd_status_lid integer,
    policy_details_approved_by integer,
    policy_covers_approved_by integer,
    policy_cd_approved_by integer,
    is_policy_mined_lid integer,
    service_level_lid integer,
    iwork_unique_id character varying(255),
    total_brokerage_amount numeric(19,2)
);


ALTER TABLE public.policy OWNER TO nl2sql_ai;

--
-- TOC entry 639 (class 1259 OID 27663066)
-- Name: policy_asset; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_asset (
    id integer NOT NULL,
    cover_code character varying(50) NOT NULL,
    risk_location_type character varying(100) NOT NULL,
    risk_location_details text,
    category character varying(100) NOT NULL,
    coverage_type character varying(100) NOT NULL,
    quantity integer,
    uom character varying(100) NOT NULL
);


ALTER TABLE public.policy_asset OWNER TO nl2sql_ai;

--
-- TOC entry 640 (class 1259 OID 27663071)
-- Name: policy_asset_endorsement; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_asset_endorsement (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    company_id integer NOT NULL,
    endorsement_type character varying(50),
    endorsement_date timestamp without time zone,
    insurer_endorsement_number character varying(255),
    insurer_endorsement_date timestamp with time zone,
    endorsement_entry_date timestamp with time zone,
    endorsment_file_id integer,
    endorsement_asset_count integer DEFAULT 0,
    ack_file_id integer,
    endorsement_ack_count integer DEFAULT 0,
    sum_insured numeric(18,2),
    premium_at_inception numeric(18,2),
    gross_premium numeric(18,2),
    net_premium numeric(18,2),
    gst_amount numeric(18,2),
    terrorism_amount numeric(18,2),
    date_of_income timestamp with time zone,
    income_type_lid integer,
    basic_brokerage_amount numeric(18,2),
    brokerage_amount_asper_iwork numeric(18,2),
    brokerage_amount_asper_isg numeric(18,2),
    fee_amount numeric(18,2),
    commission_terrorism_amount numeric(18,2),
    other_amount numeric(18,2),
    od_percentage numeric(5,2),
    tp_percentage numeric(5,2),
    net_percentage numeric(5,2),
    share_percentage numeric(5,2),
    terrorism_brokerage_percentage numeric(5,2),
    deal_confirmed_lid integer,
    remarks text,
    financial_non_financially character varying(50),
    created_by integer,
    updated_by integer,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    basic_brokerage_percentage numeric(5,2),
    income_month timestamp with time zone,
    tpa_document_id integer,
    tpa_processed_count integer DEFAULT 0,
    tpa_acknowledged_date timestamp with time zone,
    tpa_error_count integer DEFAULT 0 NOT NULL,
    tpa_error_file_id integer,
    mig_ref_no character varying(255),
    premium_collected numeric DEFAULT 0,
    ingested_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    ingested_mode character varying(255),
    brokerage_collected numeric(19,2),
    endorsement_status character varying(50),
    current_endorsement_step integer,
    os_ticket_number character varying(50),
    provisional_endorsement_number character varying(50),
    insurer_communication_date timestamp with time zone,
    insurer_communication_details text,
    insurer_endorsed_employee_count integer,
    insurer_endorsed_dependent_count integer,
    endorsement_effective_date timestamp with time zone,
    insurer_acknowledgement_number character varying(50),
    client_confirmation_message text,
    client_confirmation_date timestamp with time zone,
    tpa_upload_remarks text,
    endorsment_sub_asset_count integer,
    endorsement_addition_count integer,
    endorsement_deletion_count integer,
    is_inception boolean
);


ALTER TABLE public.policy_asset_endorsement OWNER TO nl2sql_ai;

--
-- TOC entry 641 (class 1259 OID 27663084)
-- Name: policy_asset_endorsement_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_asset_endorsement_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_asset_endorsement_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9187 (class 0 OID 0)
-- Dependencies: 641
-- Name: policy_asset_endorsement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_asset_endorsement_id_seq OWNED BY public.policy_asset_endorsement.id;


--
-- TOC entry 642 (class 1259 OID 27663085)
-- Name: policy_asset_endorsement_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_asset_endorsement_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    cover_code character varying(50) NOT NULL,
    endorsement_addition_batch_id integer,
    endorsement_deletion_batch_id integer,
    endorsement_status character varying(100),
    effective_date timestamp with time zone,
    deletion_effective_date timestamp with time zone,
    rate character varying(50) NOT NULL,
    sum_insured numeric(15,2),
    premium numeric(15,2),
    endorsement_addition_id integer,
    endorsement_deletion_id integer
);


ALTER TABLE public.policy_asset_endorsement_map OWNER TO nl2sql_ai;

--
-- TOC entry 643 (class 1259 OID 27663088)
-- Name: policy_asset_endorsement_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_asset_endorsement_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_asset_endorsement_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9188 (class 0 OID 0)
-- Dependencies: 643
-- Name: policy_asset_endorsement_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_asset_endorsement_map_id_seq OWNED BY public.policy_asset_endorsement_map.id;


--
-- TOC entry 644 (class 1259 OID 27663089)
-- Name: policy_asset_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_asset_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_asset_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9189 (class 0 OID 0)
-- Dependencies: 644
-- Name: policy_asset_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_asset_id_seq OWNED BY public.policy_asset.id;


--
-- TOC entry 645 (class 1259 OID 27663090)
-- Name: policy_audit_log; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_audit_log (
    id integer NOT NULL,
    policy_id integer,
    policy_configuration_id integer,
    entity_type character varying(100),
    entity_id integer,
    action character varying(100) NOT NULL,
    performed_by integer,
    remarks text,
    metadata jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone
);


ALTER TABLE public.policy_audit_log OWNER TO nl2sql_ai;

--
-- TOC entry 646 (class 1259 OID 27663096)
-- Name: policy_audit_log_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_audit_log_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_audit_log_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9190 (class 0 OID 0)
-- Dependencies: 646
-- Name: policy_audit_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_audit_log_id_seq OWNED BY public.policy_audit_log.id;


--
-- TOC entry 647 (class 1259 OID 27663097)
-- Name: policy_cd_number_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_cd_number_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    cd_id integer NOT NULL,
    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
);


ALTER TABLE public.policy_cd_number_map OWNER TO nl2sql_ai;

--
-- TOC entry 648 (class 1259 OID 27663102)
-- Name: policy_cd_number_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_cd_number_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_cd_number_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9191 (class 0 OID 0)
-- Dependencies: 648
-- Name: policy_cd_number_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_cd_number_map_id_seq OWNED BY public.policy_cd_number_map.id;


--
-- TOC entry 649 (class 1259 OID 27663103)
-- Name: policy_claim; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_claim (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    employee_id integer,
    employee_tpa_id character varying(100),
    claim_insured_id character varying(100),
    dependent_id integer,
    clm_hospital character varying(255),
    clm_doa date,
    clm_dod date,
    claim_dt date,
    clm_type character varying(50),
    claim_amount numeric,
    claim_description text,
    claim_status character varying(50),
    clm_pre_auth_id character varying(100),
    claim_checklist text,
    clm_bill_details text,
    clm_allowed_amt numeric,
    clm_pre_auth_date date,
    clm_pre_auth_amt numeric,
    clm_allowed_id character varying(100),
    claim_checklist_count integer,
    user_id character varying(100),
    source_file_upload_id integer,
    deleted_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    company_id integer,
    opportunity_id integer,
    claim_number character varying(50),
    active_activity character varying(255),
    created_by integer,
    updated_by integer
);


ALTER TABLE public.policy_claim OWNER TO nl2sql_ai;

--
-- TOC entry 650 (class 1259 OID 27663110)
-- Name: policy_claim_settlement; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_claim_settlement (
    id integer NOT NULL,
    claim_id integer NOT NULL,
    source_file_upload_id integer,
    clm_sett_no character varying(100),
    clm_sett_amt numeric,
    clm_sett_date date,
    clm_sett_details text,
    clm_dis_amt numeric,
    clm_sett_chq_bnk character varying(100),
    clm_sett_chq_dt date,
    clm_sett_chq_no character varying(100),
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    claim_activity_id integer,
    approved_by character varying(255),
    mode_of_settlement_key character varying(255),
    status_key character varying(255),
    created_by integer,
    updated_by integer
);


ALTER TABLE public.policy_claim_settlement OWNER TO nl2sql_ai;

--
-- TOC entry 651 (class 1259 OID 27663117)
-- Name: policy_configuration; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_configuration (
    id integer NOT NULL,
    company_id integer NOT NULL,
    policy_type_lid integer NOT NULL,
    policy_id integer NOT NULL,
    policy_configuration_status_lid integer NOT NULL,
    policy_step integer NOT NULL,
    policy_configuration jsonb NOT NULL,
    remarks text,
    version integer DEFAULT 1,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    deleted_at timestamp with time zone,
    approver_id integer,
    rejected_by_id integer
);


ALTER TABLE public.policy_configuration OWNER TO nl2sql_ai;

--
-- TOC entry 652 (class 1259 OID 27663125)
-- Name: policy_configuration_component_relation_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_configuration_component_relation_map (
    id integer NOT NULL,
    policy_configuration_component_detail_id integer NOT NULL,
    relation_type character varying(100) NOT NULL
);


ALTER TABLE public.policy_configuration_component_relation_map OWNER TO nl2sql_ai;

--
-- TOC entry 653 (class 1259 OID 27663128)
-- Name: policy_configuration_component_relation_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_configuration_component_relation_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_configuration_component_relation_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9192 (class 0 OID 0)
-- Dependencies: 653
-- Name: policy_configuration_component_relation_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_configuration_component_relation_map_id_seq OWNED BY public.policy_configuration_component_relation_map.id;


--
-- TOC entry 654 (class 1259 OID 27663129)
-- Name: policy_configuration_components_detail; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_configuration_components_detail (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    company_id integer NOT NULL,
    type character varying(100),
    label character varying(100),
    premium_per_life boolean,
    multiple_sum_insured_label character varying(100),
    sum_insured_model character varying(100),
    show_company_contribution boolean,
    created_by integer,
    updated_by integer,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    provisional_policy_number character varying(255),
    insurer_policy_number character varying(255),
    iirm_policy_number character varying(255),
    club_sum_insured_lid integer
);


ALTER TABLE public.policy_configuration_components_detail OWNER TO nl2sql_ai;

--
-- TOC entry 655 (class 1259 OID 27663136)
-- Name: policy_configuration_components_detail_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_configuration_components_detail_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_configuration_components_detail_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9193 (class 0 OID 0)
-- Dependencies: 655
-- Name: policy_configuration_components_detail_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_configuration_components_detail_id_seq OWNED BY public.policy_configuration_components_detail.id;


--
-- TOC entry 656 (class 1259 OID 27663137)
-- Name: policy_configuration_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_configuration_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_configuration_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9194 (class 0 OID 0)
-- Dependencies: 656
-- Name: policy_configuration_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_configuration_id_seq OWNED BY public.policy_configuration.id;


--
-- TOC entry 657 (class 1259 OID 27663138)
-- Name: policy_configuration_template_doc_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_configuration_template_doc_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    document_id integer NOT NULL
);


ALTER TABLE public.policy_configuration_template_doc_map OWNER TO nl2sql_ai;

--
-- TOC entry 658 (class 1259 OID 27663141)
-- Name: policy_configuration_template_doc_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_configuration_template_doc_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_configuration_template_doc_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9195 (class 0 OID 0)
-- Dependencies: 658
-- Name: policy_configuration_template_doc_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_configuration_template_doc_map_id_seq OWNED BY public.policy_configuration_template_doc_map.id;


--
-- TOC entry 659 (class 1259 OID 27663142)
-- Name: policy_confirmation_document_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_confirmation_document_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_confirmation_document_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9196 (class 0 OID 0)
-- Dependencies: 659
-- Name: policy_confirmation_document_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_confirmation_document_map_id_seq OWNED BY public.opportunity_policy_confirmation_document_map.id;


--
-- TOC entry 660 (class 1259 OID 27663143)
-- Name: policy_cover_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_cover_map (
    id integer NOT NULL,
    policy_id integer,
    cover_template_id integer NOT NULL,
    cover_name text NOT NULL,
    cover_response json,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    covers_meta jsonb
);


ALTER TABLE public.policy_cover_map OWNER TO nl2sql_ai;

--
-- TOC entry 661 (class 1259 OID 27663150)
-- Name: policy_cover_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_cover_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_cover_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9197 (class 0 OID 0)
-- Dependencies: 661
-- Name: policy_cover_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_cover_map_id_seq OWNED BY public.policy_cover_map.id;


--
-- TOC entry 662 (class 1259 OID 27663151)
-- Name: policy_docket_document_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_docket_document_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_docket_document_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9198 (class 0 OID 0)
-- Dependencies: 662
-- Name: policy_docket_document_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_docket_document_map_id_seq OWNED BY public.opportunity_policy_docket_document_map.id;


--
-- TOC entry 663 (class 1259 OID 27663152)
-- Name: policy_employee_claim_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_employee_claim_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_employee_claim_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9199 (class 0 OID 0)
-- Dependencies: 663
-- Name: policy_employee_claim_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_employee_claim_id_seq OWNED BY public.policy_claim.id;


--
-- TOC entry 664 (class 1259 OID 27663153)
-- Name: policy_employee_claim_settlement_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_employee_claim_settlement_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_employee_claim_settlement_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9200 (class 0 OID 0)
-- Dependencies: 664
-- Name: policy_employee_claim_settlement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_employee_claim_settlement_id_seq OWNED BY public.policy_claim_settlement.id;


--
-- TOC entry 665 (class 1259 OID 27663154)
-- Name: policy_employee_enrollment_choice; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_employee_enrollment_choice (
    id integer NOT NULL,
    employee_enrollment_id integer NOT NULL,
    sum_insured numeric NOT NULL,
    premium numeric NOT NULL,
    company_pay numeric NOT NULL,
    employee_pay numeric NOT NULL,
    policy_component_action_type character varying(100) NOT NULL,
    policy_component_action_type_id integer,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    policy_component_action_label character varying(100),
    parent_policy_component_action_type_id integer,
    premium_per_life boolean DEFAULT false,
    sum_insured_model character varying(20),
    sum_insured_model_property character varying(100),
    min_sum_insured_value numeric(15,2) DEFAULT 0,
    max_sum_insured_value numeric(15,2) DEFAULT 0
);


ALTER TABLE public.policy_employee_enrollment_choice OWNER TO nl2sql_ai;

--
-- TOC entry 666 (class 1259 OID 27663164)
-- Name: policy_employee_components_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_employee_components_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_employee_components_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9201 (class 0 OID 0)
-- Dependencies: 666
-- Name: policy_employee_components_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_employee_components_id_seq OWNED BY public.policy_employee_enrollment_choice.id;


--
-- TOC entry 667 (class 1259 OID 27663165)
-- Name: policy_employee_endorsement; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_employee_endorsement (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    employee_id integer NOT NULL,
    company_id integer NOT NULL,
    employee_endorsement_status_key character varying(50) NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    endorsement_id integer,
    endorsement_addition_file_id integer,
    endorsement_deletion_file_id integer,
    endorsement_addition_created_at timestamp without time zone,
    endorsement_deleted_created_at timestamp without time zone,
    deletion_endorsement_id integer
);


ALTER TABLE public.policy_employee_endorsement OWNER TO nl2sql_ai;

--
-- TOC entry 668 (class 1259 OID 27663170)
-- Name: policy_employee_endorsement_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_employee_endorsement_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_employee_endorsement_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9202 (class 0 OID 0)
-- Dependencies: 668
-- Name: policy_employee_endorsement_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_employee_endorsement_id_seq OWNED BY public.policy_employee_endorsement.id;


--
-- TOC entry 669 (class 1259 OID 27663171)
-- Name: policy_employee_enrollment; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_employee_enrollment (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    employee_id integer NOT NULL,
    company_id integer NOT NULL,
    employee_enrollment_status_key character varying(50) NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    sum_insured numeric DEFAULT 0,
    balance numeric DEFAULT 0,
    deleted_at timestamp with time zone,
    total_premium numeric DEFAULT 0,
    total_company_pay numeric DEFAULT 0,
    total_employee_pay numeric DEFAULT 0,
    last_paid_net_premium numeric(19,2) DEFAULT 0,
    last_paid_gross_premium numeric(19,2) DEFAULT 0
);


ALTER TABLE public.policy_employee_enrollment OWNER TO nl2sql_ai;

--
-- TOC entry 670 (class 1259 OID 27663185)
-- Name: policy_employee_enrollment_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_employee_enrollment_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_employee_enrollment_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9203 (class 0 OID 0)
-- Dependencies: 670
-- Name: policy_employee_enrollment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_employee_enrollment_id_seq OWNED BY public.policy_employee_enrollment.id;


--
-- TOC entry 671 (class 1259 OID 27663186)
-- Name: policy_endorsement_template_doc_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_endorsement_template_doc_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    insurer_id integer NOT NULL,
    document_id integer NOT NULL
);


ALTER TABLE public.policy_endorsement_template_doc_map OWNER TO nl2sql_ai;

--
-- TOC entry 672 (class 1259 OID 27663189)
-- Name: policy_endorsement_template_doc_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_endorsement_template_doc_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_endorsement_template_doc_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9204 (class 0 OID 0)
-- Dependencies: 672
-- Name: policy_endorsement_template_doc_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_endorsement_template_doc_map_id_seq OWNED BY public.policy_endorsement_template_doc_map.id;


--
-- TOC entry 673 (class 1259 OID 27663190)
-- Name: policy_enrollment_dependent; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_enrollment_dependent (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    employee_id integer NOT NULL,
    name character varying(100) NOT NULL,
    relation character varying(50) NOT NULL,
    date_of_birth date,
    gender character varying(20),
    created_by integer DEFAULT 0 NOT NULL,
    updated_by integer DEFAULT 0 NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    deleted_at timestamp with time zone,
    endorsement_addition_batch_id integer,
    endorsement_deletion_batch_id integer,
    endorsement_status_key character varying(50),
    enrollment_addition_batch_id integer,
    enrollment_deletion_batch_id integer,
    effective_date date,
    relationship_type character varying(100),
    dependent_tpa_id character varying(100),
    endorsement_addition_created_at timestamp without time zone,
    endorsement_deletion_created_at timestamp without time zone,
    addition_endorsement_id integer,
    deletion_endorsement_id integer,
    claim_status character varying(10)
);


ALTER TABLE public.policy_enrollment_dependent OWNER TO nl2sql_ai;

--
-- TOC entry 674 (class 1259 OID 27663197)
-- Name: policy_enrollment_dependent_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_enrollment_dependent_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_enrollment_dependent_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9205 (class 0 OID 0)
-- Dependencies: 674
-- Name: policy_enrollment_dependent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_enrollment_dependent_id_seq OWNED BY public.policy_enrollment_dependent.id;


--
-- TOC entry 675 (class 1259 OID 27663198)
-- Name: policy_enrollment_employee; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_enrollment_employee (
    id integer NOT NULL,
    employee_company_id character varying(100) NOT NULL,
    employee_name character varying(100) NOT NULL,
    full_name character varying(100),
    date_of_birth date,
    gender character varying(20),
    email character varying(100),
    phone_number character varying(20),
    ctc numeric,
    designation character varying(100),
    relation_group character varying(100),
    marital_status character varying(20),
    additional_params jsonb,
    created_by integer DEFAULT 0 NOT NULL,
    updated_by integer DEFAULT 0 NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    deleted_at timestamp with time zone,
    user_id integer,
    enrollment_addition_batch_id integer,
    enrollment_deletion_batch_id integer,
    company_employee_id character varying(100),
    employee_tpa_id character varying(100),
    company_id integer
);


ALTER TABLE public.policy_enrollment_employee OWNER TO nl2sql_ai;

--
-- TOC entry 676 (class 1259 OID 27663207)
-- Name: policy_enrollment_employee_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_enrollment_employee_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_enrollment_employee_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9206 (class 0 OID 0)
-- Dependencies: 676
-- Name: policy_enrollment_employee_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_enrollment_employee_id_seq OWNED BY public.policy_enrollment_employee.id;


--
-- TOC entry 677 (class 1259 OID 27663208)
-- Name: policy_enrollment_employee_policy_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_enrollment_employee_policy_map (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    policy_id integer NOT NULL,
    enrollment_start_date date,
    enrollment_end_date date,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    endorsement_addition_batch_id integer,
    endorsement_deletion_batch_id integer,
    endorsement_status_key character varying(50),
    employee_tpa_id character varying(100),
    additional_params jsonb,
    enrollment_addition_batch_id integer,
    enrollment_deletion_batch_id integer,
    effective_date date,
    deleted_at timestamp with time zone,
    claim_status character varying(10)
);


ALTER TABLE public.policy_enrollment_employee_policy_map OWNER TO nl2sql_ai;

--
-- TOC entry 678 (class 1259 OID 27663215)
-- Name: policy_enrollment_employee_policy_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_enrollment_employee_policy_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_enrollment_employee_policy_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9207 (class 0 OID 0)
-- Dependencies: 678
-- Name: policy_enrollment_employee_policy_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_enrollment_employee_policy_map_id_seq OWNED BY public.policy_enrollment_employee_policy_map.id;


--
-- TOC entry 679 (class 1259 OID 27663216)
-- Name: policy_enrollment_template_doc_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_enrollment_template_doc_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    document_id integer NOT NULL
);


ALTER TABLE public.policy_enrollment_template_doc_map OWNER TO nl2sql_ai;

--
-- TOC entry 680 (class 1259 OID 27663219)
-- Name: policy_enrollment_template_doc_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_enrollment_template_doc_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_enrollment_template_doc_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9208 (class 0 OID 0)
-- Dependencies: 680
-- Name: policy_enrollment_template_doc_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_enrollment_template_doc_map_id_seq OWNED BY public.policy_enrollment_template_doc_map.id;


--
-- TOC entry 681 (class 1259 OID 27663220)
-- Name: policy_enrollment_upload_summary; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_enrollment_upload_summary (
    id integer NOT NULL,
    document_processing_file_id integer NOT NULL,
    policy_id integer NOT NULL,
    source_file_upload_id integer NOT NULL,
    error_file_upload_id integer,
    success_count integer NOT NULL,
    error_count integer NOT NULL,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    success_file_upload_id integer,
    batch_id integer,
    process_count integer DEFAULT 0,
    endorsement_id integer
);


ALTER TABLE public.policy_enrollment_upload_summary OWNER TO nl2sql_ai;

--
-- TOC entry 682 (class 1259 OID 27663226)
-- Name: policy_enrollment_upload_summary_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_enrollment_upload_summary_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_enrollment_upload_summary_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9209 (class 0 OID 0)
-- Dependencies: 682
-- Name: policy_enrollment_upload_summary_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_enrollment_upload_summary_id_seq OWNED BY public.policy_enrollment_upload_summary.id;


--
-- TOC entry 683 (class 1259 OID 27663227)
-- Name: policy_faq_uploads; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_faq_uploads (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    file_id integer NOT NULL,
    file_name character varying(255) NOT NULL,
    file_path character varying(500) NOT NULL,
    faq_count integer NOT NULL,
    uploaded_by integer NOT NULL,
    uploaded_at timestamp without time zone DEFAULT now(),
    status_lkey character varying(50) DEFAULT 'FAQ_UPLOAD_FILE_PROCESSING'::character varying
);


ALTER TABLE public.policy_faq_uploads OWNER TO nl2sql_ai;

--
-- TOC entry 684 (class 1259 OID 27663234)
-- Name: policy_faq_uploads_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_faq_uploads_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_faq_uploads_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9210 (class 0 OID 0)
-- Dependencies: 684
-- Name: policy_faq_uploads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_faq_uploads_id_seq OWNED BY public.policy_faq_uploads.id;


--
-- TOC entry 685 (class 1259 OID 27663235)
-- Name: policy_faqs; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_faqs (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    category character varying(100) NOT NULL,
    question text NOT NULL,
    answer text NOT NULL,
    is_active boolean DEFAULT true,
    created_by integer NOT NULL,
    created_at timestamp without time zone DEFAULT now(),
    updated_by integer,
    updated_at timestamp without time zone
);


ALTER TABLE public.policy_faqs OWNER TO nl2sql_ai;

--
-- TOC entry 686 (class 1259 OID 27663242)
-- Name: policy_faqs_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_faqs_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_faqs_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9211 (class 0 OID 0)
-- Dependencies: 686
-- Name: policy_faqs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_faqs_id_seq OWNED BY public.policy_faqs.id;


--
-- TOC entry 687 (class 1259 OID 27663243)
-- Name: policy_feature_document_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_feature_document_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    document_id integer NOT NULL,
    status character varying(20) NOT NULL,
    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    created_by integer NOT NULL,
    updated_by integer NOT NULL,
    deleted_at timestamp without time zone,
    deleted_by integer
);


ALTER TABLE public.policy_feature_document_map OWNER TO nl2sql_ai;

--
-- TOC entry 688 (class 1259 OID 27663248)
-- Name: policy_feature_document_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_feature_document_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_feature_document_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9212 (class 0 OID 0)
-- Dependencies: 688
-- Name: policy_feature_document_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_feature_document_map_id_seq OWNED BY public.policy_feature_document_map.id;


--
-- TOC entry 689 (class 1259 OID 27663249)
-- Name: policy_hard_copy_document_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_hard_copy_document_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_hard_copy_document_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9213 (class 0 OID 0)
-- Dependencies: 689
-- Name: policy_hard_copy_document_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_hard_copy_document_map_id_seq OWNED BY public.opportunity_policy_hard_copy_document_map.id;


--
-- TOC entry 690 (class 1259 OID 27663250)
-- Name: policy_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9214 (class 0 OID 0)
-- Dependencies: 690
-- Name: policy_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_id_seq OWNED BY public.policy.id;


--
-- TOC entry 691 (class 1259 OID 27663251)
-- Name: policy_insurer_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_insurer_map (
    id integer NOT NULL,
    policy_id integer,
    insurer_participation_type_lid integer NOT NULL,
    insurer_id integer NOT NULL,
    insurer_branch_id integer,
    insurer_contact_id integer,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    share_percentage numeric,
    share_amount numeric,
    brokerage_percentage numeric(5,2),
    brokerage_amount numeric(19,2),
    insurer_location_id integer,
    deleted_at timestamp with time zone,
    terrorism_brokerage_percentage numeric(5,2),
    terrorism_brokerage_amount numeric(19,2),
    total_brokerage_amount numeric(19,2)
);


ALTER TABLE public.policy_insurer_map OWNER TO nl2sql_ai;

--
-- TOC entry 692 (class 1259 OID 27663258)
-- Name: policy_insurer_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_insurer_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_insurer_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9215 (class 0 OID 0)
-- Dependencies: 692
-- Name: policy_insurer_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_insurer_map_id_seq OWNED BY public.policy_insurer_map.id;


--
-- TOC entry 693 (class 1259 OID 27663259)
-- Name: policy_participant_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_participant_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    participant_id integer NOT NULL,
    participant_type character varying(100)
);


ALTER TABLE public.policy_participant_map OWNER TO nl2sql_ai;

--
-- TOC entry 694 (class 1259 OID 27663262)
-- Name: policy_participant_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_participant_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_participant_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9216 (class 0 OID 0)
-- Dependencies: 694
-- Name: policy_participant_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_participant_map_id_seq OWNED BY public.policy_participant_map.id;


--
-- TOC entry 695 (class 1259 OID 27663263)
-- Name: policy_premium_installment_schedules; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_premium_installment_schedules (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    installment_1 date,
    installment_2 date,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    installment_amount numeric
);


ALTER TABLE public.policy_premium_installment_schedules OWNER TO nl2sql_ai;

--
-- TOC entry 696 (class 1259 OID 27663270)
-- Name: policy_premium_installment_schedules_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_premium_installment_schedules_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_premium_installment_schedules_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9217 (class 0 OID 0)
-- Dependencies: 696
-- Name: policy_premium_installment_schedules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_premium_installment_schedules_id_seq OWNED BY public.policy_premium_installment_schedules.id;


--
-- TOC entry 697 (class 1259 OID 27663271)
-- Name: policy_risk_location_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_risk_location_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    address_id integer NOT NULL
);


ALTER TABLE public.policy_risk_location_map OWNER TO nl2sql_ai;

--
-- TOC entry 698 (class 1259 OID 27663274)
-- Name: policy_risk_location_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_risk_location_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_risk_location_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9218 (class 0 OID 0)
-- Dependencies: 698
-- Name: policy_risk_location_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_risk_location_map_id_seq OWNED BY public.policy_risk_location_map.id;


--
-- TOC entry 699 (class 1259 OID 27663275)
-- Name: policy_sub_asset; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_sub_asset (
    id integer NOT NULL,
    main_cover_code character varying(50) NOT NULL,
    sub_cover_description text,
    sub_limit_type character varying(100)
);


ALTER TABLE public.policy_sub_asset OWNER TO nl2sql_ai;

--
-- TOC entry 700 (class 1259 OID 27663280)
-- Name: policy_sub_asset_endorsement_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_sub_asset_endorsement_map (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    cover_code character varying(50) NOT NULL,
    sub_asset_id integer NOT NULL,
    endorsement_addition_batch_id integer,
    endorsement_deletion_batch_id integer,
    endorsement_status character varying(100),
    effective_date timestamp with time zone,
    deletion_effective_date timestamp with time zone,
    sub_limit_amount numeric(15,2),
    endorsement_addition_id integer,
    endorsement_deletion_id integer
);


ALTER TABLE public.policy_sub_asset_endorsement_map OWNER TO nl2sql_ai;

--
-- TOC entry 701 (class 1259 OID 27663283)
-- Name: policy_sub_asset_endorsement_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_sub_asset_endorsement_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_sub_asset_endorsement_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9219 (class 0 OID 0)
-- Dependencies: 701
-- Name: policy_sub_asset_endorsement_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_sub_asset_endorsement_map_id_seq OWNED BY public.policy_sub_asset_endorsement_map.id;


--
-- TOC entry 702 (class 1259 OID 27663284)
-- Name: policy_sub_asset_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_sub_asset_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_sub_asset_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9220 (class 0 OID 0)
-- Dependencies: 702
-- Name: policy_sub_asset_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_sub_asset_id_seq OWNED BY public.policy_sub_asset.id;


--
-- TOC entry 703 (class 1259 OID 27663285)
-- Name: policy_tpa_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_tpa_map (
    id integer NOT NULL,
    policy_id integer,
    tpa_id integer,
    tpa_branch_id integer,
    created_at timestamp with time zone DEFAULT now(),
    updated_at timestamp with time zone DEFAULT now(),
    tpa_contact_id integer
);


ALTER TABLE public.policy_tpa_map OWNER TO nl2sql_ai;

--
-- TOC entry 704 (class 1259 OID 27663290)
-- Name: policy_tpa_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_tpa_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_tpa_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9221 (class 0 OID 0)
-- Dependencies: 704
-- Name: policy_tpa_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_tpa_map_id_seq OWNED BY public.policy_tpa_map.id;


--
-- TOC entry 705 (class 1259 OID 27663291)
-- Name: policy_type_and_endorsement_steps_mapping; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_type_and_endorsement_steps_mapping (
    id integer NOT NULL,
    policy_type_id integer,
    endorsement_step_id integer,
    endorsement_step_order integer
);


ALTER TABLE public.policy_type_and_endorsement_steps_mapping OWNER TO nl2sql_ai;

--
-- TOC entry 706 (class 1259 OID 27663294)
-- Name: policy_type_and_endorsement_steps_mapping_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_type_and_endorsement_steps_mapping_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_type_and_endorsement_steps_mapping_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9222 (class 0 OID 0)
-- Dependencies: 706
-- Name: policy_type_and_endorsement_steps_mapping_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_type_and_endorsement_steps_mapping_id_seq OWNED BY public.policy_type_and_endorsement_steps_mapping.id;


--
-- TOC entry 707 (class 1259 OID 27663295)
-- Name: policy_type_segregation; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.policy_type_segregation (
    id integer NOT NULL,
    policy_type_lid integer NOT NULL,
    irdai_policy_type_lid integer,
    iirm_policy_type_lid integer,
    assoc_active_policy_type_lid integer,
    policy_type_inactive_date timestamp with time zone
);


ALTER TABLE public.policy_type_segregation OWNER TO nl2sql_ai;

--
-- TOC entry 708 (class 1259 OID 27663298)
-- Name: policy_type_segregation_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.policy_type_segregation_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.policy_type_segregation_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9223 (class 0 OID 0)
-- Dependencies: 708
-- Name: policy_type_segregation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.policy_type_segregation_id_seq OWNED BY public.policy_type_segregation.id;


--
-- TOC entry 709 (class 1259 OID 27663299)
-- Name: premium_calculation_document_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.premium_calculation_document_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.premium_calculation_document_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9224 (class 0 OID 0)
-- Dependencies: 709
-- Name: premium_calculation_document_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.premium_calculation_document_map_id_seq OWNED BY public.opportunity_premium_calculation_document_map.id;


--
-- TOC entry 710 (class 1259 OID 27663300)
-- Name: professional_experience; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.professional_experience (
    id integer NOT NULL,
    contact_id integer NOT NULL,
    from_date date,
    to_date date,
    company character varying(100),
    designation character varying(100),
    department character varying(100),
    details text,
    remarks text,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    deleted_at timestamp with time zone,
    created_by integer NOT NULL,
    updated_by integer NOT NULL,
    CONSTRAINT professional_experience_details_check CHECK ((length(details) <= 500)),
    CONSTRAINT professional_experience_remarks_check CHECK ((length(remarks) <= 500))
);


ALTER TABLE public.professional_experience OWNER TO nl2sql_ai;

--
-- TOC entry 711 (class 1259 OID 27663309)
-- Name: professional_experience_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.professional_experience_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.professional_experience_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9225 (class 0 OID 0)
-- Dependencies: 711
-- Name: professional_experience_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.professional_experience_id_seq OWNED BY public.professional_experience.id;


--
-- TOC entry 712 (class 1259 OID 27663310)
-- Name: qualification_experience; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.qualification_experience (
    id integer NOT NULL,
    contact_id integer NOT NULL,
    name_of_qualification character varying(100),
    year_of_qualification integer,
    details text,
    remarks text,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    deleted_at timestamp with time zone,
    created_by integer NOT NULL,
    updated_by integer NOT NULL,
    university_name character varying(100),
    CONSTRAINT qualification_experience_details_check CHECK ((length(details) <= 500)),
    CONSTRAINT qualification_experience_remarks_check CHECK ((length(remarks) <= 500)),
    CONSTRAINT qualification_experience_year_of_qualification_check CHECK (((year_of_qualification >= 1900) AND ((year_of_qualification)::double precision <= date_part('year'::text, CURRENT_DATE))))
);


ALTER TABLE public.qualification_experience OWNER TO nl2sql_ai;

--
-- TOC entry 713 (class 1259 OID 27663320)
-- Name: qualification_experience_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.qualification_experience_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.qualification_experience_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9226 (class 0 OID 0)
-- Dependencies: 713
-- Name: qualification_experience_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.qualification_experience_id_seq OWNED BY public.qualification_experience.id;


--
-- TOC entry 714 (class 1259 OID 27663321)
-- Name: region; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.region (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    description text
);


ALTER TABLE public.region OWNER TO nl2sql_ai;

--
-- TOC entry 715 (class 1259 OID 27663326)
-- Name: region_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.region_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.region_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9227 (class 0 OID 0)
-- Dependencies: 715
-- Name: region_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.region_id_seq OWNED BY public.region.id;


--
-- TOC entry 716 (class 1259 OID 27663327)
-- Name: role_acl_category_action_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.role_acl_category_action_map (
    id integer NOT NULL,
    role_id integer NOT NULL,
    acl_category_action_id integer NOT NULL,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    created_by character varying(255) NOT NULL,
    updated_by character varying(255) NOT NULL
);


ALTER TABLE public.role_acl_category_action_map OWNER TO nl2sql_ai;

--
-- TOC entry 717 (class 1259 OID 27663334)
-- Name: role_acl_category_action_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.role_acl_category_action_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.role_acl_category_action_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9228 (class 0 OID 0)
-- Dependencies: 717
-- Name: role_acl_category_action_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.role_acl_category_action_map_id_seq OWNED BY public.role_acl_category_action_map.id;


--
-- TOC entry 718 (class 1259 OID 27663335)
-- Name: roles; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.roles (
    id integer NOT NULL,
    name character varying(50) NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    created_by character varying(255) NOT NULL,
    updated_by character varying(255) NOT NULL,
    role_key character varying(255)
);


ALTER TABLE public.roles OWNER TO nl2sql_ai;

--
-- TOC entry 719 (class 1259 OID 27663342)
-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.roles_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.roles_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9229 (class 0 OID 0)
-- Dependencies: 719
-- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id;


--
-- TOC entry 720 (class 1259 OID 27663343)
-- Name: service_tat_score_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.service_tat_score_map (
    id integer NOT NULL,
    service_id integer NOT NULL,
    tat_bucket_id integer NOT NULL,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone
);


ALTER TABLE public.service_tat_score_map OWNER TO nl2sql_ai;

--
-- TOC entry 721 (class 1259 OID 27663347)
-- Name: service_tat_score_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.service_tat_score_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.service_tat_score_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9230 (class 0 OID 0)
-- Dependencies: 721
-- Name: service_tat_score_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.service_tat_score_map_id_seq OWNED BY public.service_tat_score_map.id;


--
-- TOC entry 722 (class 1259 OID 27663348)
-- Name: state; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.state (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    state_code character varying(10),
    country_id integer NOT NULL
);


ALTER TABLE public.state OWNER TO nl2sql_ai;

--
-- TOC entry 723 (class 1259 OID 27663351)
-- Name: state_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.state_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.state_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9231 (class 0 OID 0)
-- Dependencies: 723
-- Name: state_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.state_id_seq OWNED BY public.state.id;


--
-- TOC entry 231 (class 1259 OID 12821242)
-- Name: task_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.task_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER SEQUENCE public.task_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 724 (class 1259 OID 27663352)
-- Name: task; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.task (
    id integer DEFAULT nextval('public.task_id_seq'::regclass) NOT NULL,
    task_name character varying(255) NOT NULL,
    activity_id integer,
    company_id integer,
    due_date date NOT NULL,
    priority_lid integer NOT NULL,
    description text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    deleted_at timestamp with time zone,
    created_by integer NOT NULL,
    updated_by integer NOT NULL,
    opportunity_id integer,
    assignee_id integer,
    task_status_lid integer DEFAULT 1 NOT NULL,
    task_type_lid integer DEFAULT 1 NOT NULL,
    task_category_lid integer DEFAULT 1,
    task_close character varying(20),
    task_is_editable character varying(20),
    policy_id integer,
    task_origin character varying(100),
    task_label character varying(150),
    sub_task_type_lid integer,
    comments text
);


ALTER TABLE public.task OWNER TO nl2sql_ai;

--
-- TOC entry 725 (class 1259 OID 27663363)
-- Name: task_document_map; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.task_document_map (
    id integer NOT NULL,
    task_id integer NOT NULL,
    document_id integer NOT NULL
);


ALTER TABLE public.task_document_map OWNER TO nl2sql_ai;

--
-- TOC entry 726 (class 1259 OID 27663366)
-- Name: task_document_map_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.task_document_map_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.task_document_map_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9232 (class 0 OID 0)
-- Dependencies: 726
-- Name: task_document_map_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.task_document_map_id_seq OWNED BY public.task_document_map.id;


--
-- TOC entry 727 (class 1259 OID 27663367)
-- Name: temp_performance_output_202511151355; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.temp_performance_output_202511151355 (
    id integer,
    user_id integer,
    entity_type character varying(50),
    kpi character varying(50),
    type_of_target character varying(50),
    value_of_target numeric(15,2),
    entity_count numeric(15,2),
    performance_month date,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);


ALTER TABLE public.temp_performance_output_202511151355 OWNER TO nl2sql_ai;

--
-- TOC entry 728 (class 1259 OID 27663370)
-- Name: tpa; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.tpa (
    id integer NOT NULL,
    name character varying(200) NOT NULL,
    display_name character varying(100) NOT NULL,
    company_type_lid integer NOT NULL,
    website character varying(100),
    remarks character varying(4000),
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    created_by integer NOT NULL,
    updated_by integer NOT NULL,
    deleted_at timestamp without time zone,
    status_lid integer,
    country_id integer DEFAULT 2
);


ALTER TABLE public.tpa OWNER TO nl2sql_ai;

--
-- TOC entry 729 (class 1259 OID 27663378)
-- Name: tpa_address; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.tpa_address (
    id integer NOT NULL,
    tpa_id integer NOT NULL,
    address_id integer NOT NULL,
    deleted_at timestamp without time zone
);


ALTER TABLE public.tpa_address OWNER TO nl2sql_ai;

--
-- TOC entry 730 (class 1259 OID 27663381)
-- Name: tpa_address_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.tpa_address_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.tpa_address_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9233 (class 0 OID 0)
-- Dependencies: 730
-- Name: tpa_address_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.tpa_address_id_seq OWNED BY public.tpa_address.id;


--
-- TOC entry 731 (class 1259 OID 27663382)
-- Name: tpa_contact; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.tpa_contact (
    id integer NOT NULL,
    tpa_id integer NOT NULL,
    contact_id integer NOT NULL
);


ALTER TABLE public.tpa_contact OWNER TO nl2sql_ai;

--
-- TOC entry 732 (class 1259 OID 27663385)
-- Name: tpa_contact_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.tpa_contact_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.tpa_contact_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9234 (class 0 OID 0)
-- Dependencies: 732
-- Name: tpa_contact_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.tpa_contact_id_seq OWNED BY public.tpa_contact.id;


--
-- TOC entry 733 (class 1259 OID 27663386)
-- Name: tpa_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.tpa_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.tpa_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9235 (class 0 OID 0)
-- Dependencies: 733
-- Name: tpa_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.tpa_id_seq OWNED BY public.tpa.id;


--
-- TOC entry 734 (class 1259 OID 27663387)
-- Name: user_role; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.user_role (
    id integer NOT NULL,
    user_id integer NOT NULL,
    role_id integer NOT NULL,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    created_by character varying(255),
    updated_by character varying(255)
);


ALTER TABLE public.user_role OWNER TO nl2sql_ai;

--
-- TOC entry 735 (class 1259 OID 27663394)
-- Name: user_role_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.user_role_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.user_role_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9236 (class 0 OID 0)
-- Dependencies: 735
-- Name: user_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.user_role_id_seq OWNED BY public.user_role.id;


--
-- TOC entry 736 (class 1259 OID 27663395)
-- Name: users; Type: TABLE; Schema: public; Owner: nl2sql_ai
--

CREATE TABLE public.users (
    id integer NOT NULL,
    first_name character varying(100) NOT NULL,
    last_name character varying(100) NOT NULL,
    email_id character varying(150) NOT NULL,
    mobile character varying(20),
    login_name character varying(100) NOT NULL,
    password character varying(255) NOT NULL,
    branch_id integer,
    department_id integer,
    designation_id integer,
    reporting_user_id integer,
    salutation_lid integer,
    deleted_at timestamp without time zone,
    iirm_emp_id character varying(255),
    organisation_id integer,
    vertical_id integer,
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    created_by integer,
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    updated_by integer,
    user_type_key character varying(255),
    user_status_key character varying(255),
    status_lid integer,
    sbu_id integer
);


ALTER TABLE public.users OWNER TO nl2sql_ai;

--
-- TOC entry 737 (class 1259 OID 27663402)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: nl2sql_ai
--

CREATE SEQUENCE public.users_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.users_id_seq OWNER TO nl2sql_ai;

--
-- TOC entry 9237 (class 0 OID 0)
-- Dependencies: 737
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: nl2sql_ai
--

ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;


--
-- TOC entry 738 (class 1259 OID 27663403)
-- Name: vm_company_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vm_company_info AS
 SELECT cmp.company_name,
    cmp.display_name,
    gc.company_name AS parent_company_name,
    ((((((crm.first_name)::text || ' '::text) || (crm.last_name)::text) || ' ()'::text) || (crm.email_id)::text) || ')'::text) AS lead_crm,
    cntry.name AS country,
    brkr.broker_name AS existing_broker,
    ((((((apprv.first_name)::text || ' '::text) || (apprv.last_name)::text) || ' ()'::text) || (apprv.email_id)::text) || ')'::text) AS approver,
    cur.name AS currency,
    cmp.no_of_employees,
    cmp.website,
    cmp.date_of_incorporation,
    cmp.pan_card_number,
    cmp.registration_no,
    cmp.paid_up_capital,
    cmp.tan_number,
    cmp.source,
    cmp.account_manager,
    cmp.annual_premium,
    cmp.additional_fields,
    cmp.service_tax,
    ldst.value AS status_type,
    ldpt.value AS priority_type,
    ldgc.value AS group_company_type,
    ldsrc.value AS source_type,
    ldsntm.value AS sentiment_type,
    ldct.value AS company_type,
    ldctg.value AS company_tag_type,
    ldis.value AS industry_segment_type,
    ((((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS created_by,
    cmp.remarks,
    '-'::text AS "references",
    cmp.id AS company_id,
    cmp.existing_broker_id,
    cmp.approver_id,
    cmp.country_id,
    cmp.currency_id,
    cmp.created_at,
    cmp.created_by AS created_by_id,
    cmp.lead_crm AS lead_crm_id,
    cmp.status_lid,
    cmp.priority_lid,
    cmp.group_company_lid,
    cmp.source_type_lid,
    cmp.sentiment_lid,
    cmp.company_type_lid,
    cmp.company_tag_lid,
    cmp.industry_segment_lid
   FROM ((((((((((((((((public.company cmp
     LEFT JOIN public.users usr ON ((usr.id = cmp.created_by)))
     LEFT JOIN public.country cntry ON ((cntry.id = cmp.country_id)))
     LEFT JOIN public.broker brkr ON ((brkr.id = cmp.existing_broker_id)))
     LEFT JOIN public.users crm ON ((crm.id = cmp.lead_crm)))
     LEFT JOIN public.users apprv ON ((apprv.id = cmp.lead_crm)))
     LEFT JOIN public.currency cur ON ((cur.id = cmp.currency_id)))
     LEFT JOIN public.lookup_data ldst ON ((ldst.id = cmp.status_lid)))
     LEFT JOIN public.lookup_data ldpt ON ((ldpt.id = cmp.priority_lid)))
     LEFT JOIN public.lookup_data ldgc ON ((ldgc.id = cmp.group_company_lid)))
     LEFT JOIN public.lookup_data ldsrc ON ((ldsrc.id = cmp.source_type_lid)))
     LEFT JOIN public.lookup_data ldsntm ON ((ldsntm.id = cmp.sentiment_lid)))
     LEFT JOIN public.lookup_data ldct ON ((ldct.id = cmp.company_type_lid)))
     LEFT JOIN public.lookup_data ldctg ON ((ldctg.id = cmp.company_tag_lid)))
     LEFT JOIN public.lookup_data ldis ON ((ldis.id = cmp.industry_segment_lid)))
     LEFT JOIN public.group_company_map gci ON ((gci.company_id = cmp.id)))
     LEFT JOIN public.company gc ON ((gc.id = gci.group_company_id)));


ALTER VIEW public.vm_company_info OWNER TO nl2sql_ai;

--
-- TOC entry 739 (class 1259 OID 27663408)
-- Name: vr_all_user_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_all_user_info AS
SELECT
    NULL::text AS user_name,
    NULL::character varying(150) AS user_email,
    NULL::text AS manager_name,
    NULL::character varying(150) AS manager_email,
    NULL::character varying(255) AS iirm_employee_id,
    NULL::character varying(255) AS organisation,
    NULL::character varying(255) AS branch,
    NULL::character varying(255) AS sbu,
    NULL::character varying(255) AS vertical,
    NULL::character varying(255) AS department,
    NULL::character varying(255) AS designation,
    NULL::text AS roles,
    NULL::character varying(100) AS login,
    NULL::character varying(255) AS user_status,
    NULL::integer AS uid,
    NULL::integer AS manager_uid;


ALTER VIEW public.vr_all_user_info OWNER TO nl2sql_ai;

--
-- TOC entry 740 (class 1259 OID 27663412)
-- Name: vm_counts_by_user; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vm_counts_by_user AS
 SELECT usr.user_name,
    usr.user_email,
    usr.user_status,
    cmp.aspect_count AS company_count,
    opty_so.aspect_count AS so_count,
    opty_ro.aspect_count AS ro_count,
    plc.aspect_count AS policy_count,
    usr.organisation,
    usr.sbu,
    usr.vertical,
    usr.department,
    usr.branch,
    usr.designation,
    usr.manager_name,
    usr.manager_email,
    usr.uid AS user_id,
    usr.manager_uid AS manager_user_id
   FROM ((((public.vr_all_user_info usr
     LEFT JOIN ( SELECT company.lead_crm AS user_id,
            'Company'::text AS aspect,
            count(*) AS aspect_count
           FROM public.company
          GROUP BY company.lead_crm) cmp ON ((usr.uid = cmp.user_id)))
     LEFT JOIN ( SELECT opportunity.owner_id AS user_id,
            'SO'::text AS aspect,
            count(*) AS aspect_count
           FROM public.opportunity
          WHERE (opportunity.opportunity_type_lid = 4401)
          GROUP BY opportunity.owner_id) opty_so ON ((usr.uid = opty_so.user_id)))
     LEFT JOIN ( SELECT opportunity.owner_id AS user_id,
            'RO'::text AS aspect,
            count(*) AS aspect_count
           FROM public.opportunity
          WHERE (opportunity.opportunity_type_lid = 4402)
          GROUP BY opportunity.owner_id) opty_ro ON ((usr.uid = opty_ro.user_id)))
     LEFT JOIN ( SELECT policy.owner_id AS user_id,
            'Policy'::text AS aspect,
            count(*) AS aspect_count
           FROM public.policy
          GROUP BY policy.owner_id) plc ON ((usr.uid = plc.user_id)))
  WHERE (1 = 1)
  ORDER BY usr.organisation, usr.user_status, usr.user_name;


ALTER VIEW public.vm_counts_by_user OWNER TO nl2sql_ai;

--
-- TOC entry 741 (class 1259 OID 27663417)
-- Name: vr_active_user_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_active_user_info AS
SELECT
    NULL::text AS user_name,
    NULL::character varying(150) AS user_email,
    NULL::text AS manager_name,
    NULL::character varying(150) AS manager_email,
    NULL::character varying(255) AS iirm_employee_id,
    NULL::character varying(255) AS organisation,
    NULL::character varying(255) AS branch,
    NULL::character varying(255) AS vertical,
    NULL::character varying(255) AS department,
    NULL::character varying(255) AS designation,
    NULL::text AS roles,
    NULL::character varying(100) AS login,
    NULL::integer AS uid,
    NULL::integer AS manager_uid;


ALTER VIEW public.vr_active_user_info OWNER TO nl2sql_ai;

--
-- TOC entry 742 (class 1259 OID 27663421)
-- Name: vr_company_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_company_info AS
 SELECT cmp.company_name,
    cmp.display_name,
    gc.company_name AS parent_company_name,
    ((((((crm.first_name)::text || ' '::text) || (crm.last_name)::text) || ' ()'::text) || (crm.email_id)::text) || ')'::text) AS lead_crm,
    cntry.name AS country,
    brkr.broker_name AS existing_broker,
    ((((((apprv.first_name)::text || ' '::text) || (apprv.last_name)::text) || ' ()'::text) || (apprv.email_id)::text) || ')'::text) AS approver,
    cur.name AS currency,
    cmp.no_of_employees,
    cmp.website,
    cmp.date_of_incorporation,
    cmp.pan_card_number,
    cmp.registration_no,
    cmp.paid_up_capital,
    cmp.tan_number,
    cmp.source,
    cmp.account_manager,
    cmp.annual_premium,
    cmp.additional_fields,
    cmp.service_tax,
    ldst.value AS status_type,
    ldpt.value AS priority_type,
    ldgc.value AS group_company_type,
    ldsrc.value AS source_type,
    ldsntm.value AS sentiment_type,
    ldct.value AS company_type,
    ldctg.value AS company_tag_type,
    ldis.value AS industry_segment_type,
    ((((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS created_by,
    cmp.remarks,
    '-'::text AS "references",
    cmp.id AS company_id,
    cmp.existing_broker_id,
    cmp.approver_id,
    cmp.country_id,
    cmp.currency_id,
    cmp.created_at,
    cmp.created_by AS created_by_id,
    cmp.lead_crm AS lead_crm_id,
    cmp.status_lid,
    cmp.priority_lid,
    cmp.group_company_lid,
    cmp.source_type_lid,
    cmp.sentiment_lid,
    cmp.company_type_lid,
    cmp.company_tag_lid,
    cmp.industry_segment_lid
   FROM ((((((((((((((((public.company cmp
     LEFT JOIN public.users usr ON ((usr.id = cmp.created_by)))
     LEFT JOIN public.country cntry ON ((cntry.id = cmp.country_id)))
     LEFT JOIN public.broker brkr ON ((brkr.id = cmp.existing_broker_id)))
     LEFT JOIN public.users crm ON ((crm.id = cmp.lead_crm)))
     LEFT JOIN public.users apprv ON ((apprv.id = cmp.lead_crm)))
     LEFT JOIN public.currency cur ON ((cur.id = cmp.currency_id)))
     LEFT JOIN public.lookup_data ldst ON ((ldst.id = cmp.status_lid)))
     LEFT JOIN public.lookup_data ldpt ON ((ldpt.id = cmp.priority_lid)))
     LEFT JOIN public.lookup_data ldgc ON ((ldgc.id = cmp.group_company_lid)))
     LEFT JOIN public.lookup_data ldsrc ON ((ldsrc.id = cmp.source_type_lid)))
     LEFT JOIN public.lookup_data ldsntm ON ((ldsntm.id = cmp.sentiment_lid)))
     LEFT JOIN public.lookup_data ldct ON ((ldct.id = cmp.company_type_lid)))
     LEFT JOIN public.lookup_data ldctg ON ((ldctg.id = cmp.company_tag_lid)))
     LEFT JOIN public.lookup_data ldis ON ((ldis.id = cmp.industry_segment_lid)))
     LEFT JOIN public.group_company_map gci ON ((gci.company_id = cmp.id)))
     LEFT JOIN public.company gc ON ((gc.id = gci.group_company_id)));


ALTER VIEW public.vr_company_info OWNER TO nl2sql_ai;

--
-- TOC entry 743 (class 1259 OID 27663426)
-- Name: vr_country_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_country_info AS
 SELECT region.name AS region_name,
    country.name AS country_name,
    state.name AS state_name,
    city.name AS city_name,
    ' -- '::text AS reference,
    region.id AS region_id,
    country.id AS country_id,
    state.id AS state_id,
    city.id AS city_id
   FROM public.region,
    public.country,
    public.state,
    public.city
  WHERE ((1 = 1) AND (city.state_id = state.id) AND (state.country_id = country.id) AND (country.region_id = region.id))
  ORDER BY region.name, country.name, state.name, city.name;


ALTER VIEW public.vr_country_info OWNER TO nl2sql_ai;

--
-- TOC entry 744 (class 1259 OID 27663430)
-- Name: vr_counts_company; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_counts_company AS
 SELECT org.name AS organisation,
    sbu.name AS sbu,
    vert.name AS vertical,
    dept.name AS department,
    brn.name AS branch,
    TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)) AS "user",
    count(1) AS count_of_companies,
    org.id AS organisation_id,
    sbu.id AS sbu_id,
    vert.id AS vertical_id,
    dept.id AS department_id,
    brn.id AS branch_id,
    usr.id AS user_id
   FROM ((((((public.company cmp
     JOIN public.users usr ON ((usr.id = cmp.lead_crm)))
     JOIN public.organisation org ON ((org.id = usr.organisation_id)))
     LEFT JOIN public.org_sbu sbu ON (((org.id = sbu.organisation_id) AND (sbu.id = usr.sbu_id))))
     LEFT JOIN public.org_vertical vert ON (((sbu.id = vert.sbu_id) AND (vert.organisation_id = usr.organisation_id) AND (vert.id = usr.vertical_id))))
     LEFT JOIN public.org_department dept ON (((dept.vertical_id = vert.id) AND (dept.id = usr.department_id))))
     LEFT JOIN public.org_branch brn ON (((brn.organisation_id = org.id) AND (brn.id = usr.branch_id))))
  GROUP BY org.name, sbu.name, vert.name, dept.name, brn.name, org.id, sbu.id, vert.id, dept.id, brn.id, usr.id, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)))
  ORDER BY org.name, sbu.name, vert.name, dept.name, brn.name, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)));


ALTER VIEW public.vr_counts_company OWNER TO nl2sql_ai;

--
-- TOC entry 745 (class 1259 OID 27663435)
-- Name: vr_counts_policy; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_counts_policy AS
 SELECT org.name AS organisation,
    sbu.name AS sbu,
    vert.name AS vertical,
    dept.name AS department,
    brn.name AS branch,
    TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)) AS "user",
    count(1) AS count_of_policies,
    org.id AS organisation_id,
    sbu.id AS sbu_id,
    vert.id AS vertical_id,
    dept.id AS department_id,
    brn.id AS branch_id,
    usr.id AS user_id
   FROM (((((((public.policy plc
     JOIN public.company cmp ON ((plc.company_id = cmp.id)))
     JOIN public.users usr ON ((usr.id = cmp.lead_crm)))
     JOIN public.organisation org ON ((org.id = usr.organisation_id)))
     LEFT JOIN public.org_sbu sbu ON (((org.id = sbu.organisation_id) AND (sbu.id = usr.sbu_id))))
     LEFT JOIN public.org_vertical vert ON (((sbu.id = vert.sbu_id) AND (vert.organisation_id = usr.organisation_id) AND (vert.id = usr.vertical_id))))
     LEFT JOIN public.org_department dept ON (((dept.vertical_id = vert.id) AND (dept.id = usr.department_id))))
     LEFT JOIN public.org_branch brn ON (((brn.organisation_id = org.id) AND (brn.id = usr.branch_id))))
  GROUP BY org.name, sbu.name, vert.name, dept.name, brn.name, org.id, sbu.id, vert.id, dept.id, brn.id, usr.id, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)))
  ORDER BY org.name, sbu.name, vert.name, dept.name, brn.name, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)));


ALTER VIEW public.vr_counts_policy OWNER TO nl2sql_ai;

--
-- TOC entry 746 (class 1259 OID 27663440)
-- Name: vr_counts_ro; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_counts_ro AS
 SELECT org.name AS organisation,
    sbu.name AS sbu,
    vert.name AS vertical,
    dept.name AS department,
    brn.name AS branch,
    TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)) AS "user",
    count(1) AS count_of_so,
    org.id AS organisation_id,
    sbu.id AS sbu_id,
    vert.id AS vertical_id,
    dept.id AS department_id,
    brn.id AS branch_id,
    usr.id AS user_id
   FROM (((((((public.opportunity opty
     JOIN public.company cmp ON ((opty.company_id = cmp.id)))
     JOIN public.users usr ON ((usr.id = cmp.lead_crm)))
     JOIN public.organisation org ON ((org.id = usr.organisation_id)))
     LEFT JOIN public.org_sbu sbu ON (((org.id = sbu.organisation_id) AND (sbu.id = usr.sbu_id))))
     LEFT JOIN public.org_vertical vert ON (((sbu.id = vert.sbu_id) AND (vert.organisation_id = usr.organisation_id) AND (vert.id = usr.vertical_id))))
     LEFT JOIN public.org_department dept ON (((dept.vertical_id = vert.id) AND (dept.id = usr.department_id))))
     LEFT JOIN public.org_branch brn ON (((brn.organisation_id = org.id) AND (brn.id = usr.branch_id))))
  WHERE (opty.opportunity_type_lid = 4402)
  GROUP BY org.name, sbu.name, vert.name, dept.name, brn.name, org.id, sbu.id, vert.id, dept.id, brn.id, usr.id, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)))
  ORDER BY org.name, sbu.name, vert.name, dept.name, brn.name, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)));


ALTER VIEW public.vr_counts_ro OWNER TO nl2sql_ai;

--
-- TOC entry 747 (class 1259 OID 27663445)
-- Name: vr_counts_so; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_counts_so AS
 SELECT org.name AS organisation,
    sbu.name AS sbu,
    vert.name AS vertical,
    dept.name AS department,
    brn.name AS branch,
    TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)) AS "user",
    count(1) AS count_of_so,
    org.id AS organisation_id,
    sbu.id AS sbu_id,
    vert.id AS vertical_id,
    dept.id AS department_id,
    brn.id AS branch_id,
    usr.id AS user_id
   FROM (((((((public.opportunity opty
     JOIN public.company cmp ON ((opty.company_id = cmp.id)))
     JOIN public.users usr ON ((usr.id = cmp.lead_crm)))
     JOIN public.organisation org ON ((org.id = usr.organisation_id)))
     LEFT JOIN public.org_sbu sbu ON (((org.id = sbu.organisation_id) AND (sbu.id = usr.sbu_id))))
     LEFT JOIN public.org_vertical vert ON (((sbu.id = vert.sbu_id) AND (vert.organisation_id = usr.organisation_id) AND (vert.id = usr.vertical_id))))
     LEFT JOIN public.org_department dept ON (((dept.vertical_id = vert.id) AND (dept.id = usr.department_id))))
     LEFT JOIN public.org_branch brn ON (((brn.organisation_id = org.id) AND (brn.id = usr.branch_id))))
  WHERE (opty.opportunity_type_lid = 4401)
  GROUP BY org.name, sbu.name, vert.name, dept.name, brn.name, org.id, sbu.id, vert.id, dept.id, brn.id, usr.id, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)))
  ORDER BY org.name, sbu.name, vert.name, dept.name, brn.name, (TRIM(BOTH FROM (((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' '::text) || (usr.email_id)::text)));


ALTER VIEW public.vr_counts_so OWNER TO nl2sql_ai;

--
-- TOC entry 748 (class 1259 OID 27663450)
-- Name: vr_cover_template; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_cover_template AS
 SELECT orga.name AS organisation,
    ldpta.value AS policy_type,
        CASE ldpta.status
            WHEN 0 THEN 'Inactive'::text
            ELSE 'Active'::text
        END AS policy_type_status,
    ldct.value AS cover_type,
    mct.cover_name,
    mct.mandatory,
    mct.input_type,
    mct.input_lov AS list_of_options,
    mct.display_sequence AS display_order,
    mct.cover_description,
    ' -- '::text AS separator,
    mct.id AS cover_template_id,
    ldpta.id AS policy_type_lid,
    ldct.id AS cover_type_lid
   FROM (((((public.mstr_cover_template mct
     JOIN public.lookup_data ldpt ON ((mct.policy_type_id = ldpt.id)))
     JOIN public.organisation org ON ((org.id = mct.organization_id)))
     JOIN public.lookup_data ldct ON ((mct.cover_type = ldct.id)))
     RIGHT JOIN public.lookup_data ldpta ON ((mct.policy_type_id = ldpta.id)))
     JOIN public.organisation orga ON ((orga.id = ldpta.organisation_id)))
  WHERE ((1 = 1) AND ((ldpta.lookup_name)::text = 'POLICY_TYPE'::text))
  ORDER BY org.name, orga.name, ldpta.value, mct.display_sequence;


ALTER VIEW public.vr_cover_template OWNER TO nl2sql_ai;

--
-- TOC entry 749 (class 1259 OID 27663455)
-- Name: vr_endorsement_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_endorsement_info AS
 SELECT cmp.company_name,
    plc.policy_name AS endorsement_policy_name,
    ldpt.value AS policy_type,
    ldopts.value AS policy_status,
    ((((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS owned_by,
    endr.endorsement_type,
    endr.endorsement_date,
    endr.insurer_endorsement_number,
    endr.insurer_endorsement_date,
    endr.endorsement_entry_date,
    endr.endorsment_count,
    endr.endorsement_ack_count,
    endr.tpa_processed_count,
    endr.tpa_acknowledged_date,
    endr.tpa_error_count,
    ldopts.value AS opportunity_status,
    cntry.name AS country,
    plc.policy_from AS start_date,
    plc.policy_to AS expiry_date,
    plc.provisional_policy_no,
    plc.opportunity_type,
    endr.basic_brokerage_amount AS brokerage_amount,
    endr.date_of_income,
    endr.income_month,
    endr.gst_amount AS service_tax_amount,
    endr.net_premium AS net_premium_amount,
    endr.terrorism_amount,
    endr.other_amount,
    endr.gross_premium AS gross_premium_amount,
    endr.brokerage_amount_asper_iwork,
    endr.brokerage_amount_asper_isg,
    endr.fee_amount,
    endr.od_percentage,
    endr.tp_percentage,
    endr.net_percentage,
    endr.share_percentage,
    endr.terrorism_brokerage_percentage AS commission_terrorism_percentage,
    endr.sum_insured,
    endr.premium_at_inception,
    plc.insurer_policy_number,
    endr.commission_terrorism_amount,
    endr.basic_brokerage_percentage AS brokerage_percentage,
    endr.brokerage_collected,
    endr.premium_collected,
    endr.ingested_at,
    endr.ingested_mode,
    endr.endorsement_status,
    endr.current_endorsement_step,
    endr.os_ticket_number,
    endr.insurer_communication_date,
    endr.insurer_communication_details,
    endr.insurer_acknowledgement_number,
    endr.insurer_endorsed_employee_count,
    endr.insurer_endorsed_dependent_count,
    endr.endorsement_effective_date,
    endr.client_confirmation_message,
    endr.client_confirmation_date,
    endr.tpa_upload_remarks,
    endr.endorsment_dependent_count,
    endr.employee_endorsement_addition_count,
    endr.employee_endorsement_deletion_count,
    endr.is_inception,
    endr.enrollment_start_date,
    endr.enrollment_end_date,
    org.name AS owner_organisation,
    sbu.name AS owner_sbu,
    ver.name AS owner_vertical,
    dept.name AS owner_department,
    br.name AS owner_branch,
    desg.name AS owner_designation,
    ldict.value AS income_type,
    lddw.value AS deal_own_or_not,
    ldpgp.value AS policy_group,
    ldoes.value AS enrollment_status,
    ldcs.value AS configuration_status,
    endr.financial_non_financially,
    endr.mig_ref_no,
    ' - '::text AS reference,
    endr.remarks,
    plc.policy_configuration,
    endr.id AS endorsement_id,
    plc.id AS policy_id,
    plc.opportunity_id,
    endr.company_id,
    plc.country_id,
    plc.policy_type_lid,
    plc.status_lid,
    plc.enrollment_status_lid,
    plc.configuration_status_lid,
    plc.owner_id,
    endr.endorsment_file_id,
    endr.ack_file_id AS endorsment_ack_file_id,
    endr.tpa_document_id,
    endr.tpa_error_file_id,
    endr.created_by,
    endr.created_at,
    endr.updated_by,
    endr.updated_at
   FROM (((((((((((((((((((public.endorsement endr
     JOIN public.policy plc ON ((endr.policy_id = plc.id)))
     LEFT JOIN public.company cmp ON ((cmp.id = endr.company_id)))
     LEFT JOIN public.country cntry ON ((cntry.id = cmp.country_id)))
     LEFT JOIN public.users usr ON ((usr.id = plc.owner_id)))
     LEFT JOIN public.opportunity opty ON ((opty.id = plc.opportunity_id)))
     LEFT JOIN public.lookup_data ldpt ON ((ldpt.id = plc.policy_type_lid)))
     LEFT JOIN public.lookup_data ldopts ON ((ldopts.id = opty.status_lid)))
     LEFT JOIN public.lookup_data ldoplcs ON ((ldoplcs.id = plc.status_lid)))
     LEFT JOIN public.lookup_data ldoes ON ((ldoes.id = plc.enrollment_status_lid)))
     LEFT JOIN public.lookup_data ldcs ON ((ldcs.id = plc.configuration_status_lid)))
     LEFT JOIN public.organisation org ON ((org.id = usr.organisation_id)))
     LEFT JOIN public.org_sbu sbu ON ((sbu.id = usr.sbu_id)))
     LEFT JOIN public.org_vertical ver ON ((ver.id = usr.vertical_id)))
     LEFT JOIN public.org_department dept ON ((dept.id = usr.department_id)))
     LEFT JOIN public.org_branch br ON ((br.id = usr.branch_id)))
     LEFT JOIN public.org_designation desg ON ((desg.id = usr.designation_id)))
     LEFT JOIN public.lookup_data ldict ON ((ldict.id = endr.income_type_lid)))
     LEFT JOIN public.lookup_data lddw ON ((lddw.id = endr.deal_confirmed_lid)))
     LEFT JOIN public.lookup_data ldpgp ON ((ldpgp.id = plc.policy_group_type_lid)));


ALTER VIEW public.vr_endorsement_info OWNER TO nl2sql_ai;

--
-- TOC entry 750 (class 1259 OID 27663460)
-- Name: vr_inactive_user_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_inactive_user_info AS
SELECT
    NULL::text AS user_name,
    NULL::character varying(150) AS user_email,
    NULL::text AS manager_name,
    NULL::character varying(150) AS manager_email,
    NULL::character varying(255) AS iirm_employee_id,
    NULL::character varying(255) AS organisation,
    NULL::character varying(255) AS branch,
    NULL::character varying(255) AS vertical,
    NULL::character varying(255) AS department,
    NULL::character varying(255) AS designation,
    NULL::text AS roles,
    NULL::character varying(100) AS login,
    NULL::integer AS uid,
    NULL::integer AS manager_uid;


ALTER VIEW public.vr_inactive_user_info OWNER TO nl2sql_ai;

--
-- TOC entry 751 (class 1259 OID 27663464)
-- Name: vr_lookup_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_lookup_info AS
 SELECT org.name AS organisation,
    ld.lookup_name,
    ld.value AS lookup_value,
    ldir.value AS irdai_category,
    ldii.value AS iirm_category,
        CASE ld.status
            WHEN 0 THEN 'Inactive'::text
            ELSE 'Active'::text
        END AS lookup_status,
    ldn.value AS respective_active_policy_type,
    ld.value_key AS lookup_value_key,
    ld.lookup_order AS display_order,
    ' - '::text AS reference,
    ld.description AS lookup_description,
    ld.id AS lookup_id,
    ld.lookup_key AS unique_lookup_key,
    ldn.id AS respective_active_policy_type_lid
   FROM (((((public.lookup_data ld
     JOIN public.organisation org ON ((org.id = ld.organisation_id)))
     LEFT JOIN public.policy_type_segregation pts ON ((pts.policy_type_lid = ld.id)))
     LEFT JOIN public.lookup_data ldn ON ((pts.assoc_active_policy_type_lid = ldn.id)))
     LEFT JOIN public.lookup_data ldir ON ((pts.irdai_policy_type_lid = ldir.id)))
     LEFT JOIN public.lookup_data ldii ON ((pts.iirm_policy_type_lid = ldii.id)))
  WHERE (1 = 1)
  ORDER BY org.name, ld.lookup_name, ld.value;


ALTER VIEW public.vr_lookup_info OWNER TO nl2sql_ai;

--
-- TOC entry 752 (class 1259 OID 27663469)
-- Name: vr_opportunity_activity_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_opportunity_activity_info AS
 SELECT oam.opportunity_id,
    oam.stage_name,
    oam.activity_name,
    ((((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS activity_owner,
    ldoams.value AS activity_status,
    oam.due_date,
    oam.original_due_date,
    oam.planned_at,
    oam.completed_at,
    oam.lead_days,
    oam.approval,
    oam.mandatory,
    oam.activity_order,
    ' -- '::text AS ref,
    oam.id
   FROM (((public.opportunity opty
     LEFT JOIN public.opportunity_activity_map oam ON ((opty.id = oam.opportunity_id)))
     LEFT JOIN public.users usr ON ((usr.id = oam.created_by)))
     LEFT JOIN public.lookup_data ldoams ON ((ldoams.id = oam.status_lid)))
  ORDER BY oam.opportunity_id, oam.activity_order;


ALTER VIEW public.vr_opportunity_activity_info OWNER TO nl2sql_ai;

--
-- TOC entry 753 (class 1259 OID 27663474)
-- Name: vr_opportunity_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_opportunity_info AS
 SELECT cmp.company_name,
    opty.estimated_brokerage,
    opty.expiry_date AS opportunity_expiry_date,
    ldot.value AS opportunity_type,
    ldst.value AS opportunity_status,
    ldpt.value AS policy_type,
    plc.policy_from AS policy_start_date,
    plc.policy_to AS policy_end_date,
    opty.sum_insured,
    opty.premium_paid,
    ((((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS created_by,
    ((((((own.first_name)::text || ' '::text) || (own.last_name)::text) || ' ('::text) || (own.email_id)::text) || ')'::text) AS owned_by,
    ((((((usram.first_name)::text || ' '::text) || (usram.last_name)::text) || ' ('::text) || (usram.email_id)::text) || ')'::text) AS account_manager,
    ((((((usrisg.first_name)::text || ' '::text) || (usrisg.last_name)::text) || ' ('::text) || (usrisg.email_id)::text) || ')'::text) AS isg_owner,
    oam.stage_name,
    oam.activity_name,
    oam.activity_status,
    oam.activity_owner,
    opty.sharing_percentage,
    opty.estimated_fee,
    opty.estimated_brokerage_percentage,
    plc.id AS source_policy,
    optyplc.id AS generated_policy,
    ldps.value AS policy_status_type,
    ldsl.value AS service_level_type,
    ldpm.value AS policy_mined_type,
    ldsr.value AS source_type,
    ins.name AS previous_insurer,
    tpa.name AS previous_tpa,
    opty.sales_pitch,
    opty.source,
    opty.remarks,
    ' -- '::text AS reference,
    opty.id,
    opty.company_id,
    opty.owner_id,
    opty.contact_id,
    opty.ref_policy_id,
    opty.ref_opportunity_id,
    opty.prev_insurer_id,
    opty.prev_insurer_location_id,
    opty.prev_insurer_branch_id,
    opty.prev_tpa_id,
    opty.prev_tpa_location_id,
    opty.prev_tpa_branch_id,
    opty.policy_type_lid,
    opty.policy_status_lid,
    opty.service_level_lid,
    opty.opportunity_type_lid,
    opty.is_policy_mined_lid,
    opty.source_type_lid,
    opty.status_lid,
    opty.created_by AS created_by_id,
    opty.updated_by,
    opty.created_at,
    opty.updated_at,
    opty.deleted_at,
    opty.am_id,
    opty.isg_id
   FROM ((((((((((((((((((public.opportunity opty
     LEFT JOIN public.company cmp ON ((cmp.id = opty.company_id)))
     LEFT JOIN public.users usr ON ((usr.id = opty.created_by)))
     LEFT JOIN public.users own ON ((own.id = opty.owner_id)))
     LEFT JOIN public.country cntry ON ((cntry.id = cmp.country_id)))
     LEFT JOIN public.policy plc ON ((plc.id = opty.ref_policy_id)))
     LEFT JOIN public.policy optyplc ON ((optyplc.opportunity_id = opty.id)))
     LEFT JOIN public.lookup_data ldpt ON ((ldpt.id = opty.policy_type_lid)))
     LEFT JOIN public.lookup_data ldps ON ((ldps.id = opty.policy_status_lid)))
     LEFT JOIN public.lookup_data ldsl ON ((ldsl.id = opty.service_level_lid)))
     LEFT JOIN public.lookup_data ldot ON ((ldot.id = opty.opportunity_type_lid)))
     LEFT JOIN public.lookup_data ldpm ON ((ldpm.id = opty.is_policy_mined_lid)))
     LEFT JOIN public.lookup_data ldsr ON ((ldsr.id = opty.source_type_lid)))
     LEFT JOIN public.lookup_data ldst ON ((ldst.id = opty.status_lid)))
     LEFT JOIN public.insurer ins ON ((ins.id = opty.prev_insurer_id)))
     LEFT JOIN public.tpa tpa ON ((tpa.id = opty.prev_tpa_id)))
     LEFT JOIN ( SELECT active_records.opportunity_id,
            active_records.stage_name,
            active_records.activity_name,
            ((((((usr_1.first_name)::text || ' '::text) || (usr_1.last_name)::text) || ' ('::text) || (usr_1.email_id)::text) || ')'::text) AS activity_owner,
            active_records.planned_at,
            ld.value AS activity_status
           FROM ((( SELECT opportunity_activity_map.id,
                    opportunity_activity_map.opportunity_id,
                    opportunity_activity_map.ref_stage_id,
                    opportunity_activity_map.ref_activity_id,
                    opportunity_activity_map.activity_name,
                    opportunity_activity_map.stage_name,
                    opportunity_activity_map.original_due_date,
                    opportunity_activity_map.lead_days,
                    opportunity_activity_map.approval,
                    opportunity_activity_map.mandatory,
                    opportunity_activity_map.lead_role_id,
                    opportunity_activity_map.activity_meta,
                    opportunity_activity_map.due_date,
                    opportunity_activity_map.created_at,
                    opportunity_activity_map.updated_at,
                    opportunity_activity_map.created_by,
                    opportunity_activity_map.updated_by,
                    opportunity_activity_map.opportunity_table,
                    opportunity_activity_map.status_lid,
                    opportunity_activity_map.activity_key,
                    opportunity_activity_map.ref_role_key,
                    opportunity_activity_map.owner_id,
                    opportunity_activity_map.planned_at,
                    opportunity_activity_map.completed_at,
                    opportunity_activity_map.activity_order,
                    opportunity_activity_map.file_path_url,
                    row_number() OVER (PARTITION BY opportunity_activity_map.opportunity_id ORDER BY opportunity_activity_map.activity_order) AS actvie_row
                   FROM public.opportunity_activity_map
                  WHERE ((1 = 1) AND (opportunity_activity_map.opportunity_id = COALESCE(NULL::integer, opportunity_activity_map.opportunity_id)) AND (opportunity_activity_map.status_lid <> ALL (ARRAY[4502, 4627])))
                  ORDER BY opportunity_activity_map.activity_order) active_records
             LEFT JOIN public.users usr_1 ON ((active_records.owner_id = usr_1.id)))
             JOIN public.lookup_data ld ON ((active_records.status_lid = ld.id)))
          WHERE ((1 = 1) AND (active_records.actvie_row = 1))) oam ON ((oam.opportunity_id = opty.id)))
     LEFT JOIN public.users usram ON ((usram.id = opty.am_id)))
     LEFT JOIN public.users usrisg ON ((usrisg.id = opty.isg_id)))
  ORDER BY cmp.company_name, ldpt.value, opty.expiry_date;


ALTER VIEW public.vr_opportunity_info OWNER TO nl2sql_ai;

--
-- TOC entry 754 (class 1259 OID 27663479)
-- Name: vr_org_branch; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_org_branch AS
 SELECT org.name AS organisation_name,
    brn.name AS branch_name,
    org.id AS organisation_id,
    brn.id AS branch_id
   FROM (public.org_branch brn
     JOIN public.organisation org ON (((org.id = brn.organisation_id) AND (brn.status_lid = 16101))));


ALTER VIEW public.vr_org_branch OWNER TO nl2sql_ai;

--
-- TOC entry 755 (class 1259 OID 27663483)
-- Name: vr_org_designation; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_org_designation AS
 SELECT org.name AS organisation_name,
    desg.name AS designation_name,
    desg.grade_level,
    org.id AS organisation_id,
    desg.id AS designation_id
   FROM (public.org_designation desg
     JOIN public.organisation org ON ((org.id = desg.organisation_id)))
  WHERE (desg.status_lid = 16101)
  ORDER BY org.name, desg.grade_level;


ALTER VIEW public.vr_org_designation OWNER TO nl2sql_ai;

--
-- TOC entry 756 (class 1259 OID 27663488)
-- Name: vr_org_vertical_department; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_org_vertical_department AS
 SELECT org.name AS organisation_name,
    sbu.name AS sbu_name,
    ver.name AS vertical_name,
    dept.name AS department_name,
    org.id AS organisation_id,
    sbu.id AS sbu_id,
    ver.id AS vertical_id,
    dept.id AS department_id
   FROM (((public.organisation org
     JOIN public.org_sbu sbu ON (((sbu.organisation_id = org.id) AND (sbu.status_lid = 16101))))
     JOIN public.org_vertical ver ON (((org.id = ver.organisation_id) AND (sbu.id = ver.sbu_id) AND (ver.status_lid = 16101))))
     JOIN public.org_department dept ON (((ver.id = dept.vertical_id) AND (dept.status_lid = 16101))))
  ORDER BY org.name, sbu.name, ver.name, dept.name;


ALTER VIEW public.vr_org_vertical_department OWNER TO nl2sql_ai;

--
-- TOC entry 757 (class 1259 OID 27663493)
-- Name: vr_performed_opty_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_performed_opty_info AS
 SELECT 'Policy'::text AS record_type,
    orgb.name AS policy_owner_branch_name,
    optyownrsbu.name AS opportunity_owner_sbu,
    optyownr.email_id AS opportunity_owner_email,
    cmp.display_name AS company_display_name,
    cmp.id AS company_id,
    TRIM(BOTH FROM (((ca.addr_1)::text || ' '::text) || (ca.addr_2)::text)) AS company_address,
    ca.id AS company_address_id,
    plc.policy_type_lid AS policy_type_id,
    optyownr.id AS opportunity_owner_id,
    plc.insurer_policy_number,
    ins.display_name AS insurer_display_name,
    TRIM(BOTH FROM (((opsimadd.addr_1)::text || ' '::text) || (opsimadd.addr_2)::text)) AS insurer_location,
    opsimct.name AS insurer_branch,
    ins.id AS insurer_id,
    opsim.insurer_branch_id,
    ccdm.communication_details AS company_contact_mobile,
    ccd.communication_details AS company_contact_email,
    ldpt.value AS policy_type,
    plc.policy_from AS policy_start_date,
    plc.policy_to AS policy_end_date,
    plc.date_of_income AS policy_payment_date,
    NULL::text AS endorsement_confirmation_date,
    plc.sum_insured AS policy_sum_insured,
    opsg.basic_premium AS policy_net_premium,
    plc.terrorism_amount AS policy_terrorism_premium,
    opsg.basic_premium AS policy_net_premium_2,
    plc.gst_amount AS policy_service_tax_amount,
    opsg.total_premium AS policy_gross_premium,
        CASE
            WHEN (plc.basic_brokerage_percentage <= (0)::numeric) THEN (ophc.basic_brokerage_percentage)::numeric
            WHEN (plc.basic_brokerage_percentage > (0)::numeric) THEN (plc.basic_brokerage_percentage)::numeric
            ELSE NULL::numeric
        END AS policy_od_percentage_brokerage_percentage,
    plc.tp_percentage AS policy_tp_percentage,
    opsg.brokerage_amount AS od_cms_amount_brokerage_amount,
    NULL::text AS tp_cms_amount,
    opsg.brokerage_amount AS policy_brokerage_amount,
    opssd.share_percentage AS policy_share_percentage,
    plc.gst AS policy_gst_percentage,
    plc.gst_amount AS policy_service_tax_amount_2,
    NULL::text AS tds_percentage_on_comm,
    NULL::text AS tds_amount_on_comm,
    NULL::text AS net_comm_post_tax_tds,
    opsg.fee AS policy_fee_amount,
    opty_contact.display_name AS company_contact_name,
        CASE
            WHEN (plc.basic_brokerage_percentage <= (0)::numeric) THEN (ophc.basic_brokerage_percentage)::numeric
            WHEN (plc.basic_brokerage_percentage > (0)::numeric) THEN (plc.basic_brokerage_percentage)::numeric
            ELSE NULL::numeric
        END AS policy_brokerage_percentage,
    plc.id AS policy_id,
    opty.id AS opportunity_id,
    plc.created_at AS policy_created_time,
    org.name AS organisation
   FROM (((((((((((((((((((((((public.opportunity opty
     JOIN public.opportunity_activity_map oam ON ((oam.opportunity_id = opty.id)))
     JOIN public.company cmp ON ((cmp.id = opty.company_id)))
     JOIN public.policy plc ON ((plc.opportunity_id = opty.id)))
     JOIN public.opportunity_activity_map pam ON ((pam.opportunity_id = opty.id)))
     JOIN public.opportunity_placement_slip_generation opsg ON ((opsg.opportunity_activity_id = pam.id)))
     LEFT JOIN public.opportunity_placement_slip_insurer_map opsim ON ((opsim.placement_slip_id = opsg.id)))
     LEFT JOIN public.insurer ins ON ((ins.id = opsim.insurer_id)))
     LEFT JOIN public.opportunity_placement_slip_sharing_detail opssd ON ((opssd.placement_slip_id = opsg.id)))
     JOIN public.users ownr ON ((ownr.id = plc.owner_id)))
     JOIN public.organisation org ON ((ownr.organisation_id = org.id)))
     JOIN public.users optyownr ON ((optyownr.id = opty.owner_id)))
     JOIN public.org_sbu optyownrsbu ON ((optyownrsbu.id = optyownr.sbu_id)))
     JOIN public.org_branch orgb ON ((ownr.branch_id = orgb.id)))
     JOIN public.lookup_data ldpt ON ((ldpt.id = plc.policy_type_lid)))
     LEFT JOIN public.opportunity_contact_map ocm ON ((ocm.opportunity_id = opty.id)))
     LEFT JOIN public.contact opty_contact ON ((opty_contact.id = ocm.contact_id)))
     LEFT JOIN public.contact_communication_details ccd ON (((ccd.contact_id = opty_contact.id) AND ((ccd.communication_type)::text = 'email'::text))))
     LEFT JOIN public.contact_communication_details ccdm ON (((ccdm.contact_id = opty_contact.id) AND ((ccdm.communication_type)::text = 'phone'::text))))
     LEFT JOIN public.opportunity_risk_location_map orlm ON ((orlm.opportunity_id = opty.id)))
     LEFT JOIN public.address ca ON ((ca.id = orlm.address_id)))
     LEFT JOIN public.address opsimadd ON ((opsimadd.id = opsim.insurer_branch_id)))
     LEFT JOIN public.city opsimct ON ((opsimct.id = opsim.insurer_location_id)))
     LEFT JOIN public.opportunity_policy_hard_copy ophc ON ((ophc.opportunity_id = opty.id)))
  WHERE ((1 = 1) AND (opty.created_at >= to_date('2025-07-01'::text, 'YYYY-MM-DD'::text)) AND ((oam.activity_key)::text = 'placement_slip_generation_activity'::text) AND (lower(TRIM(BOTH FROM cmp.company_name)) !~~ 'dummy%'::text) AND (opty.updated_by <> 2004))
  ORDER BY plc.created_at;


ALTER VIEW public.vr_performed_opty_info OWNER TO nl2sql_ai;

--
-- TOC entry 758 (class 1259 OID 27663498)
-- Name: vr_performed_opty_cd_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_performed_opty_cd_info AS
 SELECT poi.policy_id AS iworkedge_policy_id,
    cdpm.caution_deposit_id,
    cd.cd_account_name,
    cd.cd_account_number,
    cd.balance_amount AS cd_balance_amount,
    openbal.opening_balance AS cd_opening_balance_amount,
    poi.organisation
   FROM (((( SELECT DISTINCT vr_performed_opty_info.policy_id,
            vr_performed_opty_info.organisation
           FROM public.vr_performed_opty_info) poi
     LEFT JOIN public.caution_deposit_policy_mapping cdpm ON ((poi.policy_id = cdpm.policy_id)))
     LEFT JOIN public.caution_deposit cd ON ((cdpm.caution_deposit_id = cd.id)))
     LEFT JOIN ( SELECT cdt.transaction_amount AS opening_balance,
            cdt.caution_deposit_id
           FROM public.caution_deposit_transaction cdt
          WHERE ((cdt.transaction_type)::text = 'CREDIT_TRANSACTION'::text)
          ORDER BY cdt.id
         LIMIT 1) openbal ON ((openbal.caution_deposit_id = cd.id)))
  WHERE (1 = 1)
  ORDER BY poi.policy_id;


ALTER VIEW public.vr_performed_opty_cd_info OWNER TO nl2sql_ai;

--
-- TOC entry 759 (class 1259 OID 27663503)
-- Name: vr_policy_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_policy_info AS
 SELECT cmp.company_name,
    plc.policy_name,
    ldpt.value AS policy_type,
    ldopts.value AS policy_status,
    ((((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS owned_by,
    ldopts.value AS opportunity_status,
    cntry.name AS country,
    plc.policy_from AS start_date,
    plc.policy_to AS expiry_date,
    plc.provisional_policy_no,
    plc.opportunity_type,
    plc.brokerage_amount,
    plc.brokerage_collected AS brokerage_amount_collected,
    plc.insurer_endorsement_number,
    plc.date_of_income,
    plc.income_month,
    plc.gst_amount AS service_tax_amount,
    plc.net_premium AS net_premium_amount,
    plc.terrorism_amount,
    plc.other_amount,
    plc.gross_premium AS gross_premium_amount,
    plc.premium_collected AS gross_premium_amount_collected,
    plc.brokerage_amount_asper_iwork,
    plc.brokerage_amount_asper_isg,
    plc.fee_amount,
    plc.od_percentage,
    plc.tp_percentage,
    plc.net_percentage,
    plc.share_percentage,
    plc.terrorism_brokerage_percentage AS commission_terrorism_percentage,
    plc.sum_insured,
    plc.premium_at_inception,
    plc.gst_percentage AS service_tax,
    plc.gst,
    plc.insurer_policy_number,
    plc.commission_terrorism,
    plc.basic_brokerage_percentage AS brokerage_percentage,
    plc.brokerage_collected,
    plc.premium_collected,
    ins.name AS lead_insurer_name,
    org.name AS owner_organisation,
    sbu.name AS owner_sbu,
    ver.name AS owner_vertical,
    dept.name AS owner_department,
    br.name AS owner_branch,
    desg.name AS owner_designation,
    ldict.value AS income_type,
    lddw.value AS deal_own_or_not,
    ldpgp.value AS policy_group,
    ldoes.value AS enrollment_status,
    ldcs.value AS configuration_status,
    plc.mig_ref_no,
    plc.ingested_at,
    plc.ingested_mode,
    plc.rcon_status,
    plc.rcon_brokerage,
    plc.rcon_outcome,
    plc.pending_brokerage,
    plc.fee_percentage,
    plc.other_percentage,
    plc.srcc_percentage,
    plc.srcc_amount,
    plc.admin_charges_percentage,
    plc.admin_charges,
    plc.cess_percentage,
    plc.cess_amount,
    plc.total_gross_premium_inc_tax_charges,
    plc.basic_premium,
    plc.basic_premium_percentage,
    plc.tc_brokerage_amount,
    plc.basic_brokerage_amount,
    plc.srcc_brokerage_amount,
    ((((((usram.first_name)::text || ' '::text) || (usram.last_name)::text) || ' ('::text) || (usram.email_id)::text) || ')'::text) AS account_manager,
    ((((((usrisg.first_name)::text || ' '::text) || (usrisg.last_name)::text) || ' ('::text) || (usrisg.email_id)::text) || ')'::text) AS isg_owner,
    ldpds.id AS policy_details_status,
    ldpcs.id AS policy_covers_status,
    ldpcds.id AS policy_cd_status,
    ((((((usrpda.first_name)::text || ' '::text) || (usrpda.last_name)::text) || ' ('::text) || (usrpda.email_id)::text) || ')'::text) AS policy_details_approved_by,
    ((((((usrpca.first_name)::text || ' '::text) || (usrpca.last_name)::text) || ' ('::text) || (usrpca.email_id)::text) || ')'::text) AS policy_covers_approved_by,
    ((((((usrpcda.first_name)::text || ' '::text) || (usrpcda.last_name)::text) || ' ('::text) || (usrpcda.email_id)::text) || ')'::text) AS policy_cd_approved_by,
    ldipm.id AS is_policy_mined,
    ldsl.id AS service_level,
    ' - '::text AS reference,
    plc.policy_configuration,
    plc.id,
    plc.opportunity_id,
    plc.company_id,
    plc.country_id,
    plc.policy_type_lid,
    plc.status_lid,
    plc.enrollment_status_lid,
    plc.configuration_status_lid,
    plc.owner_id,
    plc.created_by,
    plc.created_at,
    plc.updated_by,
    plc.updated_at
   FROM ((((((((((((((((((((((((((((((public.policy plc
     LEFT JOIN public.company cmp ON ((cmp.id = plc.company_id)))
     LEFT JOIN public.country cntry ON ((cntry.id = cmp.country_id)))
     LEFT JOIN public.users usr ON ((usr.id = plc.owner_id)))
     LEFT JOIN public.opportunity opty ON ((opty.id = plc.opportunity_id)))
     LEFT JOIN public.lookup_data ldpt ON ((ldpt.id = plc.policy_type_lid)))
     LEFT JOIN public.lookup_data ldopts ON ((ldopts.id = opty.status_lid)))
     LEFT JOIN public.lookup_data ldoplcs ON ((ldoplcs.id = plc.status_lid)))
     LEFT JOIN public.lookup_data ldoes ON ((ldoes.id = plc.enrollment_status_lid)))
     LEFT JOIN public.lookup_data ldcs ON ((ldcs.id = plc.configuration_status_lid)))
     LEFT JOIN public.organisation org ON ((org.id = usr.organisation_id)))
     LEFT JOIN public.org_sbu sbu ON ((sbu.id = usr.sbu_id)))
     LEFT JOIN public.org_vertical ver ON ((ver.id = usr.vertical_id)))
     LEFT JOIN public.org_department dept ON ((dept.id = usr.department_id)))
     LEFT JOIN public.org_branch br ON ((br.id = usr.branch_id)))
     LEFT JOIN public.org_designation desg ON ((desg.id = usr.designation_id)))
     LEFT JOIN public.lookup_data ldict ON ((ldict.id = plc.income_type_lid)))
     LEFT JOIN public.lookup_data lddw ON ((lddw.id = plc.deal_confirmed_lid)))
     LEFT JOIN public.lookup_data ldpgp ON ((ldpgp.id = plc.policy_group_type_lid)))
     LEFT JOIN public.policy_insurer_map pim ON (((plc.id = pim.policy_id) AND (pim.insurer_participation_type_lid = 486))))
     LEFT JOIN public.insurer ins ON ((ins.id = pim.insurer_id)))
     LEFT JOIN public.users usram ON ((usram.id = plc.am_id)))
     LEFT JOIN public.users usrisg ON ((usrisg.id = plc.isg_id)))
     LEFT JOIN public.users usrpda ON ((usrpda.id = plc.policy_details_approved_by)))
     LEFT JOIN public.users usrpca ON ((usrpca.id = plc.policy_covers_approved_by)))
     LEFT JOIN public.users usrpcda ON ((usrpcda.id = plc.policy_cd_approved_by)))
     LEFT JOIN public.lookup_data ldpds ON ((ldpds.id = plc.policy_details_status_lid)))
     LEFT JOIN public.lookup_data ldpcs ON ((ldpcs.id = plc.policy_covers_status_lid)))
     LEFT JOIN public.lookup_data ldpcds ON ((ldpcds.id = plc.policy_cd_status_lid)))
     LEFT JOIN public.lookup_data ldipm ON ((ldipm.id = plc.policy_cd_status_lid)))
     LEFT JOIN public.lookup_data ldsl ON ((ldsl.id = plc.service_level_lid)))
  ORDER BY cmp.company_name, plc.policy_name;


ALTER VIEW public.vr_policy_info OWNER TO nl2sql_ai;

--
-- TOC entry 760 (class 1259 OID 27663508)
-- Name: vr_role_permission_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_role_permission_info AS
 SELECT aclcat.name AS function_name,
    aclact.name AS action_name,
    rl.name AS permitted_role_name,
    ' -- '::text AS reference,
    rlaclmap.id AS rolefunctionaction_mapping_id,
    aclcatactmap.id AS functionaction_mapping_id,
    aclcat.id AS function_id,
    aclact.id AS action_id,
    rl.id AS role_id
   FROM ((((public.acl_category_action_map aclcatactmap
     JOIN public.acl_categories aclcat ON ((aclcatactmap.acl_category_id = aclcat.id)))
     JOIN public.acl_actions aclact ON ((aclcatactmap.acl_action_id = aclact.id)))
     JOIN public.role_acl_category_action_map rlaclmap ON ((rlaclmap.acl_category_action_id = aclcatactmap.id)))
     JOIN public.roles rl ON ((rlaclmap.role_id = rl.id)));


ALTER VIEW public.vr_role_permission_info OWNER TO nl2sql_ai;

--
-- TOC entry 761 (class 1259 OID 27663513)
-- Name: vr_stage_activity_template; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_stage_activity_template AS
 SELECT org.name AS organisation,
    ldpt.value AS policy_type,
    msat.stage_name AS stage,
    msat.activity_name AS activity,
    msat.lead_days,
    msat.approval AS approval_needed_or_not,
    msat.mandatory AS mandatory_or_not,
    msat.stage_activity_order AS activity_order,
    rl.name AS applicable_role
   FROM (((public.mstr_stage_activity_template msat
     JOIN public.organisation org ON ((org.id = msat.org_id)))
     JOIN public.lookup_data ldpt ON ((ldpt.id = msat.policy_type_id)))
     JOIN public.roles rl ON (((rl.role_key)::text = (msat.ref_role_key)::text)));


ALTER VIEW public.vr_stage_activity_template OWNER TO nl2sql_ai;

--
-- TOC entry 762 (class 1259 OID 27663518)
-- Name: vr_user_access; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_user_access AS
 SELECT ahl.entity_type,
    ahl.action AS operation,
    ((((((usr.first_name)::text || ' '::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS create_by,
    ahl.created_at
   FROM (public.audit_history_log ahl
     JOIN public.users usr ON ((usr.id = (ahl.user_id)::bigint)))
  WHERE ((ahl.action)::text = ANY (ARRAY[('LOGIN'::character varying)::text, ('PASSWORD-RESET'::character varying)::text]));


ALTER VIEW public.vr_user_access OWNER TO nl2sql_ai;

--
-- TOC entry 763 (class 1259 OID 27663523)
-- Name: vr_user_activity; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_user_activity AS
 SELECT 'Company'::text AS entity_type,
    entity.company_name AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    ld.value AS status,
    entity.created_at
   FROM ((public.company entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.lookup_data ld ON ((ld.id = entity.status_lid)))
UNION
 SELECT 'Contact'::text AS entity_type,
    concat(entity.first_name, ' ', entity.last_name) AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    ld.value AS status,
    entity.created_at
   FROM ((public.contact entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.lookup_data ld ON ((ld.id = entity.status_lid)))
UNION
 SELECT 'Insurer'::text AS entity_type,
    entity.name AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    ld.value AS status,
    entity.created_at
   FROM ((public.insurer entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.lookup_data ld ON ((ld.id = entity.status_lid)))
UNION
 SELECT 'Broker'::text AS entity_type,
    entity.broker_name AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    ld.value AS status,
    entity.created_at
   FROM ((public.broker entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.lookup_data ld ON ((ld.id = entity.status_lid)))
UNION
 SELECT 'TPA'::text AS entity_type,
    entity.name AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    ld.value AS status,
    entity.created_at
   FROM ((public.tpa entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.lookup_data ld ON ((ld.id = entity.status_lid)))
UNION
 SELECT otld.value AS entity_type,
    cmp.company_name AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    sld.value AS status,
    entity.created_at
   FROM ((((public.opportunity entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.company cmp ON ((cmp.id = entity.company_id)))
     JOIN public.lookup_data otld ON ((otld.id = entity.opportunity_type_lid)))
     JOIN public.lookup_data sld ON ((sld.id = entity.status_lid)))
UNION
 SELECT 'Meeting'::text AS entity_type,
    entity.meeting_subject AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    ld.value AS status,
    entity.created_at
   FROM ((public.meeting entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.lookup_data ld ON ((ld.id = entity.meeting_status_lid)))
UNION
 SELECT 'Task'::text AS entity_type,
    entity.task_name AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    ld.value AS status,
    entity.created_at
   FROM ((public.task entity
     JOIN public.users ON ((entity.created_by = users.id)))
     JOIN public.lookup_data ld ON ((ld.id = entity.task_status_lid)))
UNION
 SELECT 'Note'::text AS entity_type,
    substr(entity.description, 1, 20) AS entity_name,
    'Creation'::text AS operation,
    concat(users.first_name, ' ', users.last_name) AS created_by,
    'Active'::text AS status,
    entity.created_at
   FROM (public.note entity
     JOIN public.users ON ((entity.created_by = users.id)));


ALTER VIEW public.vr_user_activity OWNER TO nl2sql_ai;

--
-- TOC entry 764 (class 1259 OID 27663528)
-- Name: vr_user_activity_summary; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_user_activity_summary AS
 SELECT entity_type,
    created_by,
    operation,
    count(created_by) AS count
   FROM public.vr_user_activity
  GROUP BY entity_type, operation, created_by;


ALTER VIEW public.vr_user_activity_summary OWNER TO nl2sql_ai;

--
-- TOC entry 765 (class 1259 OID 27663532)
-- Name: vr_user_hierarchy; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_user_hierarchy AS
 SELECT ((((((usr.first_name)::text || ''::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS employee_from,
    'Higher Ups'::text AS hierarchy,
    ((((((mgr.first_name)::text || ''::text) || (mgr.last_name)::text) || ' ('::text) || (mgr.email_id)::text) || ')'::text) AS employee_to,
    usr.id AS from_reference_id,
    mgr.id AS to_reference_id,
    usrsld.value AS from_reference_status,
    mgrsld.value AS to_reference_status
   FROM ((((public.employee_hierarchy eh
     JOIN public.users usr ON ((usr.id = eh.user_id)))
     JOIN public.users mgr ON ((mgr.id = eh.reporting_user_id)))
     JOIN public.lookup_data usrsld ON ((usrsld.id = usr.status_lid)))
     JOIN public.lookup_data mgrsld ON ((mgrsld.id = mgr.status_lid)))
UNION
 SELECT ((((((usr.first_name)::text || ''::text) || (usr.last_name)::text) || ' ('::text) || (usr.email_id)::text) || ')'::text) AS employee_from,
    'Reportees'::text AS hierarchy,
    ((((((mgr.first_name)::text || ''::text) || (mgr.last_name)::text) || ' ('::text) || (mgr.email_id)::text) || ')'::text) AS employee_to,
    usr.id AS from_reference_id,
    mgr.id AS to_reference_id,
    usrsld.value AS from_reference_status,
    mgrsld.value AS to_reference_status
   FROM ((((public.employee_hierarchy eh
     JOIN public.users usr ON ((usr.id = eh.reporting_user_id)))
     JOIN public.users mgr ON ((mgr.id = eh.user_id)))
     JOIN public.lookup_data usrsld ON ((usrsld.id = usr.status_lid)))
     JOIN public.lookup_data mgrsld ON ((mgrsld.id = mgr.status_lid)));


ALTER VIEW public.vr_user_hierarchy OWNER TO nl2sql_ai;

--
-- TOC entry 766 (class 1259 OID 27663537)
-- Name: vr_user_hierarchy_raw; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_user_hierarchy_raw AS
 WITH RECURSIVE hierarchy_up AS (
         SELECT users.id,
            users.id AS original_user_id,
            users.first_name,
            users.reporting_user_id,
            0 AS level,
            (users.first_name)::text AS path,
            'Self'::text AS direction,
            users.organisation_id,
            users.organisation_id AS mgr_organisation_id
           FROM public.users
          WHERE ((users.user_type_key)::text = ANY (ARRAY[('USER_TYPE_IIRM_EMPLOYEE'::character varying)::text, ('USER_TYPE_COMPANY_EMPLOYEE_AND_IIRM_EMPLOYEE'::character varying)::text]))
        UNION ALL
         SELECT u.id,
            h.original_user_id,
            u.first_name,
            u.reporting_user_id,
            (h.level + 1),
            (((u.first_name)::text || ' -> '::text) || h.path),
            'Manager'::text AS direction,
            h.organisation_id,
            u.organisation_id AS mgr_organisation_id
           FROM (public.users u
             JOIN hierarchy_up h ON (((h.reporting_user_id = u.id) AND ((u.user_type_key)::text = ANY (ARRAY[('USER_TYPE_IIRM_EMPLOYEE'::character varying)::text, ('USER_TYPE_COMPANY_EMPLOYEE_AND_IIRM_EMPLOYEE'::character varying)::text])))))
        ), hierarchy_down AS (
         SELECT users.id,
            users.id AS original_user_id,
            users.first_name,
            users.reporting_user_id,
            0 AS level,
            (users.first_name)::text AS path,
            'Reportee'::text AS direction,
            users.organisation_id,
            users.organisation_id AS mgr_organisation_id
           FROM public.users
          WHERE ((users.user_type_key)::text = ANY (ARRAY[('USER_TYPE_IIRM_EMPLOYEE'::character varying)::text, ('USER_TYPE_COMPANY_EMPLOYEE_AND_IIRM_EMPLOYEE'::character varying)::text]))
        UNION ALL
         SELECT u.id,
            h.original_user_id,
            u.first_name,
            u.reporting_user_id,
            (h.level - 1),
            ((h.path || ' -> '::text) || (u.first_name)::text),
            'Reportee'::text AS direction,
            h.organisation_id,
            u.organisation_id AS mgr_organisation_id
           FROM (public.users u
             JOIN hierarchy_down h ON (((u.reporting_user_id = h.id) AND ((u.user_type_key)::text = ANY (ARRAY[('USER_TYPE_IIRM_EMPLOYEE'::character varying)::text, ('USER_TYPE_COMPANY_EMPLOYEE_AND_IIRM_EMPLOYEE'::character varying)::text])))))
        )
 SELECT organisation_id AS manager_organisation_id,
    original_user_id AS manager_id,
    ( SELECT TRIM(BOTH FROM (((users.first_name)::text || ' '::text) || (users.last_name)::text)) AS btrim
           FROM public.users
          WHERE (users.id = combined.original_user_id)) AS manager_name,
    mgr_organisation_id AS employee_organisation_id,
    ( SELECT TRIM(BOTH FROM (((users.first_name)::text || ' '::text) || (users.last_name)::text)) AS btrim
           FROM public.users
          WHERE (users.id = combined.id)) AS employee_id,
    first_name AS employee_name,
    level AS skip_level,
        CASE
            WHEN (level > 0) THEN (('Manager (Level '::text || level) || ')'::text)
            WHEN (level = 0) THEN 'Self'::text
            ELSE (('Reportee (Level '::text || abs(level)) || ')'::text)
        END AS relationship,
    direction AS hierarchy,
    path AS hierarchy_path,
        CASE
            WHEN (level > 0) THEN (repeat('↑ '::text, level) || (first_name)::text)
            WHEN (level = 0) THEN ('● '::text || (first_name)::text)
            ELSE (repeat('↓ '::text, abs(level)) || (first_name)::text)
        END AS visual_hierarchy
   FROM ( SELECT hierarchy_up.id,
            hierarchy_up.original_user_id,
            hierarchy_up.first_name,
            hierarchy_up.reporting_user_id,
            hierarchy_up.level,
            hierarchy_up.path,
            hierarchy_up.direction,
            hierarchy_up.organisation_id,
            hierarchy_up.mgr_organisation_id
           FROM hierarchy_up
          WHERE (hierarchy_up.level >= 0)
        UNION ALL
         SELECT hierarchy_down.id,
            hierarchy_down.original_user_id,
            hierarchy_down.first_name,
            hierarchy_down.reporting_user_id,
            hierarchy_down.level,
            hierarchy_down.path,
            hierarchy_down.direction,
            hierarchy_down.organisation_id,
            hierarchy_down.mgr_organisation_id
           FROM hierarchy_down
          WHERE (hierarchy_down.level < 0)) combined
  ORDER BY original_user_id,
        CASE direction
            WHEN 'Manager'::text THEN 1
            WHEN 'Self'::text THEN 2
            WHEN 'Reportee'::text THEN 3
            ELSE NULL::integer
        END, level DESC, ( SELECT TRIM(BOTH FROM (((users.first_name)::text || ' '::text) || (users.last_name)::text)) AS btrim
           FROM public.users
          WHERE (users.id = combined.original_user_id));


ALTER VIEW public.vr_user_hierarchy_raw OWNER TO nl2sql_ai;

--
-- TOC entry 767 (class 1259 OID 27663542)
-- Name: vr_user_permission_info; Type: VIEW; Schema: public; Owner: nl2sql_ai
--

CREATE VIEW public.vr_user_permission_info AS
 SELECT DISTINCT TRIM(BOTH FROM (((usr.first_name)::text || ' '::text) || (usr.last_name)::text)) AS user_name,
    usr.email_id AS user_email,
    aclcat.name AS permitted_function_name,
    aclact.name AS permitted_action_name,
    ' -- '::text AS ref,
    usr.id AS user_id,
    emp.id AS employee_id,
    aclact.id AS action_id,
    aclcat.id AS function_id,
    string_agg((rl.id)::text, ', '::text) AS role_ids
   FROM (((((((public.acl_category_action_map aclcatactmap
     JOIN public.acl_categories aclcat ON ((aclcatactmap.acl_category_id = aclcat.id)))
     JOIN public.acl_actions aclact ON ((aclcatactmap.acl_action_id = aclact.id)))
     JOIN public.role_acl_category_action_map rlaclmap ON ((rlaclmap.acl_category_action_id = aclcatactmap.id)))
     JOIN public.roles rl ON ((rlaclmap.role_id = rl.id)))
     JOIN public.user_role url ON ((rl.id = url.role_id)))
     JOIN public.users usr ON (((url.user_id = usr.id) AND ((usr.user_type_key)::text = ANY (ARRAY[('USER_TYPE_IIRM_EMPLOYEE'::character varying)::text, ('USER_TYPE_COMPANY_EMPLOYEE_AND_IIRM_EMPLOYEE'::character varying)::text])))))
     JOIN public.employee emp ON ((emp.user_id = usr.id)))
  WHERE (1 = 1)
  GROUP BY (TRIM(BOTH FROM (((usr.first_name)::text || ' '::text) || (usr.last_name)::text))), usr.email_id, aclcat.name, aclact.name, usr.id, emp.id, aclact.id, aclcat.id
  ORDER BY usr.email_id, aclcat.name, aclact.id;


ALTER VIEW public.vr_user_permission_info OWNER TO nl2sql_ai;
--
-- TOC entry 6906 (class 2604 OID 27666053)
-- Name: acl_actions id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_actions ALTER COLUMN id SET DEFAULT nextval('public.actions_id_seq'::regclass);


--
-- TOC entry 6909 (class 2604 OID 27666054)
-- Name: acl_categories id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_categories ALTER COLUMN id SET DEFAULT nextval('public.categories_id_seq'::regclass);


--
-- TOC entry 6912 (class 2604 OID 27666055)
-- Name: acl_category_action_api_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_category_action_api_map ALTER COLUMN id SET DEFAULT nextval('public.acl_category_action_api_map_id_seq'::regclass);


--
-- TOC entry 6913 (class 2604 OID 27666056)
-- Name: acl_category_action_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_category_action_map ALTER COLUMN id SET DEFAULT nextval('public.acl_category_action_map_id_seq'::regclass);


--
-- TOC entry 6916 (class 2604 OID 27666057)
-- Name: address id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.address ALTER COLUMN id SET DEFAULT nextval('public.address_id_seq'::regclass);


--
-- TOC entry 6919 (class 2604 OID 27666058)
-- Name: admin_reports id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports ALTER COLUMN id SET DEFAULT nextval('public.admin_reports_id_seq'::regclass);


--
-- TOC entry 6922 (class 2604 OID 27666059)
-- Name: admin_reports_parameters id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports_parameters ALTER COLUMN id SET DEFAULT nextval('public.admin_reports_parameters_id_seq'::regclass);


--
-- TOC entry 6925 (class 2604 OID 27666060)
-- Name: admin_reports_results_mappings id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports_results_mappings ALTER COLUMN id SET DEFAULT nextval('public.admin_reports_results_mappings_id_seq'::regclass);


--
-- TOC entry 6928 (class 2604 OID 27666061)
-- Name: ai_conversation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.ai_conversation ALTER COLUMN id SET DEFAULT nextval('public.ai_conversation_id_seq'::regclass);


--
-- TOC entry 6930 (class 2604 OID 27666062)
-- Name: ai_conversation_message id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.ai_conversation_message ALTER COLUMN id SET DEFAULT nextval('public.ai_conversation_message_id_seq'::regclass);


--
-- TOC entry 6933 (class 2604 OID 27666063)
-- Name: announcement id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.announcement ALTER COLUMN id SET DEFAULT nextval('public.announcement_id_seq'::regclass);


--
-- TOC entry 6936 (class 2604 OID 27666064)
-- Name: archived_file_upload id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.archived_file_upload ALTER COLUMN id SET DEFAULT nextval('public.archived_file_upload_id_seq'::regclass);


--
-- TOC entry 6939 (class 2604 OID 27666065)
-- Name: audit_history_log id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.audit_history_log ALTER COLUMN id SET DEFAULT nextval('public.audit_log_id_seq'::regclass);


--
-- TOC entry 6941 (class 2604 OID 27666066)
-- Name: audit_history_log_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.audit_history_log_detail ALTER COLUMN id SET DEFAULT nextval('public.audit_log_detail_id_seq'::regclass);


--
-- TOC entry 6942 (class 2604 OID 27666067)
-- Name: authentication_methods id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.authentication_methods ALTER COLUMN id SET DEFAULT nextval('public.authentication_methods_id_seq'::regclass);


--
-- TOC entry 6946 (class 2604 OID 27666068)
-- Name: broker id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker ALTER COLUMN id SET DEFAULT nextval('public.broker_id_seq'::regclass);


--
-- TOC entry 6952 (class 2604 OID 27666069)
-- Name: broker_address id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_address ALTER COLUMN id SET DEFAULT nextval('public.broker_address_id_seq'::regclass);


--
-- TOC entry 6953 (class 2604 OID 27666070)
-- Name: broker_contact id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_contact ALTER COLUMN id SET DEFAULT nextval('public.broker_contact_id_seq'::regclass);


--
-- TOC entry 6954 (class 2604 OID 27666071)
-- Name: brokingslip_version_preferred_insurer_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_insurer_detail ALTER COLUMN id SET DEFAULT nextval('public.brokingslip_version_preferred_insurer_detail_id_seq'::regclass);


--
-- TOC entry 6955 (class 2604 OID 27666072)
-- Name: brokingslip_version_preferred_tpa_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_tpa_detail ALTER COLUMN id SET DEFAULT nextval('public.brokingslip_version_preferred_tpa_detail_id_seq'::regclass);


--
-- TOC entry 6956 (class 2604 OID 27666073)
-- Name: business_target id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.business_target ALTER COLUMN id SET DEFAULT nextval('public.business_target_id_seq'::regclass);


--
-- TOC entry 6959 (class 2604 OID 27666074)
-- Name: caution_deposit id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit ALTER COLUMN id SET DEFAULT nextval('public.caution_deposit_id_seq'::regclass);


--
-- TOC entry 6960 (class 2604 OID 27666075)
-- Name: caution_deposit_policy_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit_policy_mapping ALTER COLUMN id SET DEFAULT nextval('public.caution_deposit_policy_mapping_id_seq'::regclass);


--
-- TOC entry 6961 (class 2604 OID 27666076)
-- Name: caution_deposit_transaction id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit_transaction ALTER COLUMN id SET DEFAULT nextval('public.caution_deposit_transaction_id_seq'::regclass);


--
-- TOC entry 6963 (class 2604 OID 27666077)
-- Name: child_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.child_details ALTER COLUMN id SET DEFAULT nextval('public.child_details_id_seq'::regclass);


--
-- TOC entry 6966 (class 2604 OID 27666078)
-- Name: city id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.city ALTER COLUMN id SET DEFAULT nextval('public.city_id_seq'::regclass);


--
-- TOC entry 6967 (class 2604 OID 27666079)
-- Name: claim_activity_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_activity_document_map ALTER COLUMN id SET DEFAULT nextval('public.claim_activity_document_map_id_seq'::regclass);


--
-- TOC entry 6970 (class 2604 OID 27666080)
-- Name: claim_activity_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_activity_map ALTER COLUMN id SET DEFAULT nextval('public.claim_activity_map_id_seq'::regclass);


--
-- TOC entry 6973 (class 2604 OID 27666081)
-- Name: claim_assessment_report id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_assessment_report ALTER COLUMN id SET DEFAULT nextval('public.claim_assessment_report_id_seq'::regclass);


--
-- TOC entry 6976 (class 2604 OID 27666082)
-- Name: claim_customer_agreement id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_customer_agreement ALTER COLUMN id SET DEFAULT nextval('public.claim_customer_agreement_id_seq'::regclass);


--
-- TOC entry 6979 (class 2604 OID 27666083)
-- Name: claim_discharge_voucher id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_discharge_voucher ALTER COLUMN id SET DEFAULT nextval('public.claim_discharge_voucher_id_seq'::regclass);


--
-- TOC entry 6982 (class 2604 OID 27666084)
-- Name: claim_document_submission_tracker id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_document_submission_tracker ALTER COLUMN id SET DEFAULT nextval('public.claim_document_submission_tracker_id_seq'::regclass);


--
-- TOC entry 6985 (class 2604 OID 27666085)
-- Name: claim_documents_collected id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_documents_collected ALTER COLUMN id SET DEFAULT nextval('public.claim_documents_collected_id_seq'::regclass);


--
-- TOC entry 6988 (class 2604 OID 27666086)
-- Name: claim_fnol_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_fnol_details ALTER COLUMN id SET DEFAULT nextval('public.claim_fnol_details_id_seq'::regclass);


--
-- TOC entry 6991 (class 2604 OID 27666087)
-- Name: claim_informed id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_informed ALTER COLUMN id SET DEFAULT nextval('public.claim_informed_id_seq'::regclass);


--
-- TOC entry 6994 (class 2604 OID 27666088)
-- Name: claim_joint_inspection_report id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_joint_inspection_report ALTER COLUMN id SET DEFAULT nextval('public.claim_joint_inspection_report_id_seq'::regclass);


--
-- TOC entry 6997 (class 2604 OID 27666089)
-- Name: claim_lor_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_lor_details ALTER COLUMN id SET DEFAULT nextval('public.claim_lor_details_id_seq'::regclass);


--
-- TOC entry 7000 (class 2604 OID 27666090)
-- Name: claim_loss_adjuster_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_loss_adjuster_details ALTER COLUMN id SET DEFAULT nextval('public.claim_loss_adjuster_details_id_seq'::regclass);


--
-- TOC entry 7003 (class 2604 OID 27666091)
-- Name: claim_payment id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_payment ALTER COLUMN id SET DEFAULT nextval('public.claim_payment_id_seq'::regclass);


--
-- TOC entry 7006 (class 2604 OID 27666092)
-- Name: claim_survey_completed id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_survey_completed ALTER COLUMN id SET DEFAULT nextval('public.claim_survey_completed_id_seq'::regclass);


--
-- TOC entry 7009 (class 2604 OID 27666093)
-- Name: claim_validation_report id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_validation_report ALTER COLUMN id SET DEFAULT nextval('public.claim_validation_report_id_seq'::regclass);


--
-- TOC entry 7012 (class 2604 OID 27666094)
-- Name: claim_voucher_to_insurer id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_voucher_to_insurer ALTER COLUMN id SET DEFAULT nextval('public.claim_voucher_to_insurer_id_seq'::regclass);


--
-- TOC entry 7015 (class 2604 OID 27666095)
-- Name: company id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company ALTER COLUMN id SET DEFAULT nextval('public.company_id_seq'::regclass);


--
-- TOC entry 7027 (class 2604 OID 27666096)
-- Name: company_address id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_address ALTER COLUMN id SET DEFAULT nextval('public.company_address_id_seq'::regclass);


--
-- TOC entry 7031 (class 2604 OID 27666097)
-- Name: company_authentication_config id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_authentication_config ALTER COLUMN id SET DEFAULT nextval('public.company_authentication_config_id_seq'::regclass);


--
-- TOC entry 7034 (class 2604 OID 27666098)
-- Name: company_authentication_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_authentication_map ALTER COLUMN id SET DEFAULT nextval('public.company_authentication_mapping_id_seq'::regclass);


--
-- TOC entry 7039 (class 2604 OID 27666099)
-- Name: company_contact id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_contact ALTER COLUMN id SET DEFAULT nextval('public.company_contact_id_seq'::regclass);


--
-- TOC entry 7040 (class 2604 OID 27666100)
-- Name: company_contact_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_contact_map ALTER COLUMN id SET DEFAULT nextval('public.company_contact_map_id_seq'::regclass);


--
-- TOC entry 7041 (class 2604 OID 27666101)
-- Name: company_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_detail ALTER COLUMN id SET DEFAULT nextval('public.company_detail_id_seq'::regclass);


--
-- TOC entry 7044 (class 2604 OID 27666102)
-- Name: company_doc_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_doc_map ALTER COLUMN id SET DEFAULT nextval('public.company_doc_map_id_seq'::regclass);


--
-- TOC entry 7048 (class 2604 OID 27666103)
-- Name: company_portal_configuration id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_portal_configuration ALTER COLUMN id SET DEFAULT nextval('public.config_company_id_seq'::regclass);


--
-- TOC entry 7050 (class 2604 OID 27666104)
-- Name: company_portal_configuration_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_portal_configuration_detail ALTER COLUMN id SET DEFAULT nextval('public.company_portal_configuration_detail_id_seq'::regclass);


--
-- TOC entry 7054 (class 2604 OID 27666105)
-- Name: company_rule_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_rule_mapping ALTER COLUMN id SET DEFAULT nextval('public.company_rule_mapping_id_seq'::regclass);


--
-- TOC entry 7057 (class 2604 OID 27666106)
-- Name: company_strategy id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_strategy ALTER COLUMN id SET DEFAULT nextval('public.company_strategy_id_seq'::regclass);


--
-- TOC entry 7060 (class 2604 OID 27666107)
-- Name: contact id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact ALTER COLUMN id SET DEFAULT nextval('public.contact_id_seq'::regclass);


--
-- TOC entry 7063 (class 2604 OID 27666108)
-- Name: contact_address id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_address ALTER COLUMN id SET DEFAULT nextval('public.contact_address_id_seq'::regclass);


--
-- TOC entry 7064 (class 2604 OID 27666109)
-- Name: contact_communication_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_communication_details ALTER COLUMN id SET DEFAULT nextval('public.contact_communication_details_id_seq'::regclass);


--
-- TOC entry 7068 (class 2604 OID 27666110)
-- Name: contact_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_details ALTER COLUMN id SET DEFAULT nextval('public.contact_details_id_seq'::regclass);


--
-- TOC entry 7071 (class 2604 OID 27666111)
-- Name: contact_doc_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_doc_map ALTER COLUMN id SET DEFAULT nextval('public.contact_doc_map_id_seq'::regclass);


--
-- TOC entry 7072 (class 2604 OID 27666112)
-- Name: country id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.country ALTER COLUMN id SET DEFAULT nextval('public.country_id_seq'::regclass);


--
-- TOC entry 7084 (class 2604 OID 27666113)
-- Name: document id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.document ALTER COLUMN id SET DEFAULT nextval('public.document_id_seq'::regclass);


--
-- TOC entry 7087 (class 2604 OID 27666114)
-- Name: document_processing_file id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.document_processing_file ALTER COLUMN id SET DEFAULT nextval('public.document_processing_file_id_seq'::regclass);


--
-- TOC entry 7093 (class 2604 OID 27666115)
-- Name: employee id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee ALTER COLUMN id SET DEFAULT nextval('public.employee_id_seq'::regclass);


--
-- TOC entry 7096 (class 2604 OID 27666116)
-- Name: employee_hierarchy id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee_hierarchy ALTER COLUMN id SET DEFAULT nextval('public.employee_hierarchy_id_seq'::regclass);


--
-- TOC entry 7099 (class 2604 OID 27666117)
-- Name: endorsement id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.endorsement ALTER COLUMN id SET DEFAULT nextval('public.endorsement_id_seq'::regclass);


--
-- TOC entry 7109 (class 2604 OID 27666118)
-- Name: endorsement_field_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.endorsement_field_mapping ALTER COLUMN id SET DEFAULT nextval('public.endorsement_field_mapping_id_seq'::regclass);


--
-- TOC entry 7112 (class 2604 OID 27666119)
-- Name: file_uploads id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.file_uploads ALTER COLUMN id SET DEFAULT nextval('public.file_uploads_id_seq'::regclass);


--
-- TOC entry 7116 (class 2604 OID 27666120)
-- Name: filter_preference id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.filter_preference ALTER COLUMN id SET DEFAULT nextval('public.filter_preference_id_seq'::regclass);


--
-- TOC entry 7119 (class 2604 OID 27666121)
-- Name: final_negotiation_meeting_summary id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_meeting_summary ALTER COLUMN id SET DEFAULT nextval('public.final_negotiation_meeting_summary_id_seq'::regclass);


--
-- TOC entry 7122 (class 2604 OID 27666122)
-- Name: final_negotiation_participant_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_participant_map ALTER COLUMN id SET DEFAULT nextval('public.final_negotiation_participant_map_id_seq'::regclass);


--
-- TOC entry 7123 (class 2604 OID 27666123)
-- Name: group_company_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.group_company_map ALTER COLUMN id SET DEFAULT nextval('public.group_company_map_id_seq'::regclass);


--
-- TOC entry 7125 (class 2604 OID 27666124)
-- Name: hospital_file_upload_tracking id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.hospital_file_upload_tracking ALTER COLUMN id SET DEFAULT nextval('public.hospital_file_upload_tracking_id_seq'::regclass);


--
-- TOC entry 7131 (class 2604 OID 27666125)
-- Name: insurer id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer ALTER COLUMN id SET DEFAULT nextval('public.insurer_company_id_seq'::regclass);


--
-- TOC entry 7140 (class 2604 OID 27666126)
-- Name: insurer_address id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_address ALTER COLUMN id SET DEFAULT nextval('public.insurer_address_id_seq'::regclass);


--
-- TOC entry 7143 (class 2604 OID 27666127)
-- Name: insurer_contact id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_contact ALTER COLUMN id SET DEFAULT nextval('public.insurer_contact_id_seq'::regclass);


--
-- TOC entry 7146 (class 2604 OID 27666128)
-- Name: insurer_participant_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_participant_map ALTER COLUMN id SET DEFAULT nextval('public.insurer_participant_map_id_seq'::regclass);


--
-- TOC entry 7147 (class 2604 OID 27666129)
-- Name: knowledge_central id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.knowledge_central ALTER COLUMN id SET DEFAULT nextval('public.knowledge_central_id_seq'::regclass);


--
-- TOC entry 7153 (class 2604 OID 27666130)
-- Name: localization_company_regulatory_fields id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_company_regulatory_fields ALTER COLUMN id SET DEFAULT nextval('public.localization_company_regulatory_fields_id_seq'::regclass);


--
-- TOC entry 7156 (class 2604 OID 27666131)
-- Name: localization_country id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_country ALTER COLUMN id SET DEFAULT nextval('public.localization_country_id_seq'::regclass);


--
-- TOC entry 7159 (class 2604 OID 27666132)
-- Name: localization_regulatory_fields_country_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_regulatory_fields_country_map ALTER COLUMN id SET DEFAULT nextval('public.localization_regulatory_fields_country_map_id_seq'::regclass);


--
-- TOC entry 7162 (class 2604 OID 27666133)
-- Name: localization_report_fields id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_report_fields ALTER COLUMN id SET DEFAULT nextval('public.localization_report_fields_id_seq'::regclass);


--
-- TOC entry 7165 (class 2604 OID 27666134)
-- Name: localization_report_fields_country_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_report_fields_country_map ALTER COLUMN id SET DEFAULT nextval('public.localization_report_fields_country_map_id_seq'::regclass);


--
-- TOC entry 7168 (class 2604 OID 27666135)
-- Name: lookup_data id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.lookup_data ALTER COLUMN id SET DEFAULT nextval('public.lookup_data_id_seq'::regclass);


--
-- TOC entry 7177 (class 2604 OID 27666136)
-- Name: meeting_challenges_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_challenges_map ALTER COLUMN id SET DEFAULT nextval('public.meeting_challenges_map_id_seq'::regclass);


--
-- TOC entry 7180 (class 2604 OID 27666137)
-- Name: meeting_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_document_map ALTER COLUMN id SET DEFAULT nextval('public.meeting_document_map_id_seq'::regclass);


--
-- TOC entry 7181 (class 2604 OID 27666138)
-- Name: meeting_next_steps_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_next_steps_map ALTER COLUMN id SET DEFAULT nextval('public.meeting_next_steps_map_id_seq'::regclass);


--
-- TOC entry 7184 (class 2604 OID 27666139)
-- Name: meeting_outcomes_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_outcomes_map ALTER COLUMN id SET DEFAULT nextval('public.meeting_outcomes_map_id_seq'::regclass);


--
-- TOC entry 7195 (class 2604 OID 27666140)
-- Name: mstr_claim_activity id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_claim_activity ALTER COLUMN id SET DEFAULT nextval('public.mstr_claim_activity_id_seq'::regclass);


--
-- TOC entry 7198 (class 2604 OID 27666141)
-- Name: mstr_claim_stage id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_claim_stage ALTER COLUMN id SET DEFAULT nextval('public.mstr_claim_stage_id_seq'::regclass);


--
-- TOC entry 7201 (class 2604 OID 27666142)
-- Name: mstr_claim_stage_activity_template id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_claim_stage_activity_template ALTER COLUMN id SET DEFAULT nextval('public.mstr_claim_stage_activity_template_id_seq'::regclass);


--
-- TOC entry 7219 (class 2604 OID 27666143)
-- Name: mstr_hospital id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_hospital ALTER COLUMN id SET DEFAULT nextval('public.mstr_hospital_id_seq'::regclass);


--
-- TOC entry 7222 (class 2604 OID 27666144)
-- Name: mstr_hospital_address id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_hospital_address ALTER COLUMN id SET DEFAULT nextval('public.mstr_hospital_address_id_seq'::regclass);


--
-- TOC entry 7225 (class 2604 OID 27666145)
-- Name: mstr_nudge id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge ALTER COLUMN id SET DEFAULT nextval('public.mstr_nudge_id_seq'::regclass);


--
-- TOC entry 7231 (class 2604 OID 27666146)
-- Name: mstr_nudge_action id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_action ALTER COLUMN id SET DEFAULT nextval('public.mstr_nudge_action_id_seq'::regclass);


--
-- TOC entry 7236 (class 2604 OID 27666147)
-- Name: mstr_nudge_parameters id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_parameters ALTER COLUMN id SET DEFAULT nextval('public.mstr_nudge_parameters_id_seq'::regclass);


--
-- TOC entry 7241 (class 2604 OID 27666148)
-- Name: mstr_nudge_scope id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_scope ALTER COLUMN id SET DEFAULT nextval('public.mstr_nudge_scope_id_seq'::regclass);


--
-- TOC entry 7245 (class 2604 OID 27666149)
-- Name: mstr_nudge_scope_role_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_scope_role_mapping ALTER COLUMN id SET DEFAULT nextval('public.mstr_nudge_scope_role_mapping_id_seq'::regclass);


--
-- TOC entry 7250 (class 2604 OID 27666150)
-- Name: mstr_org_service_weightage id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_org_service_weightage ALTER COLUMN id SET DEFAULT nextval('public.mstr_org_service_weightage_id_seq'::regclass);


--
-- TOC entry 7253 (class 2604 OID 27666151)
-- Name: mstr_policy_constraints id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_constraints ALTER COLUMN id SET DEFAULT nextval('public.mstr_policy_constraints_id_seq'::regclass);


--
-- TOC entry 7256 (class 2604 OID 27666152)
-- Name: mstr_policy_endorsement_steps id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_endorsement_steps ALTER COLUMN id SET DEFAULT nextval('public.mstr_policy_endorsement_steps_id_seq'::regclass);


--
-- TOC entry 7257 (class 2604 OID 27666153)
-- Name: mstr_policy_hospital_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_hospital_map ALTER COLUMN id SET DEFAULT nextval('public.mstr_policy_hospital_map_id_seq'::regclass);


--
-- TOC entry 7261 (class 2604 OID 27666154)
-- Name: mstr_service id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_service ALTER COLUMN id SET DEFAULT nextval('public.mstr_service_id_seq'::regclass);


--
-- TOC entry 7277 (class 2604 OID 27666155)
-- Name: mstr_tat_bucket id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_tat_bucket ALTER COLUMN id SET DEFAULT nextval('public.mstr_tat_bucket_id_seq'::regclass);


--
-- TOC entry 7283 (class 2604 OID 27666156)
-- Name: note id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note ALTER COLUMN id SET DEFAULT nextval('public.note_id_seq'::regclass);


--
-- TOC entry 7287 (class 2604 OID 27666157)
-- Name: note_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note_document_map ALTER COLUMN id SET DEFAULT nextval('public.note_document_map_id_seq'::regclass);


--
-- TOC entry 7288 (class 2604 OID 27666158)
-- Name: notification_channel_event_template_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_channel_event_template_mapping ALTER COLUMN id SET DEFAULT nextval('public.notification_channel_event_template_mapping_id_seq'::regclass);


--
-- TOC entry 7293 (class 2604 OID 27666159)
-- Name: notification_channel_type id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_channel_type ALTER COLUMN id SET DEFAULT nextval('public.notification_channel_type_id_seq'::regclass);


--
-- TOC entry 7110 (class 2604 OID 27666160)
-- Name: notification_event_parameter_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_parameter_mapping ALTER COLUMN id SET DEFAULT nextval('public.event_parameter_mapping_id_seq'::regclass);


--
-- TOC entry 7298 (class 2604 OID 27666161)
-- Name: notification_event_template_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_template_mapping ALTER COLUMN id SET DEFAULT nextval('public.notification_event_template_mapping_id_seq'::regclass);


--
-- TOC entry 7299 (class 2604 OID 27666162)
-- Name: notification_event_type id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_type ALTER COLUMN id SET DEFAULT nextval('public.notification_event_type_id_seq'::regclass);


--
-- TOC entry 7300 (class 2604 OID 27666163)
-- Name: notification_in_app id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_in_app ALTER COLUMN id SET DEFAULT nextval('public.notification_in_app_id_seq'::regclass);


--
-- TOC entry 7303 (class 2604 OID 27666164)
-- Name: notification_log id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_log ALTER COLUMN id SET DEFAULT nextval('public.notification_log_id_seq'::regclass);


--
-- TOC entry 7305 (class 2604 OID 27666165)
-- Name: notification_log_receiver_record id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_log_receiver_record ALTER COLUMN id SET DEFAULT nextval('public.notification_log_receiver_record_id_seq'::regclass);


--
-- TOC entry 7306 (class 2604 OID 27666166)
-- Name: notification_parameter id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_parameter ALTER COLUMN id SET DEFAULT nextval('public.notification_parameter_id_seq'::regclass);


--
-- TOC entry 7307 (class 2604 OID 27666167)
-- Name: notification_template id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_template ALTER COLUMN id SET DEFAULT nextval('public.notification_template_id_seq'::regclass);


--
-- TOC entry 7308 (class 2604 OID 27666168)
-- Name: opportunity id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity ALTER COLUMN id SET DEFAULT nextval('public.opportunity_id_seq'::regclass);


--
-- TOC entry 7321 (class 2604 OID 27666169)
-- Name: opportunity_broking_slip_activity_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_activity_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_broking_slip_activity_document_map_id_seq'::regclass);


--
-- TOC entry 7322 (class 2604 OID 27666170)
-- Name: opportunity_broking_slip_document_map_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_document_map_details ALTER COLUMN id SET DEFAULT nextval('public.opportunity_broking_slip_document_map_details_id_seq'::regclass);


--
-- TOC entry 7323 (class 2604 OID 27666171)
-- Name: opportunity_broking_slip_version_cover_map_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_version_cover_map_details ALTER COLUMN id SET DEFAULT nextval('public.opportunity_broking_slip_version_cover_map_details_id_seq'::regclass);


--
-- TOC entry 7326 (class 2604 OID 27666172)
-- Name: opportunity_broking_slip_version_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_version_details ALTER COLUMN id SET DEFAULT nextval('public.opportunity_broking_slip_version_details_id_seq'::regclass);


--
-- TOC entry 7329 (class 2604 OID 27666173)
-- Name: opportunity_challenges id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_challenges ALTER COLUMN id SET DEFAULT nextval('public.opportunity_challenges_id_seq'::regclass);


--
-- TOC entry 7330 (class 2604 OID 27666174)
-- Name: opportunity_claim_experience id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_claim_experience ALTER COLUMN id SET DEFAULT nextval('public.opportunity_claim_experience_id_seq'::regclass);


--
-- TOC entry 7331 (class 2604 OID 27666175)
-- Name: opportunity_competitor id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_competitor ALTER COLUMN id SET DEFAULT nextval('public.opportunity_competitor_id_seq'::regclass);


--
-- TOC entry 7332 (class 2604 OID 27666176)
-- Name: opportunity_contact_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_contact_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_contact_map_id_seq'::regclass);


--
-- TOC entry 7341 (class 2604 OID 27666177)
-- Name: opportunity_data_validation_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_data_validation_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_data_validation_document_map_id_seq'::regclass);


--
-- TOC entry 7342 (class 2604 OID 27666178)
-- Name: opportunity_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_document_map_id_seq'::regclass);


--
-- TOC entry 7343 (class 2604 OID 27666179)
-- Name: opportunity_final_negotiation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_id_seq'::regclass);


--
-- TOC entry 7346 (class 2604 OID 27666180)
-- Name: opportunity_final_negotiation_doc_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_doc_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_doc_map_id_seq'::regclass);


--
-- TOC entry 7347 (class 2604 OID 27666181)
-- Name: opportunity_final_negotiation_qcr_variation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_qcr_variation ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_qcr_variation_id_seq'::regclass);


--
-- TOC entry 7348 (class 2604 OID 27666182)
-- Name: opportunity_final_negotiation_quote_cover_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_quote_cover_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_quote_cover_detail_id_seq'::regclass);


--
-- TOC entry 7351 (class 2604 OID 27666183)
-- Name: opportunity_final_negotiation_quote_documents id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_quote_documents ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_quote_documents_id_seq'::regclass);


--
-- TOC entry 7354 (class 2604 OID 27666184)
-- Name: opportunity_final_negotiation_service_level_agreement id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_service_level_agreement ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_service_level_agreement_id_seq'::regclass);


--
-- TOC entry 7355 (class 2604 OID 27666185)
-- Name: opportunity_final_negotiation_sharing_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_sharing_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_sharing_detail_id_seq'::regclass);


--
-- TOC entry 7356 (class 2604 OID 27666186)
-- Name: opportunity_final_negotiation_tax_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_tax_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_final_negotiation_tax_map_id_seq'::regclass);


--
-- TOC entry 7357 (class 2604 OID 27666187)
-- Name: opportunity_hand_over_meet id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_hand_over_meet ALTER COLUMN id SET DEFAULT nextval('public.opportunity_hand_over_meet_id_seq'::regclass);


--
-- TOC entry 7360 (class 2604 OID 27666188)
-- Name: opportunity_held_cover_note id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note ALTER COLUMN id SET DEFAULT nextval('public.opportunity_held_cover_note_id_seq'::regclass);


--
-- TOC entry 7363 (class 2604 OID 27666189)
-- Name: opportunity_held_cover_note_cover_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_cover_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_held_cover_note_cover_detail_id_seq'::regclass);


--
-- TOC entry 7124 (class 2604 OID 27666190)
-- Name: opportunity_held_cover_note_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_document_map ALTER COLUMN id SET DEFAULT nextval('public.held_cover_note_document_map_id_seq'::regclass);


--
-- TOC entry 7366 (class 2604 OID 27666191)
-- Name: opportunity_held_cover_note_insurer_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_insurer_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_held_cover_note_insurer_map_id_seq'::regclass);


--
-- TOC entry 7367 (class 2604 OID 27666192)
-- Name: opportunity_kdm_meeting id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_kdm_meeting ALTER COLUMN id SET DEFAULT nextval('public.opportunity_kdm_meeting_id_seq'::regclass);


--
-- TOC entry 7370 (class 2604 OID 27666193)
-- Name: opportunity_lost id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_lost ALTER COLUMN id SET DEFAULT nextval('public.opportunity_lost_id_seq'::regclass);


--
-- TOC entry 7373 (class 2604 OID 27666194)
-- Name: opportunity_mandate_details_contact_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_contact_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_mandate_details_contact_map_id_seq'::regclass);


--
-- TOC entry 7374 (class 2604 OID 27666195)
-- Name: opportunity_mandate_details_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_mandate_details_document_map_id_seq'::regclass);


--
-- TOC entry 7375 (class 2604 OID 27666196)
-- Name: opportunity_mandate_details_entry id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_entry ALTER COLUMN id SET DEFAULT nextval('public.opportunity_mandate_details_entry_id_seq'::regclass);


--
-- TOC entry 7379 (class 2604 OID 27666197)
-- Name: opportunity_meeting_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_meeting_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_meeting_document_map_id_seq'::regclass);


--
-- TOC entry 7380 (class 2604 OID 27666198)
-- Name: opportunity_meeting_participant_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_meeting_participant_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_meeting_participant_map_id_seq'::regclass);


--
-- TOC entry 7383 (class 2604 OID 27666199)
-- Name: opportunity_placement_slip_cd_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_cd_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_cd_detail_id_seq'::regclass);


--
-- TOC entry 7386 (class 2604 OID 27666200)
-- Name: opportunity_placement_slip_cover_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_cover_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_cover_detail_id_seq'::regclass);


--
-- TOC entry 7389 (class 2604 OID 27666201)
-- Name: opportunity_placement_slip_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_document_map_id_seq'::regclass);


--
-- TOC entry 7390 (class 2604 OID 27666202)
-- Name: opportunity_placement_slip_generation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_generation ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_generation_id_seq'::regclass);


--
-- TOC entry 7394 (class 2604 OID 27666203)
-- Name: opportunity_placement_slip_installement_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_installement_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_installement_detail_id_seq'::regclass);


--
-- TOC entry 7397 (class 2604 OID 27666204)
-- Name: opportunity_placement_slip_insurer_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_insurer_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_insurer_map_id_seq'::regclass);


--
-- TOC entry 7400 (class 2604 OID 27666205)
-- Name: opportunity_placement_slip_sharing_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_sharing_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_sharing_detail_id_seq'::regclass);


--
-- TOC entry 7403 (class 2604 OID 27666206)
-- Name: opportunity_placement_slip_tpa_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_tpa_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_placement_slip_tpa_map_id_seq'::regclass);


--
-- TOC entry 7406 (class 2604 OID 27666207)
-- Name: opportunity_policy_confirmation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation ALTER COLUMN id SET DEFAULT nextval('public.opportunity_policy_confirmation_id_seq'::regclass);


--
-- TOC entry 7409 (class 2604 OID 27666208)
-- Name: opportunity_policy_confirmation_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_document_map ALTER COLUMN id SET DEFAULT nextval('public.policy_confirmation_document_map_id_seq'::regclass);


--
-- TOC entry 7410 (class 2604 OID 27666209)
-- Name: opportunity_policy_confirmation_insurer_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_insurer_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_policy_confirmation_insurer_map_id_seq'::regclass);


--
-- TOC entry 7411 (class 2604 OID 27666210)
-- Name: opportunity_policy_docket id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket ALTER COLUMN id SET DEFAULT nextval('public.opportunity_policy_docket_id_seq'::regclass);


--
-- TOC entry 7414 (class 2604 OID 27666211)
-- Name: opportunity_policy_docket_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket_document_map ALTER COLUMN id SET DEFAULT nextval('public.policy_docket_document_map_id_seq'::regclass);


--
-- TOC entry 7415 (class 2604 OID 27666212)
-- Name: opportunity_policy_hard_copy id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy ALTER COLUMN id SET DEFAULT nextval('public.opportunity_policy_hard_copy_id_seq'::regclass);


--
-- TOC entry 7418 (class 2604 OID 27666213)
-- Name: opportunity_policy_hard_copy_cover_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_cover_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_policy_hard_copy_cover_detail_id_seq'::regclass);


--
-- TOC entry 7421 (class 2604 OID 27666214)
-- Name: opportunity_policy_hard_copy_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_document_map ALTER COLUMN id SET DEFAULT nextval('public.policy_hard_copy_document_map_id_seq'::regclass);


--
-- TOC entry 7422 (class 2604 OID 27666215)
-- Name: opportunity_policy_hard_copy_insurer_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_insurer_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_policy_hard_copy_insurer_map_id_seq'::regclass);


--
-- TOC entry 7423 (class 2604 OID 27666216)
-- Name: opportunity_premium_calculation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation ALTER COLUMN id SET DEFAULT nextval('public.opportunity_premium_calculation_id_seq'::regclass);


--
-- TOC entry 7426 (class 2604 OID 27666217)
-- Name: opportunity_premium_calculation_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation_document_map ALTER COLUMN id SET DEFAULT nextval('public.premium_calculation_document_map_id_seq'::regclass);


--
-- TOC entry 7427 (class 2604 OID 27666218)
-- Name: opportunity_premium_cover_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_cover_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_premium_cover_detail_id_seq'::regclass);


--
-- TOC entry 7430 (class 2604 OID 27666219)
-- Name: opportunity_previous_mediator_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_mediator_details ALTER COLUMN id SET DEFAULT nextval('public.opportunity_previous_mediator_details_id_seq'::regclass);


--
-- TOC entry 7431 (class 2604 OID 27666220)
-- Name: opportunity_previous_placement_details id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_placement_details ALTER COLUMN id SET DEFAULT nextval('public.opportunity_previous_placement_details_id_seq'::regclass);


--
-- TOC entry 7432 (class 2604 OID 27666221)
-- Name: opportunity_quote id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_id_seq'::regclass);


--
-- TOC entry 7433 (class 2604 OID 27666222)
-- Name: opportunity_quote_comparison_report id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_comparison_report_id_seq'::regclass);


--
-- TOC entry 7436 (class 2604 OID 27666223)
-- Name: opportunity_quote_comparison_report_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_comparison_report_document_map_id_seq'::regclass);


--
-- TOC entry 7437 (class 2604 OID 27666224)
-- Name: opportunity_quote_cover_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_cover_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_cover_detail_id_seq'::regclass);


--
-- TOC entry 7440 (class 2604 OID 27666225)
-- Name: opportunity_quote_doc_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_doc_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_doc_map_id_seq'::regclass);


--
-- TOC entry 7443 (class 2604 OID 27666226)
-- Name: opportunity_quote_entry id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_entry ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_entry_id_seq'::regclass);


--
-- TOC entry 7446 (class 2604 OID 27666227)
-- Name: opportunity_quote_entry_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_entry_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_entry_document_map_id_seq'::regclass);


--
-- TOC entry 7447 (class 2604 OID 27666228)
-- Name: opportunity_quote_tax_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_tax_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_quote_tax_map_id_seq'::regclass);


--
-- TOC entry 7450 (class 2604 OID 27666229)
-- Name: opportunity_rfp_activity_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_activity_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_activity_document_map_id_seq'::regclass);


--
-- TOC entry 7451 (class 2604 OID 27666230)
-- Name: opportunity_rfp_client_contact_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_client_contact_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_client_contact_detail_id_seq'::regclass);


--
-- TOC entry 7454 (class 2604 OID 27666231)
-- Name: opportunity_rfp_client_contact_influencers id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_client_contact_influencers ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_client_contact_influencers_id_seq'::regclass);


--
-- TOC entry 7455 (class 2604 OID 27666232)
-- Name: opportunity_rfp_cover_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_cover_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_cover_detail_id_seq'::regclass);


--
-- TOC entry 7458 (class 2604 OID 27666233)
-- Name: opportunity_rfp_credit_sharing id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_credit_sharing ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_credit_sharing_id_seq'::regclass);


--
-- TOC entry 7461 (class 2604 OID 27666234)
-- Name: opportunity_rfp_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_detail_id_seq'::regclass);


--
-- TOC entry 7464 (class 2604 OID 27666235)
-- Name: opportunity_rfp_details_entry id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_details_entry ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_details_entry_id_seq'::regclass);


--
-- TOC entry 7467 (class 2604 OID 27666236)
-- Name: opportunity_rfp_details_entry_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_details_entry_document_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_details_entry_document_map_id_seq'::regclass);


--
-- TOC entry 7468 (class 2604 OID 27666237)
-- Name: opportunity_rfp_insurer_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_insurer_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_insurer_detail_id_seq'::regclass);


--
-- TOC entry 7471 (class 2604 OID 27666238)
-- Name: opportunity_rfp_tpa_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_tpa_detail ALTER COLUMN id SET DEFAULT nextval('public.opportunity_rfp_tpa_detail_id_seq'::regclass);


--
-- TOC entry 7474 (class 2604 OID 27666239)
-- Name: opportunity_risk_location_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_risk_location_map ALTER COLUMN id SET DEFAULT nextval('public.opportunity_risk_location_map_id_seq'::regclass);


--
-- TOC entry 7475 (class 2604 OID 27666240)
-- Name: org_branch id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_branch ALTER COLUMN id SET DEFAULT nextval('public.orgnisation_branch_id_seq'::regclass);


--
-- TOC entry 7076 (class 2604 OID 27666241)
-- Name: org_department id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_department ALTER COLUMN id SET DEFAULT nextval('public.department_id_seq'::regclass);


--
-- TOC entry 7080 (class 2604 OID 27666242)
-- Name: org_designation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_designation ALTER COLUMN id SET DEFAULT nextval('public.designation_id_seq'::regclass);


--
-- TOC entry 7479 (class 2604 OID 27666243)
-- Name: org_sbu id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_sbu ALTER COLUMN id SET DEFAULT nextval('public.org_sbu_id_seq'::regclass);


--
-- TOC entry 7482 (class 2604 OID 27666244)
-- Name: org_service_tat_summary id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_service_tat_summary ALTER COLUMN id SET DEFAULT nextval('public.org_service_tat_summary_id_seq'::regclass);


--
-- TOC entry 7488 (class 2604 OID 27666245)
-- Name: org_vertical id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_vertical ALTER COLUMN id SET DEFAULT nextval('public.orgnisation_vertical_id_seq'::regclass);


--
-- TOC entry 7492 (class 2604 OID 27666246)
-- Name: organisation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.organisation ALTER COLUMN id SET DEFAULT nextval('public.organisation_id_seq'::regclass);


--
-- TOC entry 7496 (class 2604 OID 27666247)
-- Name: password_rules id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.password_rules ALTER COLUMN id SET DEFAULT nextval('public.password_rules_id_seq'::regclass);


--
-- TOC entry 7500 (class 2604 OID 27666248)
-- Name: performance_output id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.performance_output ALTER COLUMN id SET DEFAULT nextval('public.performance_output_id_seq'::regclass);


--
-- TOC entry 7504 (class 2604 OID 27666249)
-- Name: policy id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy ALTER COLUMN id SET DEFAULT nextval('public.policy_id_seq'::regclass);


--
-- TOC entry 7513 (class 2604 OID 27666250)
-- Name: policy_asset id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_asset ALTER COLUMN id SET DEFAULT nextval('public.policy_asset_id_seq'::regclass);


--
-- TOC entry 7514 (class 2604 OID 27666251)
-- Name: policy_asset_endorsement id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_asset_endorsement ALTER COLUMN id SET DEFAULT nextval('public.policy_asset_endorsement_id_seq'::regclass);


--
-- TOC entry 7523 (class 2604 OID 27666252)
-- Name: policy_asset_endorsement_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_asset_endorsement_map ALTER COLUMN id SET DEFAULT nextval('public.policy_asset_endorsement_map_id_seq'::regclass);


--
-- TOC entry 7524 (class 2604 OID 27666253)
-- Name: policy_audit_log id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_audit_log ALTER COLUMN id SET DEFAULT nextval('public.policy_audit_log_id_seq'::regclass);


--
-- TOC entry 7526 (class 2604 OID 27666254)
-- Name: policy_cd_number_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_cd_number_map ALTER COLUMN id SET DEFAULT nextval('public.policy_cd_number_map_id_seq'::regclass);


--
-- TOC entry 7529 (class 2604 OID 27666255)
-- Name: policy_claim id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim ALTER COLUMN id SET DEFAULT nextval('public.policy_employee_claim_id_seq'::regclass);


--
-- TOC entry 7532 (class 2604 OID 27666256)
-- Name: policy_claim_settlement id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim_settlement ALTER COLUMN id SET DEFAULT nextval('public.policy_employee_claim_settlement_id_seq'::regclass);


--
-- TOC entry 7535 (class 2604 OID 27666257)
-- Name: policy_configuration id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration ALTER COLUMN id SET DEFAULT nextval('public.policy_configuration_id_seq'::regclass);


--
-- TOC entry 7539 (class 2604 OID 27666258)
-- Name: policy_configuration_component_relation_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_component_relation_map ALTER COLUMN id SET DEFAULT nextval('public.policy_configuration_component_relation_map_id_seq'::regclass);


--
-- TOC entry 7540 (class 2604 OID 27666259)
-- Name: policy_configuration_components_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_components_detail ALTER COLUMN id SET DEFAULT nextval('public.policy_configuration_components_detail_id_seq'::regclass);


--
-- TOC entry 7543 (class 2604 OID 27666260)
-- Name: policy_configuration_template_doc_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_template_doc_map ALTER COLUMN id SET DEFAULT nextval('public.policy_configuration_template_doc_map_id_seq'::regclass);


--
-- TOC entry 7544 (class 2604 OID 27666261)
-- Name: policy_cover_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_cover_map ALTER COLUMN id SET DEFAULT nextval('public.policy_cover_map_id_seq'::regclass);


--
-- TOC entry 7553 (class 2604 OID 27666262)
-- Name: policy_employee_endorsement id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_endorsement ALTER COLUMN id SET DEFAULT nextval('public.policy_employee_endorsement_id_seq'::regclass);


--
-- TOC entry 7556 (class 2604 OID 27666263)
-- Name: policy_employee_enrollment id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_enrollment ALTER COLUMN id SET DEFAULT nextval('public.policy_employee_enrollment_id_seq'::regclass);


--
-- TOC entry 7547 (class 2604 OID 27666264)
-- Name: policy_employee_enrollment_choice id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_enrollment_choice ALTER COLUMN id SET DEFAULT nextval('public.policy_employee_components_id_seq'::regclass);


--
-- TOC entry 7566 (class 2604 OID 27666265)
-- Name: policy_endorsement_template_doc_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_endorsement_template_doc_map ALTER COLUMN id SET DEFAULT nextval('public.policy_endorsement_template_doc_map_id_seq'::regclass);


--
-- TOC entry 7567 (class 2604 OID 27666266)
-- Name: policy_enrollment_dependent id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_dependent ALTER COLUMN id SET DEFAULT nextval('public.policy_enrollment_dependent_id_seq'::regclass);


--
-- TOC entry 7572 (class 2604 OID 27666267)
-- Name: policy_enrollment_employee id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee ALTER COLUMN id SET DEFAULT nextval('public.policy_enrollment_employee_id_seq'::regclass);


--
-- TOC entry 7577 (class 2604 OID 27666268)
-- Name: policy_enrollment_employee_policy_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee_policy_map ALTER COLUMN id SET DEFAULT nextval('public.policy_enrollment_employee_policy_map_id_seq'::regclass);


--
-- TOC entry 7580 (class 2604 OID 27666269)
-- Name: policy_enrollment_template_doc_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_template_doc_map ALTER COLUMN id SET DEFAULT nextval('public.policy_enrollment_template_doc_map_id_seq'::regclass);


--
-- TOC entry 7581 (class 2604 OID 27666270)
-- Name: policy_enrollment_upload_summary id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_upload_summary ALTER COLUMN id SET DEFAULT nextval('public.policy_enrollment_upload_summary_id_seq'::regclass);


--
-- TOC entry 7585 (class 2604 OID 27666271)
-- Name: policy_faq_uploads id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_faq_uploads ALTER COLUMN id SET DEFAULT nextval('public.policy_faq_uploads_id_seq'::regclass);


--
-- TOC entry 7588 (class 2604 OID 27666272)
-- Name: policy_faqs id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_faqs ALTER COLUMN id SET DEFAULT nextval('public.policy_faqs_id_seq'::regclass);


--
-- TOC entry 7591 (class 2604 OID 27666273)
-- Name: policy_feature_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_feature_document_map ALTER COLUMN id SET DEFAULT nextval('public.policy_feature_document_map_id_seq'::regclass);


--
-- TOC entry 7594 (class 2604 OID 27666274)
-- Name: policy_insurer_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_insurer_map ALTER COLUMN id SET DEFAULT nextval('public.policy_insurer_map_id_seq'::regclass);


--
-- TOC entry 7597 (class 2604 OID 27666275)
-- Name: policy_participant_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_participant_map ALTER COLUMN id SET DEFAULT nextval('public.policy_participant_map_id_seq'::regclass);


--
-- TOC entry 7598 (class 2604 OID 27666276)
-- Name: policy_premium_installment_schedules id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_premium_installment_schedules ALTER COLUMN id SET DEFAULT nextval('public.policy_premium_installment_schedules_id_seq'::regclass);


--
-- TOC entry 7601 (class 2604 OID 27666277)
-- Name: policy_risk_location_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_risk_location_map ALTER COLUMN id SET DEFAULT nextval('public.policy_risk_location_map_id_seq'::regclass);


--
-- TOC entry 7602 (class 2604 OID 27666278)
-- Name: policy_sub_asset id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_sub_asset ALTER COLUMN id SET DEFAULT nextval('public.policy_sub_asset_id_seq'::regclass);


--
-- TOC entry 7603 (class 2604 OID 27666279)
-- Name: policy_sub_asset_endorsement_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_sub_asset_endorsement_map ALTER COLUMN id SET DEFAULT nextval('public.policy_sub_asset_endorsement_map_id_seq'::regclass);


--
-- TOC entry 7604 (class 2604 OID 27666280)
-- Name: policy_tpa_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_tpa_map ALTER COLUMN id SET DEFAULT nextval('public.policy_tpa_map_id_seq'::regclass);


--
-- TOC entry 7607 (class 2604 OID 27666281)
-- Name: policy_type_and_endorsement_steps_mapping id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_and_endorsement_steps_mapping ALTER COLUMN id SET DEFAULT nextval('public.policy_type_and_endorsement_steps_mapping_id_seq'::regclass);


--
-- TOC entry 7608 (class 2604 OID 27666282)
-- Name: policy_type_segregation id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_segregation ALTER COLUMN id SET DEFAULT nextval('public.policy_type_segregation_id_seq'::regclass);


--
-- TOC entry 7609 (class 2604 OID 27666283)
-- Name: professional_experience id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.professional_experience ALTER COLUMN id SET DEFAULT nextval('public.professional_experience_id_seq'::regclass);


--
-- TOC entry 7612 (class 2604 OID 27666284)
-- Name: qualification_experience id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.qualification_experience ALTER COLUMN id SET DEFAULT nextval('public.qualification_experience_id_seq'::regclass);


--
-- TOC entry 7615 (class 2604 OID 27666285)
-- Name: region id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.region ALTER COLUMN id SET DEFAULT nextval('public.region_id_seq'::regclass);


--
-- TOC entry 7616 (class 2604 OID 27666286)
-- Name: role_acl_category_action_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.role_acl_category_action_map ALTER COLUMN id SET DEFAULT nextval('public.role_acl_category_action_map_id_seq'::regclass);


--
-- TOC entry 7619 (class 2604 OID 27666287)
-- Name: roles id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass);


--
-- TOC entry 7622 (class 2604 OID 27666288)
-- Name: service_tat_score_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.service_tat_score_map ALTER COLUMN id SET DEFAULT nextval('public.service_tat_score_map_id_seq'::regclass);


--
-- TOC entry 7624 (class 2604 OID 27666289)
-- Name: state id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state ALTER COLUMN id SET DEFAULT nextval('public.state_id_seq'::regclass);


--
-- TOC entry 7045 (class 2604 OID 27666290)
-- Name: state_gst_detail id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state_gst_detail ALTER COLUMN id SET DEFAULT nextval('public.company_gst_detail_id_seq'::regclass);


--
-- TOC entry 7631 (class 2604 OID 27666291)
-- Name: task_document_map id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task_document_map ALTER COLUMN id SET DEFAULT nextval('public.task_document_map_id_seq'::regclass);


--
-- TOC entry 7632 (class 2604 OID 27666292)
-- Name: tpa id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa ALTER COLUMN id SET DEFAULT nextval('public.tpa_id_seq'::regclass);


--
-- TOC entry 7636 (class 2604 OID 27666293)
-- Name: tpa_address id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_address ALTER COLUMN id SET DEFAULT nextval('public.tpa_address_id_seq'::regclass);


--
-- TOC entry 7637 (class 2604 OID 27666294)
-- Name: tpa_contact id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_contact ALTER COLUMN id SET DEFAULT nextval('public.tpa_contact_id_seq'::regclass);


--
-- TOC entry 7638 (class 2604 OID 27666295)
-- Name: user_role id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.user_role ALTER COLUMN id SET DEFAULT nextval('public.user_role_id_seq'::regclass);


--
-- TOC entry 7641 (class 2604 OID 27666296)
-- Name: users id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);


--
-- TOC entry 6931 (class 2604 OID 27666297)
-- Name: zz_load_all_table_user_update_status id; Type: DEFAULT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.zz_load_all_table_user_update_status ALTER COLUMN id SET DEFAULT nextval('public.all_table_user_update_status_id_seq'::regclass);


--
-- TOC entry 7680 (class 2606 OID 27688815)
-- Name: acl_category_action_api_map acl_category_action_api_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_category_action_api_map
    ADD CONSTRAINT acl_category_action_api_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7670 (class 2606 OID 27688817)
-- Name: acl_actions actions_name_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_actions
    ADD CONSTRAINT actions_name_key UNIQUE (name);


--
-- TOC entry 7693 (class 2606 OID 27688819)
-- Name: admin_reports_parameters admin_reports_parameters_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports_parameters
    ADD CONSTRAINT admin_reports_parameters_pkey PRIMARY KEY (id);


--
-- TOC entry 7691 (class 2606 OID 27688821)
-- Name: admin_reports admin_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports
    ADD CONSTRAINT admin_reports_pkey PRIMARY KEY (id);


--
-- TOC entry 7695 (class 2606 OID 27688823)
-- Name: admin_reports_results_mappings admin_reports_results_mappings_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports_results_mappings
    ADD CONSTRAINT admin_reports_results_mappings_pkey PRIMARY KEY (id);


--
-- TOC entry 7699 (class 2606 OID 27688825)
-- Name: ai_conversation_message ai_conversation_message_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.ai_conversation_message
    ADD CONSTRAINT ai_conversation_message_pkey PRIMARY KEY (id);


--
-- TOC entry 7697 (class 2606 OID 27688827)
-- Name: ai_conversation ai_conversation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.ai_conversation
    ADD CONSTRAINT ai_conversation_pkey PRIMARY KEY (id);


--
-- TOC entry 7701 (class 2606 OID 27688829)
-- Name: zz_load_all_table_user_update_status all_table_user_update_status_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.zz_load_all_table_user_update_status
    ADD CONSTRAINT all_table_user_update_status_pkey PRIMARY KEY (id);


--
-- TOC entry 7703 (class 2606 OID 27688831)
-- Name: announcement announcement_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.announcement
    ADD CONSTRAINT announcement_pkey PRIMARY KEY (id);


--
-- TOC entry 7705 (class 2606 OID 27688833)
-- Name: archived_file_upload archived_file_upload_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.archived_file_upload
    ADD CONSTRAINT archived_file_upload_pkey PRIMARY KEY (id);


--
-- TOC entry 7654 (class 2606 OID 27688834)
-- Name: audit_history_log audit_log_action_check; Type: CHECK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE public.audit_history_log
    ADD CONSTRAINT audit_log_action_check CHECK (((action)::text = ANY (ARRAY[('INSERT'::character varying)::text, ('UPDATE'::character varying)::text, ('DELETE'::character varying)::text, ('LOGIN'::character varying)::text, ('PASSWORD-RESET'::character varying)::text, ('LOGOUT'::character varying)::text]))) NOT VALID;


--
-- TOC entry 7712 (class 2606 OID 27688836)
-- Name: audit_history_log_detail audit_log_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.audit_history_log_detail
    ADD CONSTRAINT audit_log_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 7707 (class 2606 OID 27688848)
-- Name: audit_history_log audit_log_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.audit_history_log
    ADD CONSTRAINT audit_log_pkey PRIMARY KEY (id);


--
-- TOC entry 7715 (class 2606 OID 27688850)
-- Name: authentication_methods authentication_methods_method_code_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.authentication_methods
    ADD CONSTRAINT authentication_methods_method_code_key UNIQUE (method_code);


--
-- TOC entry 7717 (class 2606 OID 27688852)
-- Name: authentication_methods authentication_methods_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.authentication_methods
    ADD CONSTRAINT authentication_methods_pkey PRIMARY KEY (id);


--
-- TOC entry 7730 (class 2606 OID 27688854)
-- Name: broker_contact broker_contact_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_contact
    ADD CONSTRAINT broker_contact_pkey PRIMARY KEY (id);


--
-- TOC entry 7732 (class 2606 OID 27688856)
-- Name: brokingslip_version_preferred_insurer_detail brokingslip_version_preferred_insurer_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_insurer_detail
    ADD CONSTRAINT brokingslip_version_preferred_insurer_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 7734 (class 2606 OID 27688858)
-- Name: brokingslip_version_preferred_tpa_detail brokingslip_version_preferred_tpa_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_tpa_detail
    ADD CONSTRAINT brokingslip_version_preferred_tpa_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 7736 (class 2606 OID 27688860)
-- Name: business_target business_target_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.business_target
    ADD CONSTRAINT business_target_pkey PRIMARY KEY (id);


--
-- TOC entry 7675 (class 2606 OID 27688862)
-- Name: acl_categories categories_name_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_categories
    ADD CONSTRAINT categories_name_key UNIQUE (name);


--
-- TOC entry 7740 (class 2606 OID 27688864)
-- Name: caution_deposit caution_deposit_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit
    ADD CONSTRAINT caution_deposit_pkey PRIMARY KEY (id);


--
-- TOC entry 7742 (class 2606 OID 27688866)
-- Name: caution_deposit_policy_mapping caution_deposit_policy_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit_policy_mapping
    ADD CONSTRAINT caution_deposit_policy_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 7744 (class 2606 OID 27688868)
-- Name: caution_deposit_transaction caution_deposit_transaction_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit_transaction
    ADD CONSTRAINT caution_deposit_transaction_pkey PRIMARY KEY (id);


--
-- TOC entry 7755 (class 2606 OID 27688870)
-- Name: claim_activity_document_map claim_activity_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_activity_document_map
    ADD CONSTRAINT claim_activity_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7758 (class 2606 OID 27688872)
-- Name: claim_activity_map claim_activity_map_claim_number_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_activity_map
    ADD CONSTRAINT claim_activity_map_claim_number_key UNIQUE (claim_number);


--
-- TOC entry 7760 (class 2606 OID 27688874)
-- Name: claim_activity_map claim_activity_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_activity_map
    ADD CONSTRAINT claim_activity_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7766 (class 2606 OID 27688876)
-- Name: claim_assessment_report claim_assessment_report_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_assessment_report
    ADD CONSTRAINT claim_assessment_report_pkey PRIMARY KEY (id);


--
-- TOC entry 7769 (class 2606 OID 27688878)
-- Name: claim_customer_agreement claim_customer_agreement_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_customer_agreement
    ADD CONSTRAINT claim_customer_agreement_pkey PRIMARY KEY (id);


--
-- TOC entry 7772 (class 2606 OID 27688880)
-- Name: claim_discharge_voucher claim_discharge_voucher_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_discharge_voucher
    ADD CONSTRAINT claim_discharge_voucher_pkey PRIMARY KEY (id);


--
-- TOC entry 7775 (class 2606 OID 27688882)
-- Name: claim_document_submission_tracker claim_document_submission_tracker_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_document_submission_tracker
    ADD CONSTRAINT claim_document_submission_tracker_pkey PRIMARY KEY (id);


--
-- TOC entry 7778 (class 2606 OID 27688884)
-- Name: claim_documents_collected claim_documents_collected_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_documents_collected
    ADD CONSTRAINT claim_documents_collected_pkey PRIMARY KEY (id);


--
-- TOC entry 7781 (class 2606 OID 27688886)
-- Name: claim_fnol_details claim_fnol_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_fnol_details
    ADD CONSTRAINT claim_fnol_details_pkey PRIMARY KEY (id);


--
-- TOC entry 7784 (class 2606 OID 27688888)
-- Name: claim_informed claim_informed_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_informed
    ADD CONSTRAINT claim_informed_pkey PRIMARY KEY (id);


--
-- TOC entry 7787 (class 2606 OID 27688890)
-- Name: claim_joint_inspection_report claim_joint_inspection_report_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_joint_inspection_report
    ADD CONSTRAINT claim_joint_inspection_report_pkey PRIMARY KEY (id);


--
-- TOC entry 7790 (class 2606 OID 27688892)
-- Name: claim_lor_details claim_lor_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_lor_details
    ADD CONSTRAINT claim_lor_details_pkey PRIMARY KEY (id);


--
-- TOC entry 7793 (class 2606 OID 27688894)
-- Name: claim_loss_adjuster_details claim_loss_adjuster_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_loss_adjuster_details
    ADD CONSTRAINT claim_loss_adjuster_details_pkey PRIMARY KEY (id);


--
-- TOC entry 7796 (class 2606 OID 27688896)
-- Name: claim_payment claim_payment_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_payment
    ADD CONSTRAINT claim_payment_pkey PRIMARY KEY (id);


--
-- TOC entry 7799 (class 2606 OID 27688898)
-- Name: claim_survey_completed claim_survey_completed_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_survey_completed
    ADD CONSTRAINT claim_survey_completed_pkey PRIMARY KEY (id);


--
-- TOC entry 7802 (class 2606 OID 27688900)
-- Name: claim_validation_report claim_validation_report_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_validation_report
    ADD CONSTRAINT claim_validation_report_pkey PRIMARY KEY (id);


--
-- TOC entry 7805 (class 2606 OID 27688902)
-- Name: claim_voucher_to_insurer claim_voucher_to_insurer_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.claim_voucher_to_insurer
    ADD CONSTRAINT claim_voucher_to_insurer_pkey PRIMARY KEY (id);


--
-- TOC entry 7822 (class 2606 OID 27688904)
-- Name: company_authentication_config company_authentication_config_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_authentication_config
    ADD CONSTRAINT company_authentication_config_pkey PRIMARY KEY (id);


--
-- TOC entry 7824 (class 2606 OID 27688906)
-- Name: company_authentication_map company_authentication_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_authentication_map
    ADD CONSTRAINT company_authentication_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 7843 (class 2606 OID 27688908)
-- Name: state_gst_detail company_gst_detail_gst_number_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state_gst_detail
    ADD CONSTRAINT company_gst_detail_gst_number_key UNIQUE (gst_number);


--
-- TOC entry 7852 (class 2606 OID 27688910)
-- Name: company_portal_configuration_detail company_portal_configuration_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_portal_configuration_detail
    ADD CONSTRAINT company_portal_configuration_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 7854 (class 2606 OID 27688912)
-- Name: company_rule_mapping company_rule_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_rule_mapping
    ADD CONSTRAINT company_rule_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 7849 (class 2606 OID 27688914)
-- Name: company_portal_configuration config_company_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_portal_configuration
    ADD CONSTRAINT config_company_pkey PRIMARY KEY (id);


--
-- TOC entry 8124 (class 2606 OID 27688916)
-- Name: opportunity_data_validation data_validation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_data_validation
    ADD CONSTRAINT data_validation_pkey PRIMARY KEY (id);


--
-- TOC entry 7902 (class 2606 OID 27688918)
-- Name: document_processing_file document_processing_file_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.document_processing_file
    ADD CONSTRAINT document_processing_file_pkey PRIMARY KEY (id);


--
-- TOC entry 7905 (class 2606 OID 27688920)
-- Name: employee employee_email_id_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee
    ADD CONSTRAINT employee_email_id_key UNIQUE (email_id);


--
-- TOC entry 7910 (class 2606 OID 27688922)
-- Name: employee_hierarchy employee_hierarchy_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee_hierarchy
    ADD CONSTRAINT employee_hierarchy_pkey PRIMARY KEY (id);


--
-- TOC entry 7917 (class 2606 OID 27688924)
-- Name: endorsement_field_mapping endorsement_field_mapping_insurer_id_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.endorsement_field_mapping
    ADD CONSTRAINT endorsement_field_mapping_insurer_id_key UNIQUE (insurer_id);


--
-- TOC entry 7914 (class 2606 OID 27688926)
-- Name: endorsement endorsement_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.endorsement
    ADD CONSTRAINT endorsement_pkey PRIMARY KEY (id);


--
-- TOC entry 7921 (class 2606 OID 27688928)
-- Name: notification_event_parameter_mapping event_parameter_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_parameter_mapping
    ADD CONSTRAINT event_parameter_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 7923 (class 2606 OID 27688930)
-- Name: file_uploads file_uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.file_uploads
    ADD CONSTRAINT file_uploads_pkey PRIMARY KEY (id);


--
-- TOC entry 7927 (class 2606 OID 27688932)
-- Name: final_negotiation_meeting_summary final_negotiation_meeting_summary_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_meeting_summary
    ADD CONSTRAINT final_negotiation_meeting_summary_pkey PRIMARY KEY (id);


--
-- TOC entry 7929 (class 2606 OID 27688934)
-- Name: final_negotiation_participant_map final_negotiation_participant_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_participant_map
    ADD CONSTRAINT final_negotiation_participant_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7931 (class 2606 OID 27688936)
-- Name: group_company_map group_company_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.group_company_map
    ADD CONSTRAINT group_company_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7933 (class 2606 OID 27688938)
-- Name: opportunity_held_cover_note_document_map held_cover_note_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_document_map
    ADD CONSTRAINT held_cover_note_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7939 (class 2606 OID 27688940)
-- Name: hospital_file_upload_tracking hospital_file_upload_tracking_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.hospital_file_upload_tracking
    ADD CONSTRAINT hospital_file_upload_tracking_pkey PRIMARY KEY (id);


--
-- TOC entry 7948 (class 2606 OID 27688942)
-- Name: insurer_contact insurer_contact_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_contact
    ADD CONSTRAINT insurer_contact_pkey PRIMARY KEY (id);


--
-- TOC entry 7950 (class 2606 OID 27688944)
-- Name: insurer_participant_map insurer_participant_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_participant_map
    ADD CONSTRAINT insurer_participant_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7953 (class 2606 OID 27688946)
-- Name: knowledge_central knowledge_central_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.knowledge_central
    ADD CONSTRAINT knowledge_central_pkey PRIMARY KEY (id);


--
-- TOC entry 7957 (class 2606 OID 27688948)
-- Name: localization_company_regulatory_fields localization_company_regulatory_fields_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_company_regulatory_fields
    ADD CONSTRAINT localization_company_regulatory_fields_pkey PRIMARY KEY (id);


--
-- TOC entry 7959 (class 2606 OID 27688950)
-- Name: localization_country localization_country_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_country
    ADD CONSTRAINT localization_country_pkey PRIMARY KEY (id);


--
-- TOC entry 7961 (class 2606 OID 27688952)
-- Name: localization_regulatory_fields_country_map localization_regulatory_fields_country_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_regulatory_fields_country_map
    ADD CONSTRAINT localization_regulatory_fields_country_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7965 (class 2606 OID 27688954)
-- Name: localization_report_fields_country_map localization_report_fields_country_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_report_fields_country_map
    ADD CONSTRAINT localization_report_fields_country_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7963 (class 2606 OID 27688956)
-- Name: localization_report_fields localization_report_fields_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_report_fields
    ADD CONSTRAINT localization_report_fields_pkey PRIMARY KEY (id);


--
-- TOC entry 8165 (class 2606 OID 27688958)
-- Name: opportunity_mandate_details_contact_map mandate_details_contact_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_contact_map
    ADD CONSTRAINT mandate_details_contact_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8167 (class 2606 OID 27688960)
-- Name: opportunity_mandate_details_document_map mandate_details_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_document_map
    ADD CONSTRAINT mandate_details_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8169 (class 2606 OID 27688962)
-- Name: opportunity_mandate_details_entry mandate_details_entry_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_entry
    ADD CONSTRAINT mandate_details_entry_pkey PRIMARY KEY (id);


--
-- TOC entry 7988 (class 2606 OID 27688964)
-- Name: meeting_participant_map meeting_participant_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_participant_map
    ADD CONSTRAINT meeting_participant_map_pkey PRIMARY KEY (id);


--
-- TOC entry 7992 (class 2606 OID 27688966)
-- Name: mstr_claim_activity mstr_claim_activity_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_claim_activity
    ADD CONSTRAINT mstr_claim_activity_pkey PRIMARY KEY (id);


--
-- TOC entry 7996 (class 2606 OID 27688968)
-- Name: mstr_claim_stage_activity_template mstr_claim_stage_activity_template_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_claim_stage_activity_template
    ADD CONSTRAINT mstr_claim_stage_activity_template_pkey PRIMARY KEY (id);


--
-- TOC entry 7994 (class 2606 OID 27688970)
-- Name: mstr_claim_stage mstr_claim_stage_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_claim_stage
    ADD CONSTRAINT mstr_claim_stage_pkey PRIMARY KEY (id);


--
-- TOC entry 8002 (class 2606 OID 27688972)
-- Name: mstr_ext_application_ref mstr_ext_application_ref_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_ext_application_ref
    ADD CONSTRAINT mstr_ext_application_ref_pkey PRIMARY KEY (id);


--
-- TOC entry 8012 (class 2606 OID 27688974)
-- Name: mstr_hospital_address mstr_hospital_address_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_hospital_address
    ADD CONSTRAINT mstr_hospital_address_pkey PRIMARY KEY (id);


--
-- TOC entry 8007 (class 2606 OID 27688976)
-- Name: mstr_hospital mstr_hospital_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_hospital
    ADD CONSTRAINT mstr_hospital_pkey PRIMARY KEY (id);


--
-- TOC entry 8016 (class 2606 OID 27688978)
-- Name: mstr_nudge_action mstr_nudge_action_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_action
    ADD CONSTRAINT mstr_nudge_action_pkey PRIMARY KEY (id);


--
-- TOC entry 8018 (class 2606 OID 27688980)
-- Name: mstr_nudge_parameters mstr_nudge_parameters_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_parameters
    ADD CONSTRAINT mstr_nudge_parameters_pkey PRIMARY KEY (id);


--
-- TOC entry 8014 (class 2606 OID 27688982)
-- Name: mstr_nudge mstr_nudge_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge
    ADD CONSTRAINT mstr_nudge_pkey PRIMARY KEY (id);


--
-- TOC entry 8020 (class 2606 OID 27688984)
-- Name: mstr_nudge_scope mstr_nudge_scope_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_scope
    ADD CONSTRAINT mstr_nudge_scope_pkey PRIMARY KEY (id);


--
-- TOC entry 8022 (class 2606 OID 27688986)
-- Name: mstr_nudge_scope_role_mapping mstr_nudge_scope_role_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_scope_role_mapping
    ADD CONSTRAINT mstr_nudge_scope_role_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 8024 (class 2606 OID 27688988)
-- Name: mstr_org_service_weightage mstr_org_service_weightage_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_org_service_weightage
    ADD CONSTRAINT mstr_org_service_weightage_pkey PRIMARY KEY (id);


--
-- TOC entry 8028 (class 2606 OID 27688990)
-- Name: mstr_policy_constraints mstr_policy_constraints_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_constraints
    ADD CONSTRAINT mstr_policy_constraints_pkey PRIMARY KEY (id);


--
-- TOC entry 8033 (class 2606 OID 27688992)
-- Name: mstr_policy_hospital_map mstr_policy_hospital_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_hospital_map
    ADD CONSTRAINT mstr_policy_hospital_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8037 (class 2606 OID 27688994)
-- Name: mstr_service mstr_service_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_service
    ADD CONSTRAINT mstr_service_pkey PRIMARY KEY (id);


--
-- TOC entry 8039 (class 2606 OID 27688996)
-- Name: mstr_service mstr_service_service_name_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_service
    ADD CONSTRAINT mstr_service_service_name_key UNIQUE (service_name);


--
-- TOC entry 8046 (class 2606 OID 27688998)
-- Name: mstr_tat_bucket mstr_tat_bucket_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_tat_bucket
    ADD CONSTRAINT mstr_tat_bucket_pkey PRIMARY KEY (id);


--
-- TOC entry 8054 (class 2606 OID 27689000)
-- Name: notification_channel_event_template_mapping notification_channel_event_template_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_channel_event_template_mapping
    ADD CONSTRAINT notification_channel_event_template_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 8056 (class 2606 OID 27689002)
-- Name: notification_channel_type notification_channel_type_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_channel_type
    ADD CONSTRAINT notification_channel_type_pkey PRIMARY KEY (id);


--
-- TOC entry 8058 (class 2606 OID 27689004)
-- Name: notification_event_template_mapping notification_event_template_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_template_mapping
    ADD CONSTRAINT notification_event_template_mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 8060 (class 2606 OID 27689006)
-- Name: notification_event_type notification_event_type_name_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_type
    ADD CONSTRAINT notification_event_type_name_key UNIQUE (name);


--
-- TOC entry 8062 (class 2606 OID 27689008)
-- Name: notification_event_type notification_event_type_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_type
    ADD CONSTRAINT notification_event_type_pkey PRIMARY KEY (id);


--
-- TOC entry 8064 (class 2606 OID 27689010)
-- Name: notification_in_app notification_in_app_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_in_app
    ADD CONSTRAINT notification_in_app_pkey PRIMARY KEY (id);


--
-- TOC entry 8066 (class 2606 OID 27689039)
-- Name: notification_log notification_log_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_log
    ADD CONSTRAINT notification_log_pkey PRIMARY KEY (id);


--
-- TOC entry 8068 (class 2606 OID 27689083)
-- Name: notification_log_receiver_record notification_log_receiver_record_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_log_receiver_record
    ADD CONSTRAINT notification_log_receiver_record_pkey PRIMARY KEY (id);


--
-- TOC entry 8070 (class 2606 OID 27689095)
-- Name: notification_parameter notification_parameter_key_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_parameter
    ADD CONSTRAINT notification_parameter_key_key UNIQUE (key);


--
-- TOC entry 8072 (class 2606 OID 27689097)
-- Name: notification_parameter notification_parameter_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_parameter
    ADD CONSTRAINT notification_parameter_pkey PRIMARY KEY (id);


--
-- TOC entry 8074 (class 2606 OID 27689099)
-- Name: notification_template notification_template_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_template
    ADD CONSTRAINT notification_template_pkey PRIMARY KEY (id);


--
-- TOC entry 8097 (class 2606 OID 27689101)
-- Name: opportunity_broking_slip_activity_document_map opportunity_broking_slip_activity_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_activity_document_map
    ADD CONSTRAINT opportunity_broking_slip_activity_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8099 (class 2606 OID 27689103)
-- Name: opportunity_broking_slip_document_map_details opportunity_broking_slip_document_map_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_document_map_details
    ADD CONSTRAINT opportunity_broking_slip_document_map_details_pkey PRIMARY KEY (id);


--
-- TOC entry 8101 (class 2606 OID 27689105)
-- Name: opportunity_broking_slip_version_cover_map_details opportunity_broking_slip_version_cover_map_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_version_cover_map_details
    ADD CONSTRAINT opportunity_broking_slip_version_cover_map_details_pkey PRIMARY KEY (id);


--
-- TOC entry 8103 (class 2606 OID 27689107)
-- Name: opportunity_broking_slip_version_details opportunity_broking_slip_version_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_version_details
    ADD CONSTRAINT opportunity_broking_slip_version_details_pkey PRIMARY KEY (id);


--
-- TOC entry 8118 (class 2606 OID 27689109)
-- Name: opportunity_contact_map opportunity_contact_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_contact_map
    ADD CONSTRAINT opportunity_contact_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8126 (class 2606 OID 27689111)
-- Name: opportunity_data_validation_document_map opportunity_data_validation_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_data_validation_document_map
    ADD CONSTRAINT opportunity_data_validation_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8128 (class 2606 OID 27689113)
-- Name: opportunity_document_map opportunity_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_document_map
    ADD CONSTRAINT opportunity_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8132 (class 2606 OID 27689115)
-- Name: opportunity_final_negotiation_doc_map opportunity_final_negotiation_doc_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_doc_map
    ADD CONSTRAINT opportunity_final_negotiation_doc_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8130 (class 2606 OID 27689117)
-- Name: opportunity_final_negotiation opportunity_final_negotiation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation
    ADD CONSTRAINT opportunity_final_negotiation_pkey PRIMARY KEY (id);


--
-- TOC entry 8134 (class 2606 OID 27689119)
-- Name: opportunity_final_negotiation_qcr_variation opportunity_final_negotiation_qcr_variation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_qcr_variation
    ADD CONSTRAINT opportunity_final_negotiation_qcr_variation_pkey PRIMARY KEY (id);


--
-- TOC entry 8136 (class 2606 OID 27689121)
-- Name: opportunity_final_negotiation_quote_cover_detail opportunity_final_negotiation_quote_cover_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_quote_cover_detail
    ADD CONSTRAINT opportunity_final_negotiation_quote_cover_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8138 (class 2606 OID 27689123)
-- Name: opportunity_final_negotiation_quote_documents opportunity_final_negotiation_quote_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_quote_documents
    ADD CONSTRAINT opportunity_final_negotiation_quote_documents_pkey PRIMARY KEY (id);


--
-- TOC entry 8140 (class 2606 OID 27689125)
-- Name: opportunity_final_negotiation_service_level_agreement opportunity_final_negotiation_service_level_agreement_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_service_level_agreement
    ADD CONSTRAINT opportunity_final_negotiation_service_level_agreement_pkey PRIMARY KEY (id);


--
-- TOC entry 8142 (class 2606 OID 27689127)
-- Name: opportunity_final_negotiation_sharing_detail opportunity_final_negotiation_sharing_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_sharing_detail
    ADD CONSTRAINT opportunity_final_negotiation_sharing_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8144 (class 2606 OID 27689129)
-- Name: opportunity_final_negotiation_tax_map opportunity_final_negotiation_tax_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_tax_map
    ADD CONSTRAINT opportunity_final_negotiation_tax_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8146 (class 2606 OID 27689131)
-- Name: opportunity_hand_over_meet opportunity_hand_over_meet_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_hand_over_meet
    ADD CONSTRAINT opportunity_hand_over_meet_pkey PRIMARY KEY (id);


--
-- TOC entry 8157 (class 2606 OID 27689133)
-- Name: opportunity_held_cover_note_cover_detail opportunity_held_cover_note_cover_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_cover_detail
    ADD CONSTRAINT opportunity_held_cover_note_cover_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8155 (class 2606 OID 27689135)
-- Name: opportunity_held_cover_note opportunity_held_cover_note_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note
    ADD CONSTRAINT opportunity_held_cover_note_pkey PRIMARY KEY (id);


--
-- TOC entry 8163 (class 2606 OID 27689137)
-- Name: opportunity_lost opportunity_lost_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_lost
    ADD CONSTRAINT opportunity_lost_pkey PRIMARY KEY (id);


--
-- TOC entry 8173 (class 2606 OID 27689139)
-- Name: opportunity_meeting_participant_map opportunity_meeting_participant_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_meeting_participant_map
    ADD CONSTRAINT opportunity_meeting_participant_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8175 (class 2606 OID 27689141)
-- Name: opportunity_placement_slip_cd_detail opportunity_placement_slip_cd_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_cd_detail
    ADD CONSTRAINT opportunity_placement_slip_cd_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8177 (class 2606 OID 27689143)
-- Name: opportunity_placement_slip_cover_detail opportunity_placement_slip_cover_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_cover_detail
    ADD CONSTRAINT opportunity_placement_slip_cover_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8179 (class 2606 OID 27689145)
-- Name: opportunity_placement_slip_document_map opportunity_placement_slip_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_document_map
    ADD CONSTRAINT opportunity_placement_slip_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8181 (class 2606 OID 27689147)
-- Name: opportunity_placement_slip_generation opportunity_placement_slip_generation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_generation
    ADD CONSTRAINT opportunity_placement_slip_generation_pkey PRIMARY KEY (id);


--
-- TOC entry 8183 (class 2606 OID 27689149)
-- Name: opportunity_placement_slip_installement_detail opportunity_placement_slip_installement_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_installement_detail
    ADD CONSTRAINT opportunity_placement_slip_installement_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8185 (class 2606 OID 27689151)
-- Name: opportunity_placement_slip_insurer_map opportunity_placement_slip_insurer_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_insurer_map
    ADD CONSTRAINT opportunity_placement_slip_insurer_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8187 (class 2606 OID 27689153)
-- Name: opportunity_placement_slip_sharing_detail opportunity_placement_slip_sharing_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_sharing_detail
    ADD CONSTRAINT opportunity_placement_slip_sharing_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8189 (class 2606 OID 27689155)
-- Name: opportunity_placement_slip_tpa_map opportunity_placement_slip_tpa_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_tpa_map
    ADD CONSTRAINT opportunity_placement_slip_tpa_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8196 (class 2606 OID 27689157)
-- Name: opportunity_policy_confirmation opportunity_policy_confirmation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation
    ADD CONSTRAINT opportunity_policy_confirmation_pkey PRIMARY KEY (id);


--
-- TOC entry 8206 (class 2606 OID 27689159)
-- Name: opportunity_policy_docket opportunity_policy_docket_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket
    ADD CONSTRAINT opportunity_policy_docket_pkey PRIMARY KEY (id);


--
-- TOC entry 8212 (class 2606 OID 27689161)
-- Name: opportunity_policy_hard_copy opportunity_policy_hard_copy_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT opportunity_policy_hard_copy_pkey PRIMARY KEY (id);


--
-- TOC entry 8220 (class 2606 OID 27689163)
-- Name: opportunity_premium_calculation opportunity_premium_calculation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation
    ADD CONSTRAINT opportunity_premium_calculation_pkey PRIMARY KEY (id);


--
-- TOC entry 8224 (class 2606 OID 27689165)
-- Name: opportunity_premium_cover_detail opportunity_premium_cover_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_cover_detail
    ADD CONSTRAINT opportunity_premium_cover_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8226 (class 2606 OID 27689167)
-- Name: opportunity_previous_mediator_details opportunity_previous_mediator_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_mediator_details
    ADD CONSTRAINT opportunity_previous_mediator_details_pkey PRIMARY KEY (id);


--
-- TOC entry 8230 (class 2606 OID 27689169)
-- Name: opportunity_previous_placement_details opportunity_previous_placement_details_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_placement_details
    ADD CONSTRAINT opportunity_previous_placement_details_pkey PRIMARY KEY (id);


--
-- TOC entry 8236 (class 2606 OID 27689171)
-- Name: opportunity_quote_comparison_report_document_map opportunity_quote_comparison_report_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report_document_map
    ADD CONSTRAINT opportunity_quote_comparison_report_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8234 (class 2606 OID 27689173)
-- Name: opportunity_quote_comparison_report opportunity_quote_comparison_report_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report
    ADD CONSTRAINT opportunity_quote_comparison_report_pkey PRIMARY KEY (id);


--
-- TOC entry 8238 (class 2606 OID 27689175)
-- Name: opportunity_quote_cover_detail opportunity_quote_cover_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_cover_detail
    ADD CONSTRAINT opportunity_quote_cover_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8240 (class 2606 OID 27689177)
-- Name: opportunity_quote_doc_map opportunity_quote_doc_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_doc_map
    ADD CONSTRAINT opportunity_quote_doc_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8244 (class 2606 OID 27689179)
-- Name: opportunity_quote_entry_document_map opportunity_quote_entry_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_entry_document_map
    ADD CONSTRAINT opportunity_quote_entry_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8242 (class 2606 OID 27689181)
-- Name: opportunity_quote_entry opportunity_quote_entry_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_entry
    ADD CONSTRAINT opportunity_quote_entry_pkey PRIMARY KEY (id);


--
-- TOC entry 8232 (class 2606 OID 27689183)
-- Name: opportunity_quote opportunity_quote_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote
    ADD CONSTRAINT opportunity_quote_pkey PRIMARY KEY (id);


--
-- TOC entry 8246 (class 2606 OID 27689185)
-- Name: opportunity_quote_tax_map opportunity_quote_tax_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_tax_map
    ADD CONSTRAINT opportunity_quote_tax_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8252 (class 2606 OID 27689187)
-- Name: opportunity_rfp_activity_document_map opportunity_rfp_activity_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_activity_document_map
    ADD CONSTRAINT opportunity_rfp_activity_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8257 (class 2606 OID 27689189)
-- Name: opportunity_rfp_client_contact_detail opportunity_rfp_client_contact_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_client_contact_detail
    ADD CONSTRAINT opportunity_rfp_client_contact_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8262 (class 2606 OID 27689191)
-- Name: opportunity_rfp_client_contact_influencers opportunity_rfp_client_contact_influencers_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_client_contact_influencers
    ADD CONSTRAINT opportunity_rfp_client_contact_influencers_pkey PRIMARY KEY (id);


--
-- TOC entry 8268 (class 2606 OID 27689193)
-- Name: opportunity_rfp_cover_detail opportunity_rfp_cover_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_cover_detail
    ADD CONSTRAINT opportunity_rfp_cover_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8272 (class 2606 OID 27689195)
-- Name: opportunity_rfp_credit_sharing opportunity_rfp_credit_sharing_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_credit_sharing
    ADD CONSTRAINT opportunity_rfp_credit_sharing_pkey PRIMARY KEY (id);


--
-- TOC entry 8277 (class 2606 OID 27689197)
-- Name: opportunity_rfp_detail opportunity_rfp_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_detail
    ADD CONSTRAINT opportunity_rfp_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8285 (class 2606 OID 27689199)
-- Name: opportunity_rfp_details_entry_document_map opportunity_rfp_details_entry_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_details_entry_document_map
    ADD CONSTRAINT opportunity_rfp_details_entry_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8282 (class 2606 OID 27689201)
-- Name: opportunity_rfp_details_entry opportunity_rfp_details_entry_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_details_entry
    ADD CONSTRAINT opportunity_rfp_details_entry_pkey PRIMARY KEY (id);


--
-- TOC entry 8290 (class 2606 OID 27689203)
-- Name: opportunity_rfp_insurer_detail opportunity_rfp_insurer_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_insurer_detail
    ADD CONSTRAINT opportunity_rfp_insurer_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8295 (class 2606 OID 27689205)
-- Name: opportunity_rfp_tpa_detail opportunity_rfp_tpa_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_tpa_detail
    ADD CONSTRAINT opportunity_rfp_tpa_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8095 (class 2606 OID 27689207)
-- Name: opportunity_activity_participants oppty_activity_participants_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_activity_participants
    ADD CONSTRAINT oppty_activity_participants_pkey PRIMARY KEY (id);


--
-- TOC entry 8303 (class 2606 OID 27689209)
-- Name: org_sbu org_sbu_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_sbu
    ADD CONSTRAINT org_sbu_pkey PRIMARY KEY (id);


--
-- TOC entry 8306 (class 2606 OID 27689211)
-- Name: org_service_tat_summary org_service_tat_summary_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_service_tat_summary
    ADD CONSTRAINT org_service_tat_summary_pkey PRIMARY KEY (id);


--
-- TOC entry 8301 (class 2606 OID 27689213)
-- Name: org_branch orgnisation_branch_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_branch
    ADD CONSTRAINT orgnisation_branch_pkey PRIMARY KEY (id);


--
-- TOC entry 8310 (class 2606 OID 27689215)
-- Name: org_vertical orgnisation_vertical_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_vertical
    ADD CONSTRAINT orgnisation_vertical_pkey PRIMARY KEY (id);


--
-- TOC entry 8316 (class 2606 OID 27689217)
-- Name: password_rules password_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.password_rules
    ADD CONSTRAINT password_rules_pkey PRIMARY KEY (id);


--
-- TOC entry 8320 (class 2606 OID 27689219)
-- Name: performance_output performance_output_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.performance_output
    ADD CONSTRAINT performance_output_pkey PRIMARY KEY (id);


--
-- TOC entry 7683 (class 2606 OID 27689221)
-- Name: acl_category_action_map pk_acl_category_action_map_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_category_action_map
    ADD CONSTRAINT pk_acl_category_action_map_id PRIMARY KEY (id);


--
-- TOC entry 7673 (class 2606 OID 27689223)
-- Name: acl_actions pk_actions_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_actions
    ADD CONSTRAINT pk_actions_id PRIMARY KEY (id);


--
-- TOC entry 7689 (class 2606 OID 27689225)
-- Name: address pk_address_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.address
    ADD CONSTRAINT pk_address_id PRIMARY KEY (id);


--
-- TOC entry 7728 (class 2606 OID 27689227)
-- Name: broker_address pk_broker_address_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_address
    ADD CONSTRAINT pk_broker_address_id PRIMARY KEY (id);


--
-- TOC entry 7724 (class 2606 OID 27689229)
-- Name: broker pk_broker_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker
    ADD CONSTRAINT pk_broker_id PRIMARY KEY (id);


--
-- TOC entry 7678 (class 2606 OID 27689231)
-- Name: acl_categories pk_categories_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_categories
    ADD CONSTRAINT pk_categories_id PRIMARY KEY (id);


--
-- TOC entry 7749 (class 2606 OID 27689233)
-- Name: child_details pk_child_details_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.child_details
    ADD CONSTRAINT pk_child_details_id PRIMARY KEY (id);


--
-- TOC entry 7753 (class 2606 OID 27689235)
-- Name: city pk_city_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.city
    ADD CONSTRAINT pk_city_id PRIMARY KEY (id);


--
-- TOC entry 7814 (class 2606 OID 27689237)
-- Name: company pk_company; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company
    ADD CONSTRAINT pk_company PRIMARY KEY (id);


--
-- TOC entry 7820 (class 2606 OID 27689239)
-- Name: company_address pk_company_address; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_address
    ADD CONSTRAINT pk_company_address PRIMARY KEY (id);


--
-- TOC entry 7832 (class 2606 OID 27689241)
-- Name: company_contact pk_company_contact_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_contact
    ADD CONSTRAINT pk_company_contact_id PRIMARY KEY (id);


--
-- TOC entry 7836 (class 2606 OID 27689243)
-- Name: company_contact_map pk_company_contact_map_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_contact_map
    ADD CONSTRAINT pk_company_contact_map_id PRIMARY KEY (id);


--
-- TOC entry 7839 (class 2606 OID 27689245)
-- Name: company_detail pk_company_detail; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_detail
    ADD CONSTRAINT pk_company_detail PRIMARY KEY (id);


--
-- TOC entry 7841 (class 2606 OID 27689247)
-- Name: company_doc_map pk_company_doc_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_doc_map
    ADD CONSTRAINT pk_company_doc_map PRIMARY KEY (id);


--
-- TOC entry 7845 (class 2606 OID 27689249)
-- Name: state_gst_detail pk_company_gst_detail; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state_gst_detail
    ADD CONSTRAINT pk_company_gst_detail PRIMARY KEY (id);


--
-- TOC entry 7858 (class 2606 OID 27689251)
-- Name: company_strategy pk_company_strategy; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_strategy
    ADD CONSTRAINT pk_company_strategy PRIMARY KEY (id);


--
-- TOC entry 7866 (class 2606 OID 27689253)
-- Name: contact_address pk_contact_address_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_address
    ADD CONSTRAINT pk_contact_address_id PRIMARY KEY (id);


--
-- TOC entry 7871 (class 2606 OID 27689255)
-- Name: contact_communication_details pk_contact_communication_details_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_communication_details
    ADD CONSTRAINT pk_contact_communication_details_id PRIMARY KEY (id);


--
-- TOC entry 7881 (class 2606 OID 27689257)
-- Name: contact_details pk_contact_details_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_details
    ADD CONSTRAINT pk_contact_details_id PRIMARY KEY (id);


--
-- TOC entry 7883 (class 2606 OID 27689259)
-- Name: contact_doc_map pk_contact_doc_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_doc_map
    ADD CONSTRAINT pk_contact_doc_map PRIMARY KEY (id);


--
-- TOC entry 7862 (class 2606 OID 27689261)
-- Name: contact pk_contact_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact
    ADD CONSTRAINT pk_contact_id PRIMARY KEY (id);


--
-- TOC entry 7887 (class 2606 OID 27689263)
-- Name: country pk_country_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.country
    ADD CONSTRAINT pk_country_id PRIMARY KEY (id);


--
-- TOC entry 7889 (class 2606 OID 27689265)
-- Name: currency pk_currency_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.currency
    ADD CONSTRAINT pk_currency_id PRIMARY KEY (id);


--
-- TOC entry 7900 (class 2606 OID 27689267)
-- Name: document pk_document_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.document
    ADD CONSTRAINT pk_document_id PRIMARY KEY (id);


--
-- TOC entry 7908 (class 2606 OID 27689269)
-- Name: employee pk_employee_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee
    ADD CONSTRAINT pk_employee_id PRIMARY KEY (id);


--
-- TOC entry 7919 (class 2606 OID 27689271)
-- Name: endorsement_field_mapping pk_endorsement_field_mapping; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.endorsement_field_mapping
    ADD CONSTRAINT pk_endorsement_field_mapping PRIMARY KEY (id);


--
-- TOC entry 7925 (class 2606 OID 27689273)
-- Name: filter_preference pk_filter; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.filter_preference
    ADD CONSTRAINT pk_filter PRIMARY KEY (id);


--
-- TOC entry 7946 (class 2606 OID 27689275)
-- Name: insurer_address pk_insurer_address_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_address
    ADD CONSTRAINT pk_insurer_address_id PRIMARY KEY (id);


--
-- TOC entry 7944 (class 2606 OID 27689277)
-- Name: insurer pk_insurer_company_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer
    ADD CONSTRAINT pk_insurer_company_id PRIMARY KEY (id);


--
-- TOC entry 8161 (class 2606 OID 27689279)
-- Name: opportunity_kdm_meeting pk_kdm_meeting; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_kdm_meeting
    ADD CONSTRAINT pk_kdm_meeting PRIMARY KEY (id);


--
-- TOC entry 7970 (class 2606 OID 27689281)
-- Name: lookup_data pk_lookup_data_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.lookup_data
    ADD CONSTRAINT pk_lookup_data_id PRIMARY KEY (id);


--
-- TOC entry 7972 (class 2606 OID 27689283)
-- Name: meeting pk_meeting; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting
    ADD CONSTRAINT pk_meeting PRIMARY KEY (id);


--
-- TOC entry 7976 (class 2606 OID 27689285)
-- Name: meeting_challenges_map pk_meeting_challenges_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_challenges_map
    ADD CONSTRAINT pk_meeting_challenges_map PRIMARY KEY (id);


--
-- TOC entry 7978 (class 2606 OID 27689287)
-- Name: meeting_document_map pk_meeting_document_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_document_map
    ADD CONSTRAINT pk_meeting_document_map PRIMARY KEY (id);


--
-- TOC entry 7982 (class 2606 OID 27689289)
-- Name: meeting_next_steps_map pk_meeting_next_steps_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_next_steps_map
    ADD CONSTRAINT pk_meeting_next_steps_map PRIMARY KEY (id);


--
-- TOC entry 7986 (class 2606 OID 27689291)
-- Name: meeting_outcomes_map pk_meeting_outcomes_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_outcomes_map
    ADD CONSTRAINT pk_meeting_outcomes_map PRIMARY KEY (id);


--
-- TOC entry 7990 (class 2606 OID 27689293)
-- Name: mstr_activity pk_mstr_activity_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_activity
    ADD CONSTRAINT pk_mstr_activity_id PRIMARY KEY (id);


--
-- TOC entry 7998 (class 2606 OID 27689295)
-- Name: mstr_cover pk_mstr_cover_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_cover
    ADD CONSTRAINT pk_mstr_cover_id PRIMARY KEY (id);


--
-- TOC entry 8000 (class 2606 OID 27689297)
-- Name: mstr_cover_template pk_mstr_cover_template_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_cover_template
    ADD CONSTRAINT pk_mstr_cover_template_id PRIMARY KEY (id);


--
-- TOC entry 8043 (class 2606 OID 27689299)
-- Name: mstr_stage_activity_template pk_mstr_stage_activity_template_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_stage_activity_template
    ADD CONSTRAINT pk_mstr_stage_activity_template_id PRIMARY KEY (id);


--
-- TOC entry 8041 (class 2606 OID 27689301)
-- Name: mstr_stage pk_mstr_stage_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_stage
    ADD CONSTRAINT pk_mstr_stage_id PRIMARY KEY (id);


--
-- TOC entry 8050 (class 2606 OID 27689303)
-- Name: note pk_note; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note
    ADD CONSTRAINT pk_note PRIMARY KEY (id);


--
-- TOC entry 8052 (class 2606 OID 27689305)
-- Name: note_document_map pk_note_document_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note_document_map
    ADD CONSTRAINT pk_note_document_map PRIMARY KEY (id);


--
-- TOC entry 8089 (class 2606 OID 27689307)
-- Name: opportunity_activity_map pk_opportunity_activity_map_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_activity_map
    ADD CONSTRAINT pk_opportunity_activity_map_id PRIMARY KEY (id);


--
-- TOC entry 8107 (class 2606 OID 27689311)
-- Name: opportunity_challenges pk_opportunity_challenges; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_challenges
    ADD CONSTRAINT pk_opportunity_challenges PRIMARY KEY (id);


--
-- TOC entry 8112 (class 2606 OID 27689313)
-- Name: opportunity_claim_experience pk_opportunity_claim_experience; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_claim_experience
    ADD CONSTRAINT pk_opportunity_claim_experience PRIMARY KEY (id);


--
-- TOC entry 8116 (class 2606 OID 27689315)
-- Name: opportunity_competitor pk_opportunity_competitor; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_competitor
    ADD CONSTRAINT pk_opportunity_competitor PRIMARY KEY (id);


--
-- TOC entry 8122 (class 2606 OID 27689317)
-- Name: opportunity_cover_map pk_opportunity_cover_map_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_cover_map
    ADD CONSTRAINT pk_opportunity_cover_map_id PRIMARY KEY (id);


--
-- TOC entry 8159 (class 2606 OID 27689319)
-- Name: opportunity_held_cover_note_insurer_map pk_opportunity_held_cover_note_insurer_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_insurer_map
    ADD CONSTRAINT pk_opportunity_held_cover_note_insurer_map PRIMARY KEY (id);


--
-- TOC entry 8171 (class 2606 OID 27689321)
-- Name: opportunity_meeting_document_map pk_opportunity_meeting_document_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_meeting_document_map
    ADD CONSTRAINT pk_opportunity_meeting_document_map PRIMARY KEY (id);


--
-- TOC entry 8204 (class 2606 OID 27689323)
-- Name: opportunity_policy_confirmation_insurer_map pk_opportunity_policy_confirmation_insurer_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_insurer_map
    ADD CONSTRAINT pk_opportunity_policy_confirmation_insurer_map PRIMARY KEY (id);


--
-- TOC entry 8218 (class 2606 OID 27689325)
-- Name: opportunity_policy_hard_copy_insurer_map pk_opportunity_policy_hard_copy_insurer_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_insurer_map
    ADD CONSTRAINT pk_opportunity_policy_hard_copy_insurer_map PRIMARY KEY (id);


--
-- TOC entry 8299 (class 2606 OID 27689327)
-- Name: opportunity_risk_location_map pk_opportunity_risk_location_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_risk_location_map
    ADD CONSTRAINT pk_opportunity_risk_location_map PRIMARY KEY (id);


--
-- TOC entry 8082 (class 2606 OID 27689329)
-- Name: opportunity pk_oppurtunity; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity
    ADD CONSTRAINT pk_oppurtunity PRIMARY KEY (id);


--
-- TOC entry 7892 (class 2606 OID 27689331)
-- Name: org_department pk_org_department_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_department
    ADD CONSTRAINT pk_org_department_id PRIMARY KEY (id);


--
-- TOC entry 7896 (class 2606 OID 27689333)
-- Name: org_designation pk_org_designation_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_designation
    ADD CONSTRAINT pk_org_designation_id PRIMARY KEY (id);


--
-- TOC entry 8314 (class 2606 OID 27689335)
-- Name: organisation pk_organisation_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.organisation
    ADD CONSTRAINT pk_organisation_id PRIMARY KEY (id);


--
-- TOC entry 8358 (class 2606 OID 27689337)
-- Name: policy_configuration pk_policy_configuration; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration
    ADD CONSTRAINT pk_policy_configuration PRIMARY KEY (id);


--
-- TOC entry 8377 (class 2606 OID 27689339)
-- Name: policy_endorsement_template_doc_map pk_policy_endorsement_template_doc_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_endorsement_template_doc_map
    ADD CONSTRAINT pk_policy_endorsement_template_doc_map PRIMARY KEY (id);


--
-- TOC entry 8389 (class 2606 OID 27689341)
-- Name: policy_enrollment_template_doc_map pk_policy_enrollment_template_doc_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_template_doc_map
    ADD CONSTRAINT pk_policy_enrollment_template_doc_map PRIMARY KEY (id);


--
-- TOC entry 8414 (class 2606 OID 27689343)
-- Name: policy_risk_location_map pk_policy_risk_location_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_risk_location_map
    ADD CONSTRAINT pk_policy_risk_location_map PRIMARY KEY (id);


--
-- TOC entry 8365 (class 2606 OID 27689345)
-- Name: policy_configuration_template_doc_map pk_policy_template_doc_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_template_doc_map
    ADD CONSTRAINT pk_policy_template_doc_map PRIMARY KEY (id);


--
-- TOC entry 8433 (class 2606 OID 27689347)
-- Name: professional_experience pk_professional_experience_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.professional_experience
    ADD CONSTRAINT pk_professional_experience_id PRIMARY KEY (id);


--
-- TOC entry 8439 (class 2606 OID 27689349)
-- Name: qualification_experience pk_qualification_experience_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.qualification_experience
    ADD CONSTRAINT pk_qualification_experience_id PRIMARY KEY (id);


--
-- TOC entry 8442 (class 2606 OID 27689351)
-- Name: region pk_region_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.region
    ADD CONSTRAINT pk_region_id PRIMARY KEY (id);


--
-- TOC entry 8445 (class 2606 OID 27689353)
-- Name: role_acl_category_action_map pk_role_acl_category_action_map_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.role_acl_category_action_map
    ADD CONSTRAINT pk_role_acl_category_action_map_id PRIMARY KEY (id);


--
-- TOC entry 8448 (class 2606 OID 27689355)
-- Name: roles pk_roles_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT pk_roles_id PRIMARY KEY (id);


--
-- TOC entry 8458 (class 2606 OID 27689357)
-- Name: state pk_state_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state
    ADD CONSTRAINT pk_state_id PRIMARY KEY (id);


--
-- TOC entry 8463 (class 2606 OID 27689359)
-- Name: task pk_task; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task
    ADD CONSTRAINT pk_task PRIMARY KEY (id);


--
-- TOC entry 8465 (class 2606 OID 27689361)
-- Name: task_document_map pk_task_document_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task_document_map
    ADD CONSTRAINT pk_task_document_map PRIMARY KEY (id);


--
-- TOC entry 8469 (class 2606 OID 27689363)
-- Name: tpa_address pk_tpa_address_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_address
    ADD CONSTRAINT pk_tpa_address_id PRIMARY KEY (id);


--
-- TOC entry 8467 (class 2606 OID 27689365)
-- Name: tpa pk_tpa_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa
    ADD CONSTRAINT pk_tpa_id PRIMARY KEY (id);


--
-- TOC entry 8474 (class 2606 OID 27689367)
-- Name: user_role pk_user_role_id; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.user_role
    ADD CONSTRAINT pk_user_role_id PRIMARY KEY (id);


--
-- TOC entry 8339 (class 2606 OID 27689369)
-- Name: policy_asset_endorsement_map policy_asset_endorsement_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_asset_endorsement_map
    ADD CONSTRAINT policy_asset_endorsement_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8337 (class 2606 OID 27689371)
-- Name: policy_asset_endorsement policy_asset_endorsement_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_asset_endorsement
    ADD CONSTRAINT policy_asset_endorsement_pkey PRIMARY KEY (id);


--
-- TOC entry 8335 (class 2606 OID 27689373)
-- Name: policy_asset policy_asset_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_asset
    ADD CONSTRAINT policy_asset_pkey PRIMARY KEY (id);


--
-- TOC entry 8346 (class 2606 OID 27689375)
-- Name: policy_audit_log policy_audit_log_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_audit_log
    ADD CONSTRAINT policy_audit_log_pkey PRIMARY KEY (id);


--
-- TOC entry 8348 (class 2606 OID 27689377)
-- Name: policy_cd_number_map policy_cd_number_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_cd_number_map
    ADD CONSTRAINT policy_cd_number_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8351 (class 2606 OID 27689379)
-- Name: policy_claim policy_claim_claim_number_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim
    ADD CONSTRAINT policy_claim_claim_number_key UNIQUE (claim_number);


--
-- TOC entry 8353 (class 2606 OID 27689381)
-- Name: policy_claim policy_claim_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim
    ADD CONSTRAINT policy_claim_pkey PRIMARY KEY (id);


--
-- TOC entry 8356 (class 2606 OID 27689383)
-- Name: policy_claim_settlement policy_claim_settlement_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim_settlement
    ADD CONSTRAINT policy_claim_settlement_pkey PRIMARY KEY (id);


--
-- TOC entry 8361 (class 2606 OID 27689385)
-- Name: policy_configuration_component_relation_map policy_configuration_component_relation_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_component_relation_map
    ADD CONSTRAINT policy_configuration_component_relation_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8363 (class 2606 OID 27689387)
-- Name: policy_configuration_components_detail policy_configuration_components_detail_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_components_detail
    ADD CONSTRAINT policy_configuration_components_detail_pkey PRIMARY KEY (id);


--
-- TOC entry 8200 (class 2606 OID 27689389)
-- Name: opportunity_policy_confirmation_document_map policy_confirmation_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_document_map
    ADD CONSTRAINT policy_confirmation_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8367 (class 2606 OID 27689391)
-- Name: policy_cover_map policy_cover_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_cover_map
    ADD CONSTRAINT policy_cover_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8208 (class 2606 OID 27689393)
-- Name: opportunity_policy_docket_document_map policy_docket_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket_document_map
    ADD CONSTRAINT policy_docket_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8370 (class 2606 OID 27689395)
-- Name: policy_employee_enrollment_choice policy_employee_components_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_enrollment_choice
    ADD CONSTRAINT policy_employee_components_pkey PRIMARY KEY (id);


--
-- TOC entry 8372 (class 2606 OID 27689397)
-- Name: policy_employee_endorsement policy_employee_endorsement_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_endorsement
    ADD CONSTRAINT policy_employee_endorsement_pkey PRIMARY KEY (id);


--
-- TOC entry 8375 (class 2606 OID 27689399)
-- Name: policy_employee_enrollment policy_employee_enrollment_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_enrollment
    ADD CONSTRAINT policy_employee_enrollment_pkey PRIMARY KEY (id);


--
-- TOC entry 8380 (class 2606 OID 27689401)
-- Name: policy_enrollment_dependent policy_enrollment_dependent_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_dependent
    ADD CONSTRAINT policy_enrollment_dependent_pkey PRIMARY KEY (id);


--
-- TOC entry 8382 (class 2606 OID 27689403)
-- Name: policy_enrollment_employee policy_enrollment_employee_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee
    ADD CONSTRAINT policy_enrollment_employee_pkey PRIMARY KEY (id);


--
-- TOC entry 8385 (class 2606 OID 27689405)
-- Name: policy_enrollment_employee_policy_map policy_enrollment_employee_policy_map_employee_id_policy_id_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee_policy_map
    ADD CONSTRAINT policy_enrollment_employee_policy_map_employee_id_policy_id_key UNIQUE (employee_id, policy_id);


--
-- TOC entry 8387 (class 2606 OID 27689407)
-- Name: policy_enrollment_employee_policy_map policy_enrollment_employee_policy_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee_policy_map
    ADD CONSTRAINT policy_enrollment_employee_policy_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8391 (class 2606 OID 27689409)
-- Name: policy_enrollment_upload_summary policy_enrollment_upload_summary_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_upload_summary
    ADD CONSTRAINT policy_enrollment_upload_summary_pkey PRIMARY KEY (id);


--
-- TOC entry 8394 (class 2606 OID 27689411)
-- Name: policy_faq_uploads policy_faq_uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_faq_uploads
    ADD CONSTRAINT policy_faq_uploads_pkey PRIMARY KEY (id);


--
-- TOC entry 8399 (class 2606 OID 27689413)
-- Name: policy_faqs policy_faqs_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_faqs
    ADD CONSTRAINT policy_faqs_pkey PRIMARY KEY (id);


--
-- TOC entry 8406 (class 2606 OID 27689415)
-- Name: policy_feature_document_map policy_feature_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_feature_document_map
    ADD CONSTRAINT policy_feature_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8214 (class 2606 OID 27689417)
-- Name: opportunity_policy_hard_copy_document_map policy_hard_copy_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_document_map
    ADD CONSTRAINT policy_hard_copy_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8408 (class 2606 OID 27689419)
-- Name: policy_insurer_map policy_insurer_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_insurer_map
    ADD CONSTRAINT policy_insurer_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8410 (class 2606 OID 27689421)
-- Name: policy_participant_map policy_participant_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_participant_map
    ADD CONSTRAINT policy_participant_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8333 (class 2606 OID 27689423)
-- Name: policy policy_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy
    ADD CONSTRAINT policy_pkey PRIMARY KEY (id);


--
-- TOC entry 8412 (class 2606 OID 27689425)
-- Name: policy_premium_installment_schedules policy_premium_installment_schedules_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_premium_installment_schedules
    ADD CONSTRAINT policy_premium_installment_schedules_pkey PRIMARY KEY (id);


--
-- TOC entry 8418 (class 2606 OID 27689427)
-- Name: policy_sub_asset_endorsement_map policy_sub_asset_endorsement_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_sub_asset_endorsement_map
    ADD CONSTRAINT policy_sub_asset_endorsement_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8416 (class 2606 OID 27689429)
-- Name: policy_sub_asset policy_sub_asset_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_sub_asset
    ADD CONSTRAINT policy_sub_asset_pkey PRIMARY KEY (id);


--
-- TOC entry 8420 (class 2606 OID 27689431)
-- Name: policy_tpa_map policy_tpa_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_tpa_map
    ADD CONSTRAINT policy_tpa_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8422 (class 2606 OID 27689433)
-- Name: policy_type_segregation policy_type_segregation_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_segregation
    ADD CONSTRAINT policy_type_segregation_pkey PRIMARY KEY (id);


--
-- TOC entry 8222 (class 2606 OID 27689435)
-- Name: opportunity_premium_calculation_document_map premium_calculation_document_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation_document_map
    ADD CONSTRAINT premium_calculation_document_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8450 (class 2606 OID 27689437)
-- Name: roles roles_name_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_name_key UNIQUE (name);


--
-- TOC entry 8452 (class 2606 OID 27689439)
-- Name: service_tat_score_map service_tat_score_map_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.service_tat_score_map
    ADD CONSTRAINT service_tat_score_map_pkey PRIMARY KEY (id);


--
-- TOC entry 8471 (class 2606 OID 27689441)
-- Name: tpa_contact tpa_contact_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_contact
    ADD CONSTRAINT tpa_contact_pkey PRIMARY KEY (id);


--
-- TOC entry 8035 (class 2606 OID 27689443)
-- Name: mstr_policy_hospital_map uk_policy_hospital_map; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_hospital_map
    ADD CONSTRAINT uk_policy_hospital_map UNIQUE (policy_id, hospital_id);


--
-- TOC entry 8322 (class 2606 OID 27689445)
-- Name: performance_output uniq_user_entity_month; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.performance_output
    ADD CONSTRAINT uniq_user_entity_month UNIQUE (user_id, entity_type, performance_month);


--
-- TOC entry 7847 (class 2606 OID 27689447)
-- Name: state_gst_detail unique_gst_number; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state_gst_detail
    ADD CONSTRAINT unique_gst_number UNIQUE (gst_number);


--
-- TOC entry 8120 (class 2606 OID 27689449)
-- Name: opportunity_contact_map unique_opportunity_contact; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_contact_map
    ADD CONSTRAINT unique_opportunity_contact UNIQUE (opportunity_id, contact_id);


--
-- TOC entry 7816 (class 2606 OID 27689451)
-- Name: company unique_pan_card_number; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company
    ADD CONSTRAINT unique_pan_card_number UNIQUE (pan_card_number);


--
-- TOC entry 7818 (class 2606 OID 27689453)
-- Name: company unique_tan_number; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company
    ADD CONSTRAINT unique_tan_number UNIQUE (tan_number);


--
-- TOC entry 7828 (class 2606 OID 27689455)
-- Name: company_authentication_map uq_company_auth_method; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_authentication_map
    ADD CONSTRAINT uq_company_auth_method UNIQUE (company_id, authentication_method_id);


--
-- TOC entry 8228 (class 2606 OID 27689457)
-- Name: opportunity_previous_mediator_details uq_company_opportunity_mediator_type; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_mediator_details
    ADD CONSTRAINT uq_company_opportunity_mediator_type UNIQUE (company_id, opportunity_id, mediator_type);


--
-- TOC entry 7937 (class 2606 OID 27689459)
-- Name: opportunity_held_cover_note_document_map uq_held_cover_note_document; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_document_map
    ADD CONSTRAINT uq_held_cover_note_document UNIQUE (held_cover_note_id, document_id);


--
-- TOC entry 7955 (class 2606 OID 27689461)
-- Name: knowledge_central uq_kc_doc_version; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.knowledge_central
    ADD CONSTRAINT uq_kc_doc_version UNIQUE (document_id, version);


--
-- TOC entry 8026 (class 2606 OID 27689463)
-- Name: mstr_org_service_weightage uq_mstr_org_service_weightage_org_service; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_org_service_weightage
    ADD CONSTRAINT uq_mstr_org_service_weightage_org_service UNIQUE (org_id, service_id);


--
-- TOC entry 8048 (class 2606 OID 27689465)
-- Name: mstr_tat_bucket uq_mstr_tat_bucket_org_label; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_tat_bucket
    ADD CONSTRAINT uq_mstr_tat_bucket_org_label UNIQUE (org_id, tat_label);


--
-- TOC entry 8308 (class 2606 OID 27689467)
-- Name: org_service_tat_summary uq_org_service_tat_summary_unique_snapshot; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_service_tat_summary
    ADD CONSTRAINT uq_org_service_tat_summary_unique_snapshot UNIQUE (org_id, company_id, policy_id, service_id, tat_bucket_id, snapshot_date);


--
-- TOC entry 8202 (class 2606 OID 27689469)
-- Name: opportunity_policy_confirmation_document_map uq_policy_confirmation_document; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_document_map
    ADD CONSTRAINT uq_policy_confirmation_document UNIQUE (policy_confirmation_id, document_id);


--
-- TOC entry 8210 (class 2606 OID 27689471)
-- Name: opportunity_policy_docket_document_map uq_policy_docket_document; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket_document_map
    ADD CONSTRAINT uq_policy_docket_document UNIQUE (policy_docket_id, document_id);


--
-- TOC entry 8216 (class 2606 OID 27689473)
-- Name: opportunity_policy_hard_copy_document_map uq_policy_hard_copy_document; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_document_map
    ADD CONSTRAINT uq_policy_hard_copy_document UNIQUE (policy_hard_copy_id, document_id);


--
-- TOC entry 8424 (class 2606 OID 27689475)
-- Name: policy_type_segregation uq_policy_type_segregation_policy_type; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_segregation
    ADD CONSTRAINT uq_policy_type_segregation_policy_type UNIQUE (policy_type_lid);


--
-- TOC entry 8454 (class 2606 OID 27689477)
-- Name: service_tat_score_map uq_service_tat_score_map_service_bucket; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.service_tat_score_map
    ADD CONSTRAINT uq_service_tat_score_map_service_bucket UNIQUE (service_id, tat_bucket_id);


--
-- TOC entry 8477 (class 2606 OID 27689479)
-- Name: users users_email_id_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_email_id_key UNIQUE (email_id);


--
-- TOC entry 8479 (class 2606 OID 27689481)
-- Name: users users_login_name_key; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_login_name_key UNIQUE (login_name);


--
-- TOC entry 8481 (class 2606 OID 27689483)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- TOC entry 8484 (class 2606 OID 27689485)
-- Name: zz_load_policy_delete_available_in_prod_20251201 zz_load_policy_delete_available_in_prod_20251201_pkey; Type: CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.zz_load_policy_delete_available_in_prod_20251201
    ADD CONSTRAINT zz_load_policy_delete_available_in_prod_20251201_pkey PRIMARY KEY (policy_id_tobe_deleted);


--
-- TOC entry 7681 (class 1259 OID 27689486)
-- Name: idx_acl_category_action_map_category_action; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_acl_category_action_map_category_action ON public.acl_category_action_map USING btree (acl_category_id, acl_action_id);


--
-- TOC entry 7671 (class 1259 OID 27689487)
-- Name: idx_actions_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_actions_name ON public.acl_actions USING btree (name);


--
-- TOC entry 7684 (class 1259 OID 27689488)
-- Name: idx_address_city_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_address_city_id ON public.address USING btree (city_id);


--
-- TOC entry 7685 (class 1259 OID 27689489)
-- Name: idx_address_country_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_address_country_id ON public.address USING btree (country_id);


--
-- TOC entry 7686 (class 1259 OID 27689490)
-- Name: idx_address_pincode; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_address_pincode ON public.address USING btree (pincode);


--
-- TOC entry 7687 (class 1259 OID 27689491)
-- Name: idx_address_state_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_address_state_id ON public.address USING btree (state_id);


--
-- TOC entry 7708 (class 1259 OID 27689492)
-- Name: idx_audit_log_created; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_audit_log_created ON public.audit_history_log USING btree (created_at);


--
-- TOC entry 7713 (class 1259 OID 27689493)
-- Name: idx_audit_log_detail_audit_log; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_audit_log_detail_audit_log ON public.audit_history_log_detail USING btree (audit_log_id);


--
-- TOC entry 7709 (class 1259 OID 27689497)
-- Name: idx_audit_log_entity; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_audit_log_entity ON public.audit_history_log USING btree (entity_type, entity_id);


--
-- TOC entry 7710 (class 1259 OID 27689498)
-- Name: idx_audit_log_user; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_audit_log_user ON public.audit_history_log USING btree (user_id);


--
-- TOC entry 7725 (class 1259 OID 27689499)
-- Name: idx_broker_address_address_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_broker_address_address_id ON public.broker_address USING btree (address_id);


--
-- TOC entry 7726 (class 1259 OID 27689500)
-- Name: idx_broker_address_broker_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_broker_address_broker_id ON public.broker_address USING btree (broker_id);


--
-- TOC entry 7718 (class 1259 OID 27689501)
-- Name: idx_broker_company_type_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_broker_company_type_id ON public.broker USING btree (company_type_lid);


--
-- TOC entry 7719 (class 1259 OID 27689502)
-- Name: idx_broker_created_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_broker_created_by ON public.broker USING btree (created_by);


--
-- TOC entry 7720 (class 1259 OID 27689503)
-- Name: idx_broker_display_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_broker_display_name ON public.broker USING btree (display_name);


--
-- TOC entry 7721 (class 1259 OID 27689504)
-- Name: idx_broker_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_broker_name ON public.broker USING btree (broker_name);


--
-- TOC entry 7722 (class 1259 OID 27689505)
-- Name: idx_broker_updated_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_broker_updated_by ON public.broker USING btree (updated_by);


--
-- TOC entry 7737 (class 1259 OID 27689506)
-- Name: idx_business_target_entity_type; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_business_target_entity_type ON public.business_target USING btree (entity_type);


--
-- TOC entry 7738 (class 1259 OID 27689507)
-- Name: idx_business_target_month; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_business_target_month ON public.business_target USING btree (month);


--
-- TOC entry 7676 (class 1259 OID 27689508)
-- Name: idx_categories_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_categories_name ON public.acl_categories USING btree (name);


--
-- TOC entry 7745 (class 1259 OID 27689509)
-- Name: idx_child_details_child_dob; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_child_details_child_dob ON public.child_details USING btree (child_dob);


--
-- TOC entry 7746 (class 1259 OID 27689510)
-- Name: idx_child_details_contact_details_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_child_details_contact_details_id ON public.child_details USING btree (contact_details_id);


--
-- TOC entry 7747 (class 1259 OID 27689511)
-- Name: idx_child_details_deleted_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_child_details_deleted_at ON public.child_details USING btree (deleted_at);


--
-- TOC entry 7750 (class 1259 OID 27689512)
-- Name: idx_city_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_city_name ON public.city USING btree (name);


--
-- TOC entry 7751 (class 1259 OID 27689513)
-- Name: idx_city_state_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_city_state_id ON public.city USING btree (state_id);


--
-- TOC entry 7756 (class 1259 OID 27689514)
-- Name: idx_claim_activity_document_map_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_activity_document_map_activity_id ON public.claim_activity_document_map USING btree (claim_activity_id);


--
-- TOC entry 7761 (class 1259 OID 27689515)
-- Name: idx_claim_activity_map_activity_order; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_activity_map_activity_order ON public.claim_activity_map USING btree (activity_order);


--
-- TOC entry 7762 (class 1259 OID 27689516)
-- Name: idx_claim_activity_map_claim_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_activity_map_claim_id ON public.claim_activity_map USING btree (claim_id);


--
-- TOC entry 7763 (class 1259 OID 27689517)
-- Name: idx_claim_activity_map_claim_number; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_activity_map_claim_number ON public.claim_activity_map USING btree (claim_number);


--
-- TOC entry 7764 (class 1259 OID 27689518)
-- Name: idx_claim_activity_map_policy_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_activity_map_policy_id ON public.claim_activity_map USING btree (policy_id);


--
-- TOC entry 7767 (class 1259 OID 27689519)
-- Name: idx_claim_assessment_report_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_assessment_report_activity_id ON public.claim_assessment_report USING btree (claim_activity_id);


--
-- TOC entry 7770 (class 1259 OID 27689520)
-- Name: idx_claim_customer_agreement_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_customer_agreement_activity_id ON public.claim_customer_agreement USING btree (claim_activity_id);


--
-- TOC entry 7773 (class 1259 OID 27689521)
-- Name: idx_claim_discharge_voucher_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_discharge_voucher_activity_id ON public.claim_discharge_voucher USING btree (claim_activity_id);


--
-- TOC entry 7776 (class 1259 OID 27689522)
-- Name: idx_claim_document_submission_tracker_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_document_submission_tracker_activity_id ON public.claim_document_submission_tracker USING btree (claim_activity_id);


--
-- TOC entry 7779 (class 1259 OID 27689523)
-- Name: idx_claim_documents_collected_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_documents_collected_activity_id ON public.claim_documents_collected USING btree (claim_activity_id);


--
-- TOC entry 7782 (class 1259 OID 27689524)
-- Name: idx_claim_fnol_details_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_fnol_details_activity_id ON public.claim_fnol_details USING btree (claim_activity_id);


--
-- TOC entry 7785 (class 1259 OID 27689525)
-- Name: idx_claim_informed_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_informed_activity_id ON public.claim_informed USING btree (claim_activity_id);


--
-- TOC entry 7788 (class 1259 OID 27689526)
-- Name: idx_claim_joint_inspection_report_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_joint_inspection_report_activity_id ON public.claim_joint_inspection_report USING btree (claim_activity_id);


--
-- TOC entry 7791 (class 1259 OID 27689527)
-- Name: idx_claim_lor_details_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_lor_details_activity_id ON public.claim_lor_details USING btree (claim_activity_id);


--
-- TOC entry 7794 (class 1259 OID 27689528)
-- Name: idx_claim_loss_adjuster_details_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_loss_adjuster_details_activity_id ON public.claim_loss_adjuster_details USING btree (claim_activity_id);


--
-- TOC entry 7797 (class 1259 OID 27689529)
-- Name: idx_claim_payment_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_payment_activity_id ON public.claim_payment USING btree (claim_activity_id);


--
-- TOC entry 7800 (class 1259 OID 27689530)
-- Name: idx_claim_survey_completed_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_survey_completed_activity_id ON public.claim_survey_completed USING btree (claim_activity_id);


--
-- TOC entry 7803 (class 1259 OID 27689531)
-- Name: idx_claim_validation_report_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_validation_report_activity_id ON public.claim_validation_report USING btree (claim_activity_id);


--
-- TOC entry 7806 (class 1259 OID 27689532)
-- Name: idx_claim_voucher_to_insurer_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_claim_voucher_to_insurer_activity_id ON public.claim_voucher_to_insurer USING btree (claim_activity_id);


--
-- TOC entry 7825 (class 1259 OID 27689533)
-- Name: idx_company_auth_mapping_company; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_auth_mapping_company ON public.company_authentication_map USING btree (company_id);


--
-- TOC entry 7826 (class 1259 OID 27689534)
-- Name: idx_company_auth_mapping_method; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_auth_mapping_method ON public.company_authentication_map USING btree (authentication_method_id);


--
-- TOC entry 7829 (class 1259 OID 27689535)
-- Name: idx_company_contact_company_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_contact_company_id ON public.company_contact USING btree (company_id);


--
-- TOC entry 7830 (class 1259 OID 27689536)
-- Name: idx_company_contact_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_contact_contact_id ON public.company_contact USING btree (contact_id);


--
-- TOC entry 7833 (class 1259 OID 27689537)
-- Name: idx_company_contact_map_company_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_contact_map_company_id ON public.company_contact_map USING btree (company_id);


--
-- TOC entry 7834 (class 1259 OID 27689538)
-- Name: idx_company_contact_map_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_contact_map_contact_id ON public.company_contact_map USING btree (contact_id);


--
-- TOC entry 7807 (class 1259 OID 27689539)
-- Name: idx_company_created_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_created_by ON public.company USING btree (created_by);


--
-- TOC entry 7837 (class 1259 OID 27689540)
-- Name: idx_company_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_id ON public.company_detail USING btree (company_id);


--
-- TOC entry 7808 (class 1259 OID 27689541)
-- Name: idx_company_industry_segment_lid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_industry_segment_lid ON public.company USING btree (industry_segment_lid);


--
-- TOC entry 7809 (class 1259 OID 27689542)
-- Name: idx_company_lead_crm; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_lead_crm ON public.company USING btree (lead_crm);


--
-- TOC entry 7855 (class 1259 OID 27689543)
-- Name: idx_company_rule_mapping_company; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_rule_mapping_company ON public.company_rule_mapping USING btree (company_id);


--
-- TOC entry 7856 (class 1259 OID 27689544)
-- Name: idx_company_rule_mapping_rule; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_company_rule_mapping_rule ON public.company_rule_mapping USING btree (rule_id);


--
-- TOC entry 7850 (class 1259 OID 27689545)
-- Name: idx_config_company_subdomain; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_config_company_subdomain ON public.company_portal_configuration USING btree (sub_domain);


--
-- TOC entry 7863 (class 1259 OID 27689546)
-- Name: idx_contact_address_address_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_address_address_id ON public.contact_address USING btree (address_id);


--
-- TOC entry 7864 (class 1259 OID 27689547)
-- Name: idx_contact_address_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_address_contact_id ON public.contact_address USING btree (contact_id);


--
-- TOC entry 7867 (class 1259 OID 27689548)
-- Name: idx_contact_communication_details_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_communication_details_contact_id ON public.contact_communication_details USING btree (contact_id);


--
-- TOC entry 7868 (class 1259 OID 27689549)
-- Name: idx_contact_communication_details_deleted_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_communication_details_deleted_at ON public.contact_communication_details USING btree (deleted_at);


--
-- TOC entry 7869 (class 1259 OID 27689550)
-- Name: idx_contact_communication_details_type; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_communication_details_type ON public.contact_communication_details USING btree (communication_type);


--
-- TOC entry 7872 (class 1259 OID 27689551)
-- Name: idx_contact_details_child_dob; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_child_dob ON public.contact_details USING btree (child_dob);


--
-- TOC entry 7873 (class 1259 OID 27689552)
-- Name: idx_contact_details_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_contact_id ON public.contact_details USING btree (contact_id);


--
-- TOC entry 7874 (class 1259 OID 27689553)
-- Name: idx_contact_details_date_of_birth; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_date_of_birth ON public.contact_details USING btree (date_of_birth);


--
-- TOC entry 7875 (class 1259 OID 27689554)
-- Name: idx_contact_details_deleted_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_deleted_at ON public.contact_details USING btree (deleted_at);


--
-- TOC entry 7876 (class 1259 OID 27689555)
-- Name: idx_contact_details_gender; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_gender ON public.contact_details USING btree (gender);


--
-- TOC entry 7877 (class 1259 OID 27689556)
-- Name: idx_contact_details_marital_status; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_marital_status ON public.contact_details USING btree (marital_status);


--
-- TOC entry 7878 (class 1259 OID 27689557)
-- Name: idx_contact_details_spouse_date_of_birth; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_spouse_date_of_birth ON public.contact_details USING btree (spouse_date_of_birth);


--
-- TOC entry 7879 (class 1259 OID 27689558)
-- Name: idx_contact_details_spouse_working_status; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_details_spouse_working_status ON public.contact_details USING btree (spouse_working_status);


--
-- TOC entry 7859 (class 1259 OID 27689559)
-- Name: idx_contact_first_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_first_name ON public.contact USING btree (first_name);


--
-- TOC entry 7860 (class 1259 OID 27689560)
-- Name: idx_contact_last_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_contact_last_name ON public.contact USING btree (last_name);


--
-- TOC entry 7884 (class 1259 OID 27689561)
-- Name: idx_country_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_country_name ON public.country USING btree (name);


--
-- TOC entry 7885 (class 1259 OID 27689562)
-- Name: idx_country_region_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_country_region_id ON public.country USING btree (region_id);


--
-- TOC entry 7810 (class 1259 OID 27689563)
-- Name: idx_created_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_created_at ON public.company USING btree (created_at);


--
-- TOC entry 7811 (class 1259 OID 27689564)
-- Name: idx_deleted_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_deleted_at ON public.company USING btree (deleted_at);


--
-- TOC entry 7812 (class 1259 OID 27689565)
-- Name: idx_display_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_display_name ON public.company USING btree (display_name);


--
-- TOC entry 7897 (class 1259 OID 27689566)
-- Name: idx_document_doc_type_lid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_document_doc_type_lid ON public.document USING btree (doc_type_lid);


--
-- TOC entry 7898 (class 1259 OID 27689567)
-- Name: idx_document_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_document_name ON public.document USING btree (name);


--
-- TOC entry 7903 (class 1259 OID 27689568)
-- Name: idx_dpf_entity_status; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_dpf_entity_status ON public.document_processing_file USING btree (entity_type, entity_id, process_status);


--
-- TOC entry 8373 (class 1259 OID 27689569)
-- Name: idx_employee_enrollment; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_employee_enrollment ON public.policy_employee_enrollment USING btree (policy_id);


--
-- TOC entry 7911 (class 1259 OID 27689570)
-- Name: idx_employee_hierarchy_reporting_user_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_employee_hierarchy_reporting_user_id ON public.employee_hierarchy USING btree (reporting_user_id);


--
-- TOC entry 7912 (class 1259 OID 27689571)
-- Name: idx_employee_hierarchy_user_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_employee_hierarchy_user_id ON public.employee_hierarchy USING btree (user_id);


--
-- TOC entry 7906 (class 1259 OID 27689572)
-- Name: idx_employee_user_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_employee_user_id ON public.employee USING btree (user_id);


--
-- TOC entry 7915 (class 1259 OID 27689573)
-- Name: idx_endorsement_mig_ref_no_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_endorsement_mig_ref_no_id ON public.endorsement USING btree (mig_ref_no);


--
-- TOC entry 8392 (class 1259 OID 27689574)
-- Name: idx_faq_uploads_policy_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_faq_uploads_policy_id ON public.policy_faq_uploads USING btree (policy_id);


--
-- TOC entry 8395 (class 1259 OID 27689575)
-- Name: idx_faqs_category; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_faqs_category ON public.policy_faqs USING btree (category);


--
-- TOC entry 8396 (class 1259 OID 27689576)
-- Name: idx_faqs_is_active; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_faqs_is_active ON public.policy_faqs USING btree (is_active);


--
-- TOC entry 8397 (class 1259 OID 27689577)
-- Name: idx_faqs_policy_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_faqs_policy_id ON public.policy_faqs USING btree (policy_id);


--
-- TOC entry 8147 (class 1259 OID 27689578)
-- Name: idx_held_cover_note_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_activity_id ON public.opportunity_held_cover_note USING btree (activity_id);


--
-- TOC entry 8148 (class 1259 OID 27689579)
-- Name: idx_held_cover_note_created_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_created_at ON public.opportunity_held_cover_note USING btree (created_at);


--
-- TOC entry 7934 (class 1259 OID 27689580)
-- Name: idx_held_cover_note_doc_map_cover_note_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_doc_map_cover_note_id ON public.opportunity_held_cover_note_document_map USING btree (held_cover_note_id);


--
-- TOC entry 7935 (class 1259 OID 27689581)
-- Name: idx_held_cover_note_doc_map_document_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_doc_map_document_id ON public.opportunity_held_cover_note_document_map USING btree (document_id);


--
-- TOC entry 8149 (class 1259 OID 27689582)
-- Name: idx_held_cover_note_opportunity_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_opportunity_activity_id ON public.opportunity_held_cover_note USING btree (opportunity_activity_id);


--
-- TOC entry 8150 (class 1259 OID 27689583)
-- Name: idx_held_cover_note_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_opportunity_id ON public.opportunity_held_cover_note USING btree (opportunity_id);


--
-- TOC entry 8151 (class 1259 OID 27689584)
-- Name: idx_held_cover_note_placement_slip_deviations; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_placement_slip_deviations ON public.opportunity_held_cover_note USING btree (placement_slip_deviations_lid);


--
-- TOC entry 8152 (class 1259 OID 27689585)
-- Name: idx_held_cover_note_receipt_no; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_receipt_no ON public.opportunity_held_cover_note USING btree (receipt_no);


--
-- TOC entry 8153 (class 1259 OID 27689586)
-- Name: idx_held_cover_note_status_lid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_held_cover_note_status_lid ON public.opportunity_held_cover_note USING btree (status_lid);


--
-- TOC entry 7940 (class 1259 OID 27689587)
-- Name: idx_hospital_file_upload_tracking_file; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_hospital_file_upload_tracking_file ON public.hospital_file_upload_tracking USING btree (file_id);


--
-- TOC entry 7941 (class 1259 OID 27689588)
-- Name: idx_hospital_file_upload_tracking_policy; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_hospital_file_upload_tracking_policy ON public.hospital_file_upload_tracking USING btree (policy_id);


--
-- TOC entry 7942 (class 1259 OID 27689589)
-- Name: idx_hospital_file_upload_tracking_status; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_hospital_file_upload_tracking_status ON public.hospital_file_upload_tracking USING btree (file_status);


--
-- TOC entry 7951 (class 1259 OID 27689590)
-- Name: idx_kc_doc_status; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_kc_doc_status ON public.knowledge_central USING btree (document_id, status_id);


--
-- TOC entry 7966 (class 1259 OID 27689591)
-- Name: idx_lookup_key; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_lookup_key ON public.lookup_data USING btree (lookup_key);


--
-- TOC entry 7967 (class 1259 OID 27689592)
-- Name: idx_lookup_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_lookup_name ON public.lookup_data USING btree (lookup_name);


--
-- TOC entry 7973 (class 1259 OID 27689593)
-- Name: idx_meeting_challenges_map_challenge_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_meeting_challenges_map_challenge_id ON public.meeting_challenges_map USING btree (challenge_id);


--
-- TOC entry 7974 (class 1259 OID 27689594)
-- Name: idx_meeting_challenges_map_meeting_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_meeting_challenges_map_meeting_id ON public.meeting_challenges_map USING btree (meeting_id);


--
-- TOC entry 7979 (class 1259 OID 27689595)
-- Name: idx_meeting_next_steps_map_meeting_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_meeting_next_steps_map_meeting_id ON public.meeting_next_steps_map USING btree (meeting_id);


--
-- TOC entry 7980 (class 1259 OID 27689596)
-- Name: idx_meeting_next_steps_map_next_step_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_meeting_next_steps_map_next_step_id ON public.meeting_next_steps_map USING btree (next_step_id);


--
-- TOC entry 7983 (class 1259 OID 27689597)
-- Name: idx_meeting_outcomes_map_meeting_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_meeting_outcomes_map_meeting_id ON public.meeting_outcomes_map USING btree (meeting_id);


--
-- TOC entry 7984 (class 1259 OID 27689598)
-- Name: idx_meeting_outcomes_map_outcome_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_meeting_outcomes_map_outcome_id ON public.meeting_outcomes_map USING btree (outcome_id);


--
-- TOC entry 8008 (class 1259 OID 27689599)
-- Name: idx_mstr_hospital_address_city_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_hospital_address_city_name ON public.mstr_hospital_address USING btree (city_name);


--
-- TOC entry 8003 (class 1259 OID 27689600)
-- Name: idx_mstr_hospital_address_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_hospital_address_id ON public.mstr_hospital USING btree (address_id);


--
-- TOC entry 8009 (class 1259 OID 27689601)
-- Name: idx_mstr_hospital_address_pincode; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_hospital_address_pincode ON public.mstr_hospital_address USING btree (pin_code);


--
-- TOC entry 8010 (class 1259 OID 27689602)
-- Name: idx_mstr_hospital_address_state_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_hospital_address_state_name ON public.mstr_hospital_address USING btree (state_name);


--
-- TOC entry 8004 (class 1259 OID 27689603)
-- Name: idx_mstr_hospital_code; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_hospital_code ON public.mstr_hospital USING btree (code);


--
-- TOC entry 8005 (class 1259 OID 27689604)
-- Name: idx_mstr_hospital_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_hospital_name ON public.mstr_hospital USING btree (name);


--
-- TOC entry 8029 (class 1259 OID 27689605)
-- Name: idx_mstr_policy_hospital_map_hospital; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_policy_hospital_map_hospital ON public.mstr_policy_hospital_map USING btree (hospital_id);


--
-- TOC entry 8030 (class 1259 OID 27689606)
-- Name: idx_mstr_policy_hospital_map_network; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_policy_hospital_map_network ON public.mstr_policy_hospital_map USING btree (is_network_hospital);


--
-- TOC entry 8031 (class 1259 OID 27689607)
-- Name: idx_mstr_policy_hospital_map_policy; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_policy_hospital_map_policy ON public.mstr_policy_hospital_map USING btree (policy_id);


--
-- TOC entry 8044 (class 1259 OID 27689608)
-- Name: idx_mstr_tat_bucket_org_display_order; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_mstr_tat_bucket_org_display_order ON public.mstr_tat_bucket USING btree (org_id, tat_display_order);


--
-- TOC entry 8104 (class 1259 OID 27689609)
-- Name: idx_opp_challenges_challenge_type; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_challenges_challenge_type ON public.opportunity_challenges USING btree (challenge_type_lid);


--
-- TOC entry 8105 (class 1259 OID 27689610)
-- Name: idx_opp_challenges_opp_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_challenges_opp_id ON public.opportunity_challenges USING btree (opportunity_id);


--
-- TOC entry 8108 (class 1259 OID 27689611)
-- Name: idx_opp_claim_exp_opp_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_claim_exp_opp_id ON public.opportunity_claim_experience USING btree (opportunity_id);


--
-- TOC entry 8109 (class 1259 OID 27689612)
-- Name: idx_opp_claim_exp_policy_from; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_claim_exp_policy_from ON public.opportunity_claim_experience USING btree (policy_from);


--
-- TOC entry 8110 (class 1259 OID 27689613)
-- Name: idx_opp_claim_exp_policy_to; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_claim_exp_policy_to ON public.opportunity_claim_experience USING btree (policy_to);


--
-- TOC entry 8113 (class 1259 OID 27689614)
-- Name: idx_opp_competitor_competitor_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_competitor_competitor_id ON public.opportunity_competitor USING btree (competitor_id);


--
-- TOC entry 8114 (class 1259 OID 27689615)
-- Name: idx_opp_competitor_opp_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_competitor_opp_id ON public.opportunity_competitor USING btree (opportunity_id);


--
-- TOC entry 8296 (class 1259 OID 27689616)
-- Name: idx_opp_risk_loc_addr_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_risk_loc_addr_id ON public.opportunity_risk_location_map USING btree (address_id);


--
-- TOC entry 8297 (class 1259 OID 27689617)
-- Name: idx_opp_risk_loc_opp_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opp_risk_loc_opp_id ON public.opportunity_risk_location_map USING btree (opportunity_id);


--
-- TOC entry 8083 (class 1259 OID 27689618)
-- Name: idx_opportunity_activity_map_activity_key; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_map_activity_key ON public.opportunity_activity_map USING btree (activity_key);


--
-- TOC entry 8084 (class 1259 OID 27689624)
-- Name: idx_opportunity_activity_map_created_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_map_created_by ON public.opportunity_activity_map USING btree (created_by);


--
-- TOC entry 8085 (class 1259 OID 27689625)
-- Name: idx_opportunity_activity_map_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_map_opportunity_id ON public.opportunity_activity_map USING btree (opportunity_id);


--
-- TOC entry 8086 (class 1259 OID 27689626)
-- Name: idx_opportunity_activity_map_owner_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_map_owner_id ON public.opportunity_activity_map USING btree (owner_id);


--
-- TOC entry 8087 (class 1259 OID 27689647)
-- Name: idx_opportunity_activity_map_status_lid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_map_status_lid ON public.opportunity_activity_map USING btree (status_lid);


--
-- TOC entry 8090 (class 1259 OID 27689655)
-- Name: idx_opportunity_activity_participants_created_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_participants_created_by ON public.opportunity_activity_participants USING btree (created_by);


--
-- TOC entry 8091 (class 1259 OID 27689656)
-- Name: idx_opportunity_activity_participants_opportunity_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_participants_opportunity_activity_id ON public.opportunity_activity_participants USING btree (opportunity_activity_id);


--
-- TOC entry 8092 (class 1259 OID 27689657)
-- Name: idx_opportunity_activity_participants_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_participants_opportunity_id ON public.opportunity_activity_participants USING btree (opportunity_id);


--
-- TOC entry 8093 (class 1259 OID 27689658)
-- Name: idx_opportunity_activity_participants_participant_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_activity_participants_participant_id ON public.opportunity_activity_participants USING btree (participant_id);


--
-- TOC entry 8075 (class 1259 OID 27689659)
-- Name: idx_opportunity_created_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_created_by ON public.opportunity USING btree (created_by);


--
-- TOC entry 8076 (class 1259 OID 27689661)
-- Name: idx_opportunity_owner_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_owner_id ON public.opportunity USING btree (owner_id);


--
-- TOC entry 8190 (class 1259 OID 27689662)
-- Name: idx_opportunity_policy_confirmation_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_policy_confirmation_activity_id ON public.opportunity_policy_confirmation USING btree (activity_id);


--
-- TOC entry 8191 (class 1259 OID 27689663)
-- Name: idx_opportunity_policy_confirmation_created_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_policy_confirmation_created_at ON public.opportunity_policy_confirmation USING btree (created_at);


--
-- TOC entry 8192 (class 1259 OID 27689664)
-- Name: idx_opportunity_policy_confirmation_opportunity_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_policy_confirmation_opportunity_activity_id ON public.opportunity_policy_confirmation USING btree (opportunity_activity_id);


--
-- TOC entry 8193 (class 1259 OID 27689665)
-- Name: idx_opportunity_policy_confirmation_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_policy_confirmation_opportunity_id ON public.opportunity_policy_confirmation USING btree (opportunity_id);


--
-- TOC entry 8194 (class 1259 OID 27689666)
-- Name: idx_opportunity_policy_confirmation_status_lid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_policy_confirmation_status_lid ON public.opportunity_policy_confirmation USING btree (status_lid);


--
-- TOC entry 8077 (class 1259 OID 27689667)
-- Name: idx_opportunity_policy_type_lid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_policy_type_lid ON public.opportunity USING btree (policy_type_lid);


--
-- TOC entry 8078 (class 1259 OID 27689668)
-- Name: idx_opportunity_refpolicy; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_refpolicy ON public.opportunity USING btree (ref_policy_id);


--
-- TOC entry 8247 (class 1259 OID 27689669)
-- Name: idx_opportunity_rfp_activity_document_map_document_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_activity_document_map_document_id ON public.opportunity_rfp_activity_document_map USING btree (document_id);


--
-- TOC entry 8248 (class 1259 OID 27689670)
-- Name: idx_opportunity_rfp_activity_document_map_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_activity_document_map_id ON public.opportunity_rfp_activity_document_map USING btree (id);


--
-- TOC entry 8249 (class 1259 OID 27689671)
-- Name: idx_opportunity_rfp_activity_document_map_opportunity_activity_; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_activity_document_map_opportunity_activity_ ON public.opportunity_rfp_activity_document_map USING btree (opportunity_activity_map_id);


--
-- TOC entry 8250 (class 1259 OID 27689672)
-- Name: idx_opportunity_rfp_activity_document_map_rfp_detail_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_activity_document_map_rfp_detail_id ON public.opportunity_rfp_activity_document_map USING btree (rfp_detail_id);


--
-- TOC entry 8253 (class 1259 OID 27689673)
-- Name: idx_opportunity_rfp_client_contact_detail_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_client_contact_detail_contact_id ON public.opportunity_rfp_client_contact_detail USING btree (contact_id);


--
-- TOC entry 8254 (class 1259 OID 27689674)
-- Name: idx_opportunity_rfp_client_contact_detail_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_client_contact_detail_id ON public.opportunity_rfp_client_contact_detail USING btree (id);


--
-- TOC entry 8255 (class 1259 OID 27689675)
-- Name: idx_opportunity_rfp_client_contact_detail_opportunity_rfp_detai; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_client_contact_detail_opportunity_rfp_detai ON public.opportunity_rfp_client_contact_detail USING btree (opportunity_rfp_details_entry_id);


--
-- TOC entry 8258 (class 1259 OID 27689676)
-- Name: idx_opportunity_rfp_client_contact_influencers_client_contact_i; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_client_contact_influencers_client_contact_i ON public.opportunity_rfp_client_contact_influencers USING btree (client_contact_id);


--
-- TOC entry 8259 (class 1259 OID 27689677)
-- Name: idx_opportunity_rfp_client_contact_influencers_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_client_contact_influencers_id ON public.opportunity_rfp_client_contact_influencers USING btree (id);


--
-- TOC entry 8260 (class 1259 OID 27689678)
-- Name: idx_opportunity_rfp_client_contact_influencers_influencer_conta; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_client_contact_influencers_influencer_conta ON public.opportunity_rfp_client_contact_influencers USING btree (influencer_contact_id);


--
-- TOC entry 8263 (class 1259 OID 27689679)
-- Name: idx_opportunity_rfp_cover_detail_cover_map_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_cover_detail_cover_map_id ON public.opportunity_rfp_cover_detail USING btree (cover_map_id);


--
-- TOC entry 8264 (class 1259 OID 27689680)
-- Name: idx_opportunity_rfp_cover_detail_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_cover_detail_id ON public.opportunity_rfp_cover_detail USING btree (id);


--
-- TOC entry 8265 (class 1259 OID 27689681)
-- Name: idx_opportunity_rfp_cover_detail_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_cover_detail_opportunity_id ON public.opportunity_rfp_cover_detail USING btree (opportunity_id);


--
-- TOC entry 8266 (class 1259 OID 27689682)
-- Name: idx_opportunity_rfp_cover_detail_policy_type_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_cover_detail_policy_type_id ON public.opportunity_rfp_cover_detail USING btree (policy_type_id);


--
-- TOC entry 8269 (class 1259 OID 27689683)
-- Name: idx_opportunity_rfp_credit_sharing_executive_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_credit_sharing_executive_id ON public.opportunity_rfp_credit_sharing USING btree (executive_id);


--
-- TOC entry 8270 (class 1259 OID 27689684)
-- Name: idx_opportunity_rfp_credit_sharing_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_credit_sharing_id ON public.opportunity_rfp_credit_sharing USING btree (id);


--
-- TOC entry 8273 (class 1259 OID 27689685)
-- Name: idx_opportunity_rfp_detail_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_detail_id ON public.opportunity_rfp_detail USING btree (id);


--
-- TOC entry 8274 (class 1259 OID 27689686)
-- Name: idx_opportunity_rfp_detail_opportunity_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_detail_opportunity_activity_id ON public.opportunity_rfp_detail USING btree (opportunity_activity_id);


--
-- TOC entry 8275 (class 1259 OID 27689687)
-- Name: idx_opportunity_rfp_detail_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_detail_opportunity_id ON public.opportunity_rfp_detail USING btree (opportunity_id);


--
-- TOC entry 8283 (class 1259 OID 27689688)
-- Name: idx_opportunity_rfp_details_entry_document_map_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_details_entry_document_map_id ON public.opportunity_rfp_details_entry_document_map USING btree (id);


--
-- TOC entry 8278 (class 1259 OID 27689689)
-- Name: idx_opportunity_rfp_details_entry_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_details_entry_id ON public.opportunity_rfp_details_entry USING btree (id);


--
-- TOC entry 8279 (class 1259 OID 27689690)
-- Name: idx_opportunity_rfp_details_entry_opportunity_activity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_details_entry_opportunity_activity_id ON public.opportunity_rfp_details_entry USING btree (opportunity_activity_id);


--
-- TOC entry 8280 (class 1259 OID 27689691)
-- Name: idx_opportunity_rfp_details_entry_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_details_entry_opportunity_id ON public.opportunity_rfp_details_entry USING btree (opportunity_id);


--
-- TOC entry 8286 (class 1259 OID 27689692)
-- Name: idx_opportunity_rfp_insurer_detail_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_insurer_detail_id ON public.opportunity_rfp_insurer_detail USING btree (id);


--
-- TOC entry 8287 (class 1259 OID 27689693)
-- Name: idx_opportunity_rfp_insurer_detail_insurer_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_insurer_detail_insurer_contact_id ON public.opportunity_rfp_insurer_detail USING btree (insurer_contact_id);


--
-- TOC entry 8288 (class 1259 OID 27689694)
-- Name: idx_opportunity_rfp_insurer_detail_insurer_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_insurer_detail_insurer_id ON public.opportunity_rfp_insurer_detail USING btree (insurer_id);


--
-- TOC entry 8291 (class 1259 OID 27689695)
-- Name: idx_opportunity_rfp_tpa_detail_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_tpa_detail_id ON public.opportunity_rfp_tpa_detail USING btree (id);


--
-- TOC entry 8292 (class 1259 OID 27689696)
-- Name: idx_opportunity_rfp_tpa_detail_tpa_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_tpa_detail_tpa_contact_id ON public.opportunity_rfp_tpa_detail USING btree (tpa_contact_id);


--
-- TOC entry 8293 (class 1259 OID 27689697)
-- Name: idx_opportunity_rfp_tpa_detail_tpa_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_opportunity_rfp_tpa_detail_tpa_id ON public.opportunity_rfp_tpa_detail USING btree (tpa_id);


--
-- TOC entry 8079 (class 1259 OID 27689698)
-- Name: idx_oppurtunity_companyid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_oppurtunity_companyid ON public.opportunity USING btree (company_id);


--
-- TOC entry 8080 (class 1259 OID 27689699)
-- Name: idx_oppurtunity_contactid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_oppurtunity_contactid ON public.opportunity USING btree (contact_id);


--
-- TOC entry 7890 (class 1259 OID 27689700)
-- Name: idx_org_department_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_org_department_name ON public.org_department USING btree (name);


--
-- TOC entry 7893 (class 1259 OID 27689701)
-- Name: idx_org_designation_created_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_org_designation_created_at ON public.org_designation USING btree (created_at);


--
-- TOC entry 7894 (class 1259 OID 27689702)
-- Name: idx_org_designation_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_org_designation_name ON public.org_designation USING btree (name);


--
-- TOC entry 8304 (class 1259 OID 27689703)
-- Name: idx_org_service_tat_summary_lookup; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_org_service_tat_summary_lookup ON public.org_service_tat_summary USING btree (org_id, service_id, snapshot_date);


--
-- TOC entry 8311 (class 1259 OID 27689704)
-- Name: idx_organisation_created_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_organisation_created_at ON public.organisation USING btree (created_at);


--
-- TOC entry 8312 (class 1259 OID 27689705)
-- Name: idx_organisation_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_organisation_name ON public.organisation USING btree (name);


--
-- TOC entry 8378 (class 1259 OID 27689706)
-- Name: idx_ped_employee; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_ped_employee ON public.policy_enrollment_dependent USING btree (employee_id, relation);


--
-- TOC entry 8317 (class 1259 OID 27689707)
-- Name: idx_performance_output_performance_month; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_performance_output_performance_month ON public.performance_output USING btree (performance_month);


--
-- TOC entry 8318 (class 1259 OID 27689708)
-- Name: idx_performance_output_user_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_performance_output_user_id ON public.performance_output USING btree (user_id);


--
-- TOC entry 8340 (class 1259 OID 27689717)
-- Name: idx_policy_audit_log_action; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_audit_log_action ON public.policy_audit_log USING btree (action);


--
-- TOC entry 8341 (class 1259 OID 27689718)
-- Name: idx_policy_audit_log_entity_type; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_audit_log_entity_type ON public.policy_audit_log USING btree (entity_type);


--
-- TOC entry 8342 (class 1259 OID 27689719)
-- Name: idx_policy_audit_log_entity_type_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_audit_log_entity_type_id ON public.policy_audit_log USING btree (entity_type, entity_id);


--
-- TOC entry 8343 (class 1259 OID 27689720)
-- Name: idx_policy_audit_log_policy_configuration_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_audit_log_policy_configuration_id ON public.policy_audit_log USING btree (policy_configuration_id);


--
-- TOC entry 8344 (class 1259 OID 27689721)
-- Name: idx_policy_audit_log_policy_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_audit_log_policy_id ON public.policy_audit_log USING btree (policy_id);


--
-- TOC entry 8349 (class 1259 OID 27689722)
-- Name: idx_policy_claim_employee_policy; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_claim_employee_policy ON public.policy_claim USING btree (employee_id, policy_id);


--
-- TOC entry 8354 (class 1259 OID 27689723)
-- Name: idx_policy_claim_settlement_claim_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_claim_settlement_claim_id ON public.policy_claim_settlement USING btree (claim_id);


--
-- TOC entry 8323 (class 1259 OID 27689724)
-- Name: idx_policy_company_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_company_id ON public.policy USING btree (company_id);


--
-- TOC entry 8368 (class 1259 OID 27689727)
-- Name: idx_policy_component_map; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_component_map ON public.policy_employee_enrollment_choice USING btree (employee_enrollment_id);


--
-- TOC entry 8359 (class 1259 OID 27689734)
-- Name: idx_policy_config_component_relation_map_detail_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_config_component_relation_map_detail_id ON public.policy_configuration_component_relation_map USING btree (policy_configuration_component_detail_id);


--
-- TOC entry 8197 (class 1259 OID 27689735)
-- Name: idx_policy_confirmation_document_map_document_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_confirmation_document_map_document_id ON public.opportunity_policy_confirmation_document_map USING btree (document_id);


--
-- TOC entry 8198 (class 1259 OID 27689736)
-- Name: idx_policy_confirmation_document_map_policy_confirmation_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_confirmation_document_map_policy_confirmation_id ON public.opportunity_policy_confirmation_document_map USING btree (policy_confirmation_id);


--
-- TOC entry 8324 (class 1259 OID 27689737)
-- Name: idx_policy_created_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_created_at ON public.policy USING btree (created_at);


--
-- TOC entry 8325 (class 1259 OID 27689738)
-- Name: idx_policy_created_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_created_by ON public.policy USING btree (created_by);


--
-- TOC entry 8326 (class 1259 OID 27689739)
-- Name: idx_policy_expried_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_expried_at ON public.policy USING btree (policy_to);


--
-- TOC entry 8400 (class 1259 OID 27689740)
-- Name: idx_policy_feature_docs_document_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_feature_docs_document_id ON public.policy_feature_document_map USING btree (document_id);


--
-- TOC entry 8401 (class 1259 OID 27689741)
-- Name: idx_policy_feature_docs_policy_created; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_feature_docs_policy_created ON public.policy_feature_document_map USING btree (policy_id, created_at);


--
-- TOC entry 8402 (class 1259 OID 27689742)
-- Name: idx_policy_feature_docs_policy_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_feature_docs_policy_id ON public.policy_feature_document_map USING btree (policy_id);


--
-- TOC entry 8403 (class 1259 OID 27689743)
-- Name: idx_policy_feature_docs_policy_status; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_feature_docs_policy_status ON public.policy_feature_document_map USING btree (policy_id, status);


--
-- TOC entry 8404 (class 1259 OID 27689744)
-- Name: idx_policy_feature_docs_status; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_feature_docs_status ON public.policy_feature_document_map USING btree (status);


--
-- TOC entry 8327 (class 1259 OID 27689745)
-- Name: idx_policy_mig_ref_no_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_mig_ref_no_id ON public.policy USING btree (mig_ref_no);


--
-- TOC entry 8328 (class 1259 OID 27689746)
-- Name: idx_policy_net_premium; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_net_premium ON public.policy USING btree (net_premium);


--
-- TOC entry 8329 (class 1259 OID 27689748)
-- Name: idx_policy_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_opportunity_id ON public.policy USING btree (opportunity_id);


--
-- TOC entry 8330 (class 1259 OID 27689749)
-- Name: idx_policy_owner_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_owner_id ON public.policy USING btree (owner_id);


--
-- TOC entry 8331 (class 1259 OID 27689750)
-- Name: idx_policy_policy_type_lid; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_policy_policy_type_lid ON public.policy USING btree (policy_type_lid);


--
-- TOC entry 8425 (class 1259 OID 27689759)
-- Name: idx_professional_experience_company; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_professional_experience_company ON public.professional_experience USING btree (company);


--
-- TOC entry 8426 (class 1259 OID 27689760)
-- Name: idx_professional_experience_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_professional_experience_contact_id ON public.professional_experience USING btree (contact_id);


--
-- TOC entry 8427 (class 1259 OID 27689761)
-- Name: idx_professional_experience_deleted_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_professional_experience_deleted_at ON public.professional_experience USING btree (deleted_at);


--
-- TOC entry 8428 (class 1259 OID 27689762)
-- Name: idx_professional_experience_department; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_professional_experience_department ON public.professional_experience USING btree (department);


--
-- TOC entry 8429 (class 1259 OID 27689763)
-- Name: idx_professional_experience_designation; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_professional_experience_designation ON public.professional_experience USING btree (designation);


--
-- TOC entry 8430 (class 1259 OID 27689764)
-- Name: idx_professional_experience_from_date; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_professional_experience_from_date ON public.professional_experience USING btree (from_date);


--
-- TOC entry 8431 (class 1259 OID 27689765)
-- Name: idx_professional_experience_to_date; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_professional_experience_to_date ON public.professional_experience USING btree (to_date);


--
-- TOC entry 8434 (class 1259 OID 27689766)
-- Name: idx_qualification_experience_contact_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_qualification_experience_contact_id ON public.qualification_experience USING btree (contact_id);


--
-- TOC entry 8435 (class 1259 OID 27689767)
-- Name: idx_qualification_experience_deleted_at; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_qualification_experience_deleted_at ON public.qualification_experience USING btree (deleted_at);


--
-- TOC entry 8436 (class 1259 OID 27689768)
-- Name: idx_qualification_experience_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_qualification_experience_name ON public.qualification_experience USING btree (name_of_qualification);


--
-- TOC entry 8437 (class 1259 OID 27689769)
-- Name: idx_qualification_experience_year; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_qualification_experience_year ON public.qualification_experience USING btree (year_of_qualification);


--
-- TOC entry 8440 (class 1259 OID 27689770)
-- Name: idx_region_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_region_name ON public.region USING btree (name);


--
-- TOC entry 8443 (class 1259 OID 27689771)
-- Name: idx_role_acl_category_action_map_role_acl_category_action; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_role_acl_category_action_map_role_acl_category_action ON public.role_acl_category_action_map USING btree (role_id, acl_category_action_id);


--
-- TOC entry 8446 (class 1259 OID 27689772)
-- Name: idx_roles_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_roles_name ON public.roles USING btree (name);


--
-- TOC entry 8455 (class 1259 OID 27689773)
-- Name: idx_state_country_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_state_country_id ON public.state USING btree (country_id);


--
-- TOC entry 8456 (class 1259 OID 27689774)
-- Name: idx_state_name; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_state_name ON public.state USING btree (name);


--
-- TOC entry 8459 (class 1259 OID 27689775)
-- Name: idx_task_assignee_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_task_assignee_id ON public.task USING btree (assignee_id);


--
-- TOC entry 8460 (class 1259 OID 27689776)
-- Name: idx_task_created_by; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_task_created_by ON public.task USING btree (created_by);


--
-- TOC entry 8461 (class 1259 OID 27689777)
-- Name: idx_task_opportunity_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_task_opportunity_id ON public.task USING btree (opportunity_id);


--
-- TOC entry 8472 (class 1259 OID 27689778)
-- Name: idx_user_role_user_role; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_user_role_user_role ON public.user_role USING btree (user_id, role_id);


--
-- TOC entry 8475 (class 1259 OID 27689779)
-- Name: idx_users_branch_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_users_branch_id ON public.users USING btree (branch_id);


--
-- TOC entry 7968 (class 1259 OID 27689780)
-- Name: idx_value_key; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX idx_value_key ON public.lookup_data USING btree (value_key);


--
-- TOC entry 8485 (class 1259 OID 27689781)
-- Name: tmp_idx_optydelete_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX tmp_idx_optydelete_id ON public.zz_ref_lanka_opty_being_deleted_20250902 USING btree (id);


--
-- TOC entry 8486 (class 1259 OID 27689782)
-- Name: tmp_idx_plcdelete_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX tmp_idx_plcdelete_id ON public.zz_ref_lanka_policies_being_deleted_20250902 USING btree (id);


--
-- TOC entry 8383 (class 1259 OID 27689783)
-- Name: uq_pee_empco_companyemp_active; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE UNIQUE INDEX uq_pee_empco_companyemp_active ON public.policy_enrollment_employee USING btree (employee_company_id, company_employee_id) WHERE (deleted_at IS NULL);


--
-- TOC entry 8482 (class 1259 OID 27689784)
-- Name: zz_idx_zz_trnsf_min_users_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX zz_idx_zz_trnsf_min_users_id ON public.users USING btree (id);


--
-- TOC entry 8487 (class 1259 OID 27689785)
-- Name: zz_tmp_load_address_id; Type: INDEX; Schema: public; Owner: nl2sql_ai
--

CREATE INDEX zz_tmp_load_address_id ON public.zz_tmp_load_address USING btree (id);


--
-- TOC entry 8955 (class 2618 OID 27663411)
-- Name: vr_all_user_info _RETURN; Type: RULE; Schema: public; Owner: nl2sql_ai
--

CREATE OR REPLACE VIEW public.vr_all_user_info AS
 SELECT TRIM(BOTH FROM (((usr.first_name)::text || ' '::text) || (usr.last_name)::text)) AS user_name,
    usr.email_id AS user_email,
    TRIM(BOTH FROM (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text)) AS manager_name,
    mgr.email_id AS manager_email,
    usr.iirm_emp_id AS iirm_employee_id,
    org.name AS organisation,
    orgb.name AS branch,
    sbu.name AS sbu,
    orgv.name AS vertical,
    dept.name AS department,
    desg.name AS designation,
    string_agg((rl.name)::text, ', '::text) AS roles,
    usr.login_name AS login,
    usr.user_status_key AS user_status,
    usr.id AS uid,
    usr.reporting_user_id AS manager_uid
   FROM ((((((((((public.users usr
     JOIN public.employee emp ON (((emp.user_id = usr.id) AND ((usr.user_type_key)::text = ANY (ARRAY[('USER_TYPE_IIRM_EMPLOYEE'::character varying)::text, ('USER_TYPE_COMPANY_EMPLOYEE_AND_IIRM_EMPLOYEE'::character varying)::text])))))
     LEFT JOIN public.employee mgr ON ((emp.reporting_manager_employee_id = mgr.id)))
     JOIN public.organisation org ON ((org.id = emp.organisation_id)))
     LEFT JOIN public.org_sbu sbu ON ((sbu.id = emp.sbu_id)))
     JOIN public.org_vertical orgv ON (((org.id = orgv.organisation_id) AND (emp.vertical_id = orgv.id))))
     JOIN public.org_department dept ON ((emp.department_id = dept.id)))
     JOIN public.org_designation desg ON ((emp.designation_id = desg.id)))
     JOIN public.org_branch orgb ON ((emp.branch_id = orgb.id)))
     JOIN public.user_role ur ON ((usr.id = ur.user_id)))
     JOIN public.roles rl ON ((ur.role_id = rl.id)))
  GROUP BY (TRIM(BOTH FROM (((usr.first_name)::text || ' '::text) || (usr.last_name)::text))), usr.email_id, (TRIM(BOTH FROM (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text))), mgr.email_id, org.name, sbu.name, orgv.name, dept.name, orgb.name, usr.login_name, desg.name, usr.user_status_key, usr.id, usr.reporting_user_id;


--
-- TOC entry 8957 (class 2618 OID 27663420)
-- Name: vr_active_user_info _RETURN; Type: RULE; Schema: public; Owner: nl2sql_ai
--

CREATE OR REPLACE VIEW public.vr_active_user_info AS
 SELECT (((usr.first_name)::text || ' '::text) || (usr.last_name)::text) AS user_name,
    usr.email_id AS user_email,
    (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text) AS manager_name,
    mgr.email_id AS manager_email,
    usr.iirm_emp_id AS iirm_employee_id,
    org.name AS organisation,
    orgb.name AS branch,
    orgv.name AS vertical,
    dept.name AS department,
    desg.name AS designation,
    string_agg((rl.name)::text, ', '::text) AS roles,
    usr.login_name AS login,
    usr.id AS uid,
    usr.reporting_user_id AS manager_uid
   FROM (((((((((public.users usr
     JOIN public.employee emp ON (((emp.user_id = usr.id) AND ((usr.user_status_key)::text = 'USER_STATUS_ACTIVE'::text))))
     JOIN public.employee mgr ON ((emp.reporting_manager_employee_id = mgr.id)))
     JOIN public.organisation org ON ((org.id = emp.organisation_id)))
     JOIN public.org_vertical orgv ON (((org.id = orgv.organisation_id) AND (emp.vertical_id = orgv.id))))
     JOIN public.org_department dept ON ((emp.department_id = dept.id)))
     JOIN public.org_designation desg ON ((emp.designation_id = desg.id)))
     JOIN public.org_branch orgb ON ((emp.branch_id = orgb.id)))
     JOIN public.user_role ur ON ((usr.id = ur.user_id)))
     JOIN public.roles rl ON ((ur.role_id = rl.id)))
  GROUP BY (((usr.first_name)::text || ' '::text) || (usr.last_name)::text), usr.email_id, (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text), mgr.email_id, org.name, orgv.name, dept.name, orgb.name, usr.login_name, desg.name, usr.id, usr.reporting_user_id
UNION
 SELECT (((usr.first_name)::text || ' '::text) || (usr.last_name)::text) AS user_name,
    usr.email_id AS user_email,
    (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text) AS manager_name,
    mgr.email_id AS manager_email,
    usr.iirm_emp_id AS iirm_employee_id,
    org.name AS organisation,
    orgb.name AS branch,
    orgv.name AS vertical,
    dept.name AS department,
    desg.name AS designation,
    string_agg((rl.name)::text, ', '::text) AS roles,
    usr.login_name AS login,
    usr.id AS uid,
    usr.reporting_user_id AS manager_uid
   FROM (((((((((public.users usr
     JOIN public.employee emp ON (((emp.user_id = usr.id) AND ((usr.user_status_key)::text = 'USER_STATUS_ACTIVE'::text) AND (usr.reporting_user_id IS NULL))))
     LEFT JOIN public.employee mgr ON ((emp.reporting_manager_employee_id = mgr.id)))
     JOIN public.organisation org ON ((org.id = emp.organisation_id)))
     JOIN public.org_vertical orgv ON (((org.id = orgv.organisation_id) AND (emp.vertical_id = orgv.id))))
     JOIN public.org_department dept ON ((emp.department_id = dept.id)))
     JOIN public.org_designation desg ON ((emp.designation_id = desg.id)))
     JOIN public.org_branch orgb ON ((emp.branch_id = orgb.id)))
     JOIN public.user_role ur ON ((usr.id = ur.user_id)))
     JOIN public.roles rl ON ((ur.role_id = rl.id)))
  GROUP BY (((usr.first_name)::text || ' '::text) || (usr.last_name)::text), usr.email_id, (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text), mgr.email_id, org.name, orgv.name, dept.name, orgb.name, usr.login_name, desg.name, usr.id, usr.reporting_user_id;


--
-- TOC entry 8966 (class 2618 OID 27663463)
-- Name: vr_inactive_user_info _RETURN; Type: RULE; Schema: public; Owner: nl2sql_ai
--

CREATE OR REPLACE VIEW public.vr_inactive_user_info AS
 SELECT (((usr.first_name)::text || ' '::text) || (usr.last_name)::text) AS user_name,
    usr.email_id AS user_email,
    (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text) AS manager_name,
    mgr.email_id AS manager_email,
    usr.iirm_emp_id AS iirm_employee_id,
    org.name AS organisation,
    orgb.name AS branch,
    orgv.name AS vertical,
    dept.name AS department,
    desg.name AS designation,
    string_agg((rl.name)::text, ', '::text) AS roles,
    usr.login_name AS login,
    usr.id AS uid,
    usr.reporting_user_id AS manager_uid
   FROM (((((((((public.users usr
     JOIN public.employee emp ON (((emp.user_id = usr.id) AND ((usr.user_status_key)::text = 'USER_STATUS_INACTIVE'::text))))
     JOIN public.employee mgr ON ((emp.reporting_manager_employee_id = mgr.id)))
     JOIN public.organisation org ON ((org.id = emp.organisation_id)))
     JOIN public.org_vertical orgv ON (((org.id = orgv.organisation_id) AND (emp.vertical_id = orgv.id))))
     JOIN public.org_department dept ON ((emp.department_id = dept.id)))
     JOIN public.org_designation desg ON ((emp.designation_id = desg.id)))
     JOIN public.org_branch orgb ON ((emp.branch_id = orgb.id)))
     JOIN public.user_role ur ON ((usr.id = ur.user_id)))
     JOIN public.roles rl ON ((ur.role_id = rl.id)))
  GROUP BY (((usr.first_name)::text || ' '::text) || (usr.last_name)::text), usr.email_id, (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text), mgr.email_id, org.name, orgv.name, dept.name, orgb.name, usr.login_name, desg.name, usr.id, usr.reporting_user_id
UNION
 SELECT (((usr.first_name)::text || ' '::text) || (usr.last_name)::text) AS user_name,
    usr.email_id AS user_email,
    (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text) AS manager_name,
    mgr.email_id AS manager_email,
    usr.iirm_emp_id AS iirm_employee_id,
    org.name AS organisation,
    orgb.name AS branch,
    orgv.name AS vertical,
    dept.name AS department,
    desg.name AS designation,
    string_agg((rl.name)::text, ', '::text) AS roles,
    usr.login_name AS login,
    usr.id AS uid,
    usr.reporting_user_id AS manager_uid
   FROM (((((((((public.users usr
     JOIN public.employee emp ON (((emp.user_id = usr.id) AND ((usr.user_status_key)::text = 'USER_STATUS_INACTIVE'::text) AND (usr.reporting_user_id IS NULL))))
     LEFT JOIN public.employee mgr ON ((emp.reporting_manager_employee_id = mgr.id)))
     JOIN public.organisation org ON ((org.id = emp.organisation_id)))
     JOIN public.org_vertical orgv ON (((org.id = orgv.organisation_id) AND (emp.vertical_id = orgv.id))))
     JOIN public.org_department dept ON ((emp.department_id = dept.id)))
     JOIN public.org_designation desg ON ((emp.designation_id = desg.id)))
     JOIN public.org_branch orgb ON ((emp.branch_id = orgb.id)))
     JOIN public.user_role ur ON ((usr.id = ur.user_id)))
     JOIN public.roles rl ON ((ur.role_id = rl.id)))
  GROUP BY (((usr.first_name)::text || ' '::text) || (usr.last_name)::text), usr.email_id, (((mgr.first_name)::text || ' '::text) || (mgr.last_name)::text), mgr.email_id, org.name, orgv.name, dept.name, orgb.name, usr.login_name, desg.name, usr.id, usr.reporting_user_id;


--
-- TOC entry 8494 (class 2606 OID 27689789)
-- Name: admin_reports_parameters admin_reports_parameters_admin_report_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports_parameters
    ADD CONSTRAINT admin_reports_parameters_admin_report_id_fkey FOREIGN KEY (admin_report_id) REFERENCES public.admin_reports(id);


--
-- TOC entry 8495 (class 2606 OID 27689794)
-- Name: admin_reports_results_mappings admin_reports_results_mappings_admin_report_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.admin_reports_results_mappings
    ADD CONSTRAINT admin_reports_results_mappings_admin_report_id_fkey FOREIGN KEY (admin_report_id) REFERENCES public.admin_reports(id);


--
-- TOC entry 8496 (class 2606 OID 27689799)
-- Name: ai_conversation_message ai_conversation_message_conversation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.ai_conversation_message
    ADD CONSTRAINT ai_conversation_message_conversation_id_fkey FOREIGN KEY (conversation_id) REFERENCES public.ai_conversation(id);


--
-- TOC entry 8497 (class 2606 OID 27689804)
-- Name: ai_conversation_message ai_conversation_message_parent_message_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.ai_conversation_message
    ADD CONSTRAINT ai_conversation_message_parent_message_id_fkey FOREIGN KEY (parent_message_id) REFERENCES public.ai_conversation_message(id);


--
-- TOC entry 8498 (class 2606 OID 27689809)
-- Name: ai_conversation_message ai_conversation_message_reference_message_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.ai_conversation_message
    ADD CONSTRAINT ai_conversation_message_reference_message_id_fkey FOREIGN KEY (reference_message_id) REFERENCES public.ai_conversation_message(id);


--
-- TOC entry 8500 (class 2606 OID 27689814)
-- Name: audit_history_log_detail audit_log_detail_audit_log_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.audit_history_log_detail
    ADD CONSTRAINT audit_log_detail_audit_log_id_fkey FOREIGN KEY (audit_log_id) REFERENCES public.audit_history_log(id);


--
-- TOC entry 8538 (class 2606 OID 27689822)
-- Name: document_processing_file document_processing_file_document_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.document_processing_file
    ADD CONSTRAINT document_processing_file_document_id_fkey FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8766 (class 2606 OID 27689827)
-- Name: policy_employee_endorsement endorsement; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_endorsement
    ADD CONSTRAINT endorsement FOREIGN KEY (endorsement_id) REFERENCES public.endorsement(id);


--
-- TOC entry 8488 (class 2606 OID 27689840)
-- Name: acl_category_action_api_map fk_acl_category_action; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_category_action_api_map
    ADD CONSTRAINT fk_acl_category_action FOREIGN KEY (acl_category_action_id) REFERENCES public.acl_category_action_map(id);


--
-- TOC entry 8489 (class 2606 OID 27689845)
-- Name: acl_category_action_map fk_acl_category_action_map_action_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_category_action_map
    ADD CONSTRAINT fk_acl_category_action_map_action_id FOREIGN KEY (acl_action_id) REFERENCES public.acl_actions(id);


--
-- TOC entry 8490 (class 2606 OID 27689850)
-- Name: acl_category_action_map fk_acl_category_action_map_category_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.acl_category_action_map
    ADD CONSTRAINT fk_acl_category_action_map_category_id FOREIGN KEY (acl_category_id) REFERENCES public.acl_categories(id);


--
-- TOC entry 8659 (class 2606 OID 27689855)
-- Name: opportunity_mandate_details_entry fk_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_entry
    ADD CONSTRAINT fk_activity FOREIGN KEY (activity_id) REFERENCES public.mstr_activity(id);


--
-- TOC entry 8517 (class 2606 OID 27689860)
-- Name: company_address fk_address; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_address
    ADD CONSTRAINT fk_address FOREIGN KEY (address_id) REFERENCES public.address(id);


--
-- TOC entry 8786 (class 2606 OID 27689865)
-- Name: policy_risk_location_map fk_address; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_risk_location_map
    ADD CONSTRAINT fk_address FOREIGN KEY (address_id) REFERENCES public.address(id);


--
-- TOC entry 8491 (class 2606 OID 27689870)
-- Name: address fk_address_city; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.address
    ADD CONSTRAINT fk_address_city FOREIGN KEY (city_id) REFERENCES public.city(id);


--
-- TOC entry 8492 (class 2606 OID 27689875)
-- Name: address fk_address_country; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.address
    ADD CONSTRAINT fk_address_country FOREIGN KEY (country_id) REFERENCES public.country(id);


--
-- TOC entry 8493 (class 2606 OID 27689881)
-- Name: address fk_address_state; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.address
    ADD CONSTRAINT fk_address_state FOREIGN KEY (state_id) REFERENCES public.state(id);


--
-- TOC entry 8499 (class 2606 OID 27689886)
-- Name: announcement fk_announcement_organisation; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.announcement
    ADD CONSTRAINT fk_announcement_organisation FOREIGN KEY (organisation_id) REFERENCES public.organisation(id);


--
-- TOC entry 8519 (class 2606 OID 27689893)
-- Name: company_authentication_map fk_authentication_method; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_authentication_map
    ADD CONSTRAINT fk_authentication_method FOREIGN KEY (authentication_method_id) REFERENCES public.authentication_methods(id) ON DELETE CASCADE;


--
-- TOC entry 8709 (class 2606 OID 27689901)
-- Name: opportunity_previous_mediator_details fk_branch; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_mediator_details
    ADD CONSTRAINT fk_branch FOREIGN KEY (branch_id) REFERENCES public.address(id);


--
-- TOC entry 8503 (class 2606 OID 27689906)
-- Name: broker_contact fk_broker; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_contact
    ADD CONSTRAINT fk_broker FOREIGN KEY (broker_id) REFERENCES public.broker(id);


--
-- TOC entry 8501 (class 2606 OID 27689911)
-- Name: broker_address fk_broker_address_address; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_address
    ADD CONSTRAINT fk_broker_address_address FOREIGN KEY (address_id) REFERENCES public.address(id);


--
-- TOC entry 8502 (class 2606 OID 27689916)
-- Name: broker_address fk_broker_address_broker; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_address
    ADD CONSTRAINT fk_broker_address_broker FOREIGN KEY (broker_id) REFERENCES public.broker(id);


--
-- TOC entry 8621 (class 2606 OID 27689921)
-- Name: opportunity_broking_slip_version_details fk_broking_slip_generation_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_version_details
    ADD CONSTRAINT fk_broking_slip_generation_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8746 (class 2606 OID 27689926)
-- Name: policy_cd_number_map fk_cd_detail; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_cd_number_map
    ADD CONSTRAINT fk_cd_detail FOREIGN KEY (cd_id) REFERENCES public.opportunity_placement_slip_cd_detail(id);


--
-- TOC entry 8509 (class 2606 OID 27689931)
-- Name: caution_deposit_policy_mapping fk_cdp_caution; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit_policy_mapping
    ADD CONSTRAINT fk_cdp_caution FOREIGN KEY (caution_deposit_id) REFERENCES public.caution_deposit(id);


--
-- TOC entry 8510 (class 2606 OID 27689936)
-- Name: caution_deposit_policy_mapping fk_cdp_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit_policy_mapping
    ADD CONSTRAINT fk_cdp_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8511 (class 2606 OID 27689945)
-- Name: caution_deposit_transaction fk_cdt_caution; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.caution_deposit_transaction
    ADD CONSTRAINT fk_cdt_caution FOREIGN KEY (caution_deposit_id) REFERENCES public.caution_deposit(id);


--
-- TOC entry 8512 (class 2606 OID 27689950)
-- Name: child_details fk_child_details_contact_details_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.child_details
    ADD CONSTRAINT fk_child_details_contact_details_id FOREIGN KEY (contact_details_id) REFERENCES public.contact_details(id);


--
-- TOC entry 8513 (class 2606 OID 27689955)
-- Name: city fk_city_state; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.city
    ADD CONSTRAINT fk_city_state FOREIGN KEY (state_id) REFERENCES public.state(id);


--
-- TOC entry 8726 (class 2606 OID 27689960)
-- Name: opportunity_rfp_client_contact_influencers fk_client_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_client_contact_influencers
    ADD CONSTRAINT fk_client_contact FOREIGN KEY (client_contact_id) REFERENCES public.opportunity_rfp_client_contact_detail(id);


--
-- TOC entry 8660 (class 2606 OID 27689965)
-- Name: opportunity_mandate_details_entry fk_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_entry
    ADD CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8744 (class 2606 OID 27689970)
-- Name: policy fk_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy
    ADD CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8523 (class 2606 OID 27689975)
-- Name: company_detail fk_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_detail
    ADD CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8529 (class 2606 OID 27689980)
-- Name: company_strategy fk_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_strategy
    ADD CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8518 (class 2606 OID 27689985)
-- Name: company_address fk_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_address
    ADD CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8550 (class 2606 OID 27689990)
-- Name: group_company_map fk_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.group_company_map
    ADD CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8524 (class 2606 OID 27689995)
-- Name: company_doc_map fk_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_doc_map
    ADD CONSTRAINT fk_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8514 (class 2606 OID 27690000)
-- Name: company fk_company_account_manager; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company
    ADD CONSTRAINT fk_company_account_manager FOREIGN KEY (account_manager) REFERENCES public.users(id);


--
-- TOC entry 8526 (class 2606 OID 27690005)
-- Name: company_portal_configuration fk_company_configuration_status_lid; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_portal_configuration
    ADD CONSTRAINT fk_company_configuration_status_lid FOREIGN KEY (company_configuration_status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8521 (class 2606 OID 27690010)
-- Name: company_contact_map fk_company_contact_map_company_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_contact_map
    ADD CONSTRAINT fk_company_contact_map_company_id FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8522 (class 2606 OID 27690018)
-- Name: company_contact_map fk_company_contact_map_contact_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_contact_map
    ADD CONSTRAINT fk_company_contact_map_contact_id FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8515 (class 2606 OID 27690023)
-- Name: company fk_company_country; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company
    ADD CONSTRAINT fk_company_country FOREIGN KEY (country_id) REFERENCES public.country(id);


--
-- TOC entry 8754 (class 2606 OID 27690028)
-- Name: policy_configuration fk_company_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration
    ADD CONSTRAINT fk_company_id FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8759 (class 2606 OID 27690033)
-- Name: policy_configuration_components_detail fk_company_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_components_detail
    ADD CONSTRAINT fk_company_id FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8516 (class 2606 OID 27690038)
-- Name: company fk_company_lead_crm; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company
    ADD CONSTRAINT fk_company_lead_crm FOREIGN KEY (lead_crm) REFERENCES public.users(id);


--
-- TOC entry 8520 (class 2606 OID 27690043)
-- Name: company_authentication_map fk_company_portal_auth_config; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_authentication_map
    ADD CONSTRAINT fk_company_portal_auth_config FOREIGN KEY (company_portal_auth_config_id) REFERENCES public.company_authentication_config(id);


--
-- TOC entry 8527 (class 2606 OID 27690048)
-- Name: company_portal_configuration fk_company_portal_configuration_detail; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_portal_configuration
    ADD CONSTRAINT fk_company_portal_configuration_detail FOREIGN KEY (company_portal_configuration_detail_id) REFERENCES public.company_portal_configuration_detail(id);


--
-- TOC entry 8661 (class 2606 OID 27690053)
-- Name: opportunity_mandate_details_entry fk_compensation_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_entry
    ADD CONSTRAINT fk_compensation_type FOREIGN KEY (compensation_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8504 (class 2606 OID 27690058)
-- Name: broker_contact fk_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.broker_contact
    ADD CONSTRAINT fk_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8625 (class 2606 OID 27690063)
-- Name: opportunity_contact_map fk_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_contact_map
    ADD CONSTRAINT fk_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8534 (class 2606 OID 27690068)
-- Name: contact_doc_map fk_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_doc_map
    ADD CONSTRAINT fk_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8530 (class 2606 OID 27690073)
-- Name: contact_address fk_contact_address_address_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_address
    ADD CONSTRAINT fk_contact_address_address_id FOREIGN KEY (address_id) REFERENCES public.address(id);


--
-- TOC entry 8531 (class 2606 OID 27690079)
-- Name: contact_address fk_contact_address_contact_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_address
    ADD CONSTRAINT fk_contact_address_contact_id FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8532 (class 2606 OID 27690084)
-- Name: contact_communication_details fk_contact_communication_details_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_communication_details
    ADD CONSTRAINT fk_contact_communication_details_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8533 (class 2606 OID 27690089)
-- Name: contact_details fk_contact_details_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.contact_details
    ADD CONSTRAINT fk_contact_details_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8589 (class 2606 OID 27690094)
-- Name: mstr_policy_constraints fk_country_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_constraints
    ADD CONSTRAINT fk_country_id FOREIGN KEY (country_id) REFERENCES public.country(id);


--
-- TOC entry 8535 (class 2606 OID 27690099)
-- Name: country fk_country_region; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.country
    ADD CONSTRAINT fk_country_region FOREIGN KEY (region_id) REFERENCES public.region(id);


--
-- TOC entry 8536 (class 2606 OID 27690104)
-- Name: currency fk_currency_country; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.currency
    ADD CONSTRAINT fk_currency_country FOREIGN KEY (country_id) REFERENCES public.country(id);


--
-- TOC entry 8689 (class 2606 OID 27690109)
-- Name: opportunity_policy_hard_copy fk_deviation_coverages; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT fk_deviation_coverages FOREIGN KEY (deviation_coverages_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8675 (class 2606 OID 27690114)
-- Name: opportunity_policy_confirmation fk_deviation_revised; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation
    ADD CONSTRAINT fk_deviation_revised FOREIGN KEY (deviation_resolved_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8690 (class 2606 OID 27690119)
-- Name: opportunity_policy_hard_copy fk_deviations; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT fk_deviations FOREIGN KEY (deviations_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8644 (class 2606 OID 27690124)
-- Name: opportunity_held_cover_note fk_deviations_addressed; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note
    ADD CONSTRAINT fk_deviations_addressed FOREIGN KEY (deviations_addressed_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8691 (class 2606 OID 27690129)
-- Name: opportunity_policy_hard_copy fk_deviations_addressed; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT fk_deviations_addressed FOREIGN KEY (deviations_addressed_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8656 (class 2606 OID 27690134)
-- Name: opportunity_mandate_details_document_map fk_doc_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_document_map
    ADD CONSTRAINT fk_doc_type FOREIGN KEY (document_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8546 (class 2606 OID 27690139)
-- Name: final_negotiation_meeting_summary fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_meeting_summary
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8552 (class 2606 OID 27690144)
-- Name: opportunity_held_cover_note_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8681 (class 2606 OID 27690149)
-- Name: opportunity_policy_confirmation_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8628 (class 2606 OID 27690154)
-- Name: opportunity_data_validation_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_data_validation_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8657 (class 2606 OID 27690159)
-- Name: opportunity_mandate_details_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8722 (class 2606 OID 27690164)
-- Name: opportunity_rfp_activity_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_activity_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8697 (class 2606 OID 27690169)
-- Name: opportunity_policy_hard_copy_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8704 (class 2606 OID 27690174)
-- Name: opportunity_premium_calculation_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8615 (class 2606 OID 27690179)
-- Name: opportunity_broking_slip_activity_document_map fk_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_activity_document_map
    ADD CONSTRAINT fk_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8687 (class 2606 OID 27690184)
-- Name: opportunity_policy_docket_document_map fk_document_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket_document_map
    ADD CONSTRAINT fk_document_type FOREIGN KEY (document_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8698 (class 2606 OID 27690189)
-- Name: opportunity_policy_hard_copy_document_map fk_document_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_document_map
    ADD CONSTRAINT fk_document_type FOREIGN KEY (document_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8705 (class 2606 OID 27690194)
-- Name: opportunity_premium_calculation_document_map fk_document_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation_document_map
    ADD CONSTRAINT fk_document_type FOREIGN KEY (document_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8539 (class 2606 OID 27690199)
-- Name: employee fk_employee_branch; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee
    ADD CONSTRAINT fk_employee_branch FOREIGN KEY (branch_id) REFERENCES public.org_branch(id);


--
-- TOC entry 8540 (class 2606 OID 27690204)
-- Name: employee fk_employee_department; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee
    ADD CONSTRAINT fk_employee_department FOREIGN KEY (department_id) REFERENCES public.org_department(id);


--
-- TOC entry 8541 (class 2606 OID 27690209)
-- Name: employee fk_employee_user_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee
    ADD CONSTRAINT fk_employee_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- TOC entry 8542 (class 2606 OID 27690214)
-- Name: employee fk_employee_vertical; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.employee
    ADD CONSTRAINT fk_employee_vertical FOREIGN KEY (vertical_id) REFERENCES public.org_vertical(id);


--
-- TOC entry 8543 (class 2606 OID 27690219)
-- Name: endorsement_field_mapping fk_endorsement_field_mapping_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.endorsement_field_mapping
    ADD CONSTRAINT fk_endorsement_field_mapping_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8544 (class 2606 OID 27690229)
-- Name: notification_event_parameter_mapping fk_event_parameter_mapping_event_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_parameter_mapping
    ADD CONSTRAINT fk_event_parameter_mapping_event_type FOREIGN KEY (event_type_id) REFERENCES public.notification_event_type(id);


--
-- TOC entry 8545 (class 2606 OID 27690234)
-- Name: notification_event_parameter_mapping fk_event_parameter_mapping_parameter_definition; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_parameter_mapping
    ADD CONSTRAINT fk_event_parameter_mapping_parameter_definition FOREIGN KEY (parameter_definition_id) REFERENCES public.notification_parameter(id);


--
-- TOC entry 8547 (class 2606 OID 27690239)
-- Name: final_negotiation_meeting_summary fk_finalised_quote; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_meeting_summary
    ADD CONSTRAINT fk_finalised_quote FOREIGN KEY (finalised_quote_id) REFERENCES public.opportunity_quote(id);


--
-- TOC entry 8551 (class 2606 OID 27690244)
-- Name: group_company_map fk_group_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.group_company_map
    ADD CONSTRAINT fk_group_company FOREIGN KEY (group_company_id) REFERENCES public.company(id);


--
-- TOC entry 8553 (class 2606 OID 27690249)
-- Name: opportunity_held_cover_note_document_map fk_held_cover_note; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_document_map
    ADD CONSTRAINT fk_held_cover_note FOREIGN KEY (held_cover_note_id) REFERENCES public.opportunity_held_cover_note(id);


--
-- TOC entry 8650 (class 2606 OID 27690254)
-- Name: opportunity_held_cover_note_cover_detail fk_held_cover_note; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_cover_detail
    ADD CONSTRAINT fk_held_cover_note FOREIGN KEY (held_cover_note_id) REFERENCES public.opportunity_held_cover_note(id);


--
-- TOC entry 8651 (class 2606 OID 27690260)
-- Name: opportunity_held_cover_note_insurer_map fk_held_cover_note; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_insurer_map
    ADD CONSTRAINT fk_held_cover_note FOREIGN KEY (held_cover_note_id) REFERENCES public.opportunity_held_cover_note(id);


--
-- TOC entry 8652 (class 2606 OID 27690265)
-- Name: opportunity_held_cover_note_insurer_map fk_held_cover_note_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note_insurer_map
    ADD CONSTRAINT fk_held_cover_note_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8554 (class 2606 OID 27690270)
-- Name: hospital_file_upload_tracking fk_hospital_file_upload_tracking_error_file; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.hospital_file_upload_tracking
    ADD CONSTRAINT fk_hospital_file_upload_tracking_error_file FOREIGN KEY (error_file_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8555 (class 2606 OID 27690275)
-- Name: hospital_file_upload_tracking fk_hospital_file_upload_tracking_file; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.hospital_file_upload_tracking
    ADD CONSTRAINT fk_hospital_file_upload_tracking_file FOREIGN KEY (file_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8556 (class 2606 OID 27690280)
-- Name: hospital_file_upload_tracking fk_hospital_file_upload_tracking_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.hospital_file_upload_tracking
    ADD CONSTRAINT fk_hospital_file_upload_tracking_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8557 (class 2606 OID 27690285)
-- Name: hospital_file_upload_tracking fk_hospital_file_upload_tracking_success_file; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.hospital_file_upload_tracking
    ADD CONSTRAINT fk_hospital_file_upload_tracking_success_file FOREIGN KEY (success_file_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8561 (class 2606 OID 27690290)
-- Name: insurer_participant_map fk_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_participant_map
    ADD CONSTRAINT fk_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8558 (class 2606 OID 27690295)
-- Name: insurer_address fk_insurer_address_address; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_address
    ADD CONSTRAINT fk_insurer_address_address FOREIGN KEY (address_id) REFERENCES public.address(id);


--
-- TOC entry 8559 (class 2606 OID 27690300)
-- Name: insurer_address fk_insurer_address_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_address
    ADD CONSTRAINT fk_insurer_address_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8560 (class 2606 OID 27690305)
-- Name: insurer_contact fk_insurer_company_contact_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_contact
    ADD CONSTRAINT fk_insurer_company_contact_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8608 (class 2606 OID 27690310)
-- Name: opportunity fk_is_policy_mined_lid; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity
    ADD CONSTRAINT fk_is_policy_mined_lid FOREIGN KEY (is_policy_mined_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8563 (class 2606 OID 27690315)
-- Name: knowledge_central fk_kc_category; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.knowledge_central
    ADD CONSTRAINT fk_kc_category FOREIGN KEY (category_id) REFERENCES public.lookup_data(id);


--
-- TOC entry 8564 (class 2606 OID 27690320)
-- Name: knowledge_central fk_kc_doc_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.knowledge_central
    ADD CONSTRAINT fk_kc_doc_type FOREIGN KEY (doc_type_id) REFERENCES public.lookup_data(id);


--
-- TOC entry 8565 (class 2606 OID 27690325)
-- Name: knowledge_central fk_kc_status; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.knowledge_central
    ADD CONSTRAINT fk_kc_status FOREIGN KEY (status_id) REFERENCES public.lookup_data(id);


--
-- TOC entry 8653 (class 2606 OID 27690330)
-- Name: opportunity_kdm_meeting fk_kdm_meeting_meeting; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_kdm_meeting
    ADD CONSTRAINT fk_kdm_meeting_meeting FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8548 (class 2606 OID 27690335)
-- Name: final_negotiation_meeting_summary fk_lead_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_meeting_summary
    ADD CONSTRAINT fk_lead_insurer FOREIGN KEY (lead_insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8611 (class 2606 OID 27690340)
-- Name: opportunity_activity_map fk_lead_role; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_activity_map
    ADD CONSTRAINT fk_lead_role FOREIGN KEY (lead_role_id) REFERENCES public.roles(id);


--
-- TOC entry 8592 (class 2606 OID 27690358)
-- Name: mstr_stage_activity_template fk_lead_role; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_stage_activity_template
    ADD CONSTRAINT fk_lead_role FOREIGN KEY (lead_role_id) REFERENCES public.roles(id);


--
-- TOC entry 8710 (class 2606 OID 27690363)
-- Name: opportunity_previous_mediator_details fk_location; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_mediator_details
    ADD CONSTRAINT fk_location FOREIGN KEY (location_id) REFERENCES public.city(id);


--
-- TOC entry 8658 (class 2606 OID 27690368)
-- Name: opportunity_mandate_details_document_map fk_mandate; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_document_map
    ADD CONSTRAINT fk_mandate FOREIGN KEY (mandate_id) REFERENCES public.opportunity_mandate_details_entry(id);


--
-- TOC entry 8662 (class 2606 OID 27690373)
-- Name: opportunity_mandate_details_entry fk_mandate_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_entry
    ADD CONSTRAINT fk_mandate_type FOREIGN KEY (mandate_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8581 (class 2606 OID 27690378)
-- Name: meeting_participant_map fk_meeting; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_participant_map
    ADD CONSTRAINT fk_meeting FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8570 (class 2606 OID 27690383)
-- Name: meeting fk_meeting_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting
    ADD CONSTRAINT fk_meeting_activity FOREIGN KEY (activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8573 (class 2606 OID 27690419)
-- Name: meeting_challenges_map fk_meeting_challenges_map_challenge; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_challenges_map
    ADD CONSTRAINT fk_meeting_challenges_map_challenge FOREIGN KEY (challenge_id) REFERENCES public.lookup_data(id);


--
-- TOC entry 8574 (class 2606 OID 27690424)
-- Name: meeting_challenges_map fk_meeting_challenges_map_meeting; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_challenges_map
    ADD CONSTRAINT fk_meeting_challenges_map_meeting FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8571 (class 2606 OID 27690429)
-- Name: meeting fk_meeting_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting
    ADD CONSTRAINT fk_meeting_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8575 (class 2606 OID 27690434)
-- Name: meeting_document_map fk_meeting_document_map_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_document_map
    ADD CONSTRAINT fk_meeting_document_map_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8576 (class 2606 OID 27690439)
-- Name: meeting_document_map fk_meeting_document_map_meeting; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_document_map
    ADD CONSTRAINT fk_meeting_document_map_meeting FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8577 (class 2606 OID 27690444)
-- Name: meeting_next_steps_map fk_meeting_next_steps_map_meeting; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_next_steps_map
    ADD CONSTRAINT fk_meeting_next_steps_map_meeting FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8578 (class 2606 OID 27690449)
-- Name: meeting_next_steps_map fk_meeting_next_steps_map_next_step; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_next_steps_map
    ADD CONSTRAINT fk_meeting_next_steps_map_next_step FOREIGN KEY (next_step_id) REFERENCES public.lookup_data(id);


--
-- TOC entry 8572 (class 2606 OID 27690454)
-- Name: meeting fk_meeting_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting
    ADD CONSTRAINT fk_meeting_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8579 (class 2606 OID 27690459)
-- Name: meeting_outcomes_map fk_meeting_outcomes_map_meeting; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_outcomes_map
    ADD CONSTRAINT fk_meeting_outcomes_map_meeting FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8580 (class 2606 OID 27690464)
-- Name: meeting_outcomes_map fk_meeting_outcomes_map_outcome; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.meeting_outcomes_map
    ADD CONSTRAINT fk_meeting_outcomes_map_outcome FOREIGN KEY (outcome_id) REFERENCES public.lookup_data(id);


--
-- TOC entry 8562 (class 2606 OID 27690469)
-- Name: insurer_participant_map fk_meeting_summary; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.insurer_participant_map
    ADD CONSTRAINT fk_meeting_summary FOREIGN KEY (meeting_summary_id) REFERENCES public.final_negotiation_meeting_summary(id);


--
-- TOC entry 8549 (class 2606 OID 27690474)
-- Name: final_negotiation_participant_map fk_meeting_summary; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.final_negotiation_participant_map
    ADD CONSTRAINT fk_meeting_summary FOREIGN KEY (meeting_summary_id) REFERENCES public.final_negotiation_meeting_summary(id);


--
-- TOC entry 8582 (class 2606 OID 27690479)
-- Name: mstr_hospital fk_mstr_hospital_address; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_hospital
    ADD CONSTRAINT fk_mstr_hospital_address FOREIGN KEY (address_id) REFERENCES public.mstr_hospital_address(id);


--
-- TOC entry 8583 (class 2606 OID 27690484)
-- Name: mstr_nudge fk_mstr_nugget_org; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge
    ADD CONSTRAINT fk_mstr_nugget_org FOREIGN KEY (org_id) REFERENCES public.organisation(id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- TOC entry 8590 (class 2606 OID 27690489)
-- Name: mstr_policy_hospital_map fk_mstr_policy_hospital_map_hospital; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_hospital_map
    ADD CONSTRAINT fk_mstr_policy_hospital_map_hospital FOREIGN KEY (hospital_id) REFERENCES public.mstr_hospital(id);


--
-- TOC entry 8591 (class 2606 OID 27690494)
-- Name: mstr_policy_hospital_map fk_mstr_policy_hospital_map_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_policy_hospital_map
    ADD CONSTRAINT fk_mstr_policy_hospital_map_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8595 (class 2606 OID 27690499)
-- Name: note fk_note_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note
    ADD CONSTRAINT fk_note_activity FOREIGN KEY (activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8596 (class 2606 OID 27690504)
-- Name: note fk_note_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note
    ADD CONSTRAINT fk_note_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8598 (class 2606 OID 27690509)
-- Name: note_document_map fk_note_document_map_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note_document_map
    ADD CONSTRAINT fk_note_document_map_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8599 (class 2606 OID 27690514)
-- Name: note_document_map fk_note_document_map_note; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note_document_map
    ADD CONSTRAINT fk_note_document_map_note FOREIGN KEY (note_id) REFERENCES public.note(id);


--
-- TOC entry 8597 (class 2606 OID 27690519)
-- Name: note fk_note_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.note
    ADD CONSTRAINT fk_note_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8600 (class 2606 OID 27690524)
-- Name: notification_channel_event_template_mapping fk_notification_channel_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_channel_event_template_mapping
    ADD CONSTRAINT fk_notification_channel_type FOREIGN KEY (channel_type_id) REFERENCES public.notification_channel_type(id);


--
-- TOC entry 8602 (class 2606 OID 27690529)
-- Name: notification_event_template_mapping fk_notification_event_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_template_mapping
    ADD CONSTRAINT fk_notification_event_type FOREIGN KEY (event_type_id) REFERENCES public.notification_event_type(id);


--
-- TOC entry 8601 (class 2606 OID 27690534)
-- Name: notification_channel_event_template_mapping fk_notification_event_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_channel_event_template_mapping
    ADD CONSTRAINT fk_notification_event_type FOREIGN KEY (event_type_id) REFERENCES public.notification_event_type(id);


--
-- TOC entry 8604 (class 2606 OID 27690539)
-- Name: notification_in_app fk_notification_in_app_event_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_in_app
    ADD CONSTRAINT fk_notification_in_app_event_type FOREIGN KEY (event_type_id) REFERENCES public.notification_event_type(id);


--
-- TOC entry 8605 (class 2606 OID 27690629)
-- Name: notification_log fk_notification_log_event_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_log
    ADD CONSTRAINT fk_notification_log_event_type FOREIGN KEY (event_type_id) REFERENCES public.notification_event_type(id);


--
-- TOC entry 8606 (class 2606 OID 27690673)
-- Name: notification_log_receiver_record fk_notification_log_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_log_receiver_record
    ADD CONSTRAINT fk_notification_log_id FOREIGN KEY (log_id) REFERENCES public.notification_log(id);


--
-- TOC entry 8603 (class 2606 OID 27690689)
-- Name: notification_event_template_mapping fk_notification_template; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_event_template_mapping
    ADD CONSTRAINT fk_notification_template FOREIGN KEY (template_id) REFERENCES public.notification_template(id);


--
-- TOC entry 8663 (class 2606 OID 27690694)
-- Name: opportunity_mandate_details_entry fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_entry
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8731 (class 2606 OID 27690699)
-- Name: opportunity_rfp_details_entry fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_details_entry
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8745 (class 2606 OID 27690704)
-- Name: policy fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8712 (class 2606 OID 27690709)
-- Name: opportunity_previous_placement_details fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_placement_details
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8711 (class 2606 OID 27690714)
-- Name: opportunity_previous_mediator_details fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_previous_mediator_details
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8626 (class 2606 OID 27690719)
-- Name: opportunity_contact_map fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_contact_map
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8613 (class 2606 OID 27690726)
-- Name: opportunity_activity_participants fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_activity_participants
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8645 (class 2606 OID 27690731)
-- Name: opportunity_held_cover_note fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8719 (class 2606 OID 27690736)
-- Name: opportunity_quote_entry fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_entry
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8676 (class 2606 OID 27690741)
-- Name: opportunity_policy_confirmation fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8730 (class 2606 OID 27690746)
-- Name: opportunity_rfp_detail fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_detail
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8685 (class 2606 OID 27690751)
-- Name: opportunity_policy_docket fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8692 (class 2606 OID 27690756)
-- Name: opportunity_policy_hard_copy fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8702 (class 2606 OID 27690761)
-- Name: opportunity_premium_calculation fk_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation
    ADD CONSTRAINT fk_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8732 (class 2606 OID 27690766)
-- Name: opportunity_rfp_details_entry fk_opportunity_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_details_entry
    ADD CONSTRAINT fk_opportunity_activity FOREIGN KEY (opportunity_activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8723 (class 2606 OID 27690771)
-- Name: opportunity_rfp_activity_document_map fk_opportunity_activity_map; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_activity_document_map
    ADD CONSTRAINT fk_opportunity_activity_map FOREIGN KEY (opportunity_activity_map_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8706 (class 2606 OID 27690776)
-- Name: opportunity_premium_calculation_document_map fk_opportunity_activity_map; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation_document_map
    ADD CONSTRAINT fk_opportunity_activity_map FOREIGN KEY (opportunity_activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8616 (class 2606 OID 27690781)
-- Name: opportunity_broking_slip_activity_document_map fk_opportunity_activity_map; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_activity_document_map
    ADD CONSTRAINT fk_opportunity_activity_map FOREIGN KEY (opportunity_activity_map_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8622 (class 2606 OID 27690786)
-- Name: opportunity_challenges fk_opportunity_challenges; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_challenges
    ADD CONSTRAINT fk_opportunity_challenges FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8623 (class 2606 OID 27690791)
-- Name: opportunity_claim_experience fk_opportunity_claim_experience; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_claim_experience
    ADD CONSTRAINT fk_opportunity_claim_experience FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8624 (class 2606 OID 27690796)
-- Name: opportunity_competitor fk_opportunity_competitor; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_competitor
    ADD CONSTRAINT fk_opportunity_competitor FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8617 (class 2606 OID 27690801)
-- Name: opportunity_broking_slip_activity_document_map fk_opportunity_detail; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_activity_document_map
    ADD CONSTRAINT fk_opportunity_detail FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8630 (class 2606 OID 27690806)
-- Name: opportunity_document_map fk_opportunity_document_map_document_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_document_map
    ADD CONSTRAINT fk_opportunity_document_map_document_id FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8631 (class 2606 OID 27690811)
-- Name: opportunity_document_map fk_opportunity_document_map_opportunity_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_document_map
    ADD CONSTRAINT fk_opportunity_document_map_opportunity_id FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8642 (class 2606 OID 27690816)
-- Name: opportunity_hand_over_meet fk_opportunity_hand_over_meet; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_hand_over_meet
    ADD CONSTRAINT fk_opportunity_hand_over_meet FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8643 (class 2606 OID 27690821)
-- Name: opportunity_hand_over_meet fk_opportunity_hand_over_meet_meeting; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_hand_over_meet
    ADD CONSTRAINT fk_opportunity_hand_over_meet_meeting FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8618 (class 2606 OID 27690826)
-- Name: opportunity_broking_slip_document_map_details fk_opportunity_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_document_map_details
    ADD CONSTRAINT fk_opportunity_id FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8664 (class 2606 OID 27690831)
-- Name: opportunity_meeting_document_map fk_opportunity_meeting_document_map_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_meeting_document_map
    ADD CONSTRAINT fk_opportunity_meeting_document_map_activity FOREIGN KEY (opportunity_activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8665 (class 2606 OID 27690836)
-- Name: opportunity_meeting_document_map fk_opportunity_meeting_document_map_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_meeting_document_map
    ADD CONSTRAINT fk_opportunity_meeting_document_map_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8666 (class 2606 OID 27690841)
-- Name: opportunity_meeting_participant_map fk_opportunity_meeting_participant_map_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_meeting_participant_map
    ADD CONSTRAINT fk_opportunity_meeting_participant_map_activity FOREIGN KEY (opportunity_activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8707 (class 2606 OID 27690846)
-- Name: opportunity_premium_cover_detail fk_opportunity_premium_cover_detail_cover_map; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_cover_detail
    ADD CONSTRAINT fk_opportunity_premium_cover_detail_cover_map FOREIGN KEY (cover_map_id) REFERENCES public.opportunity_cover_map(id);


--
-- TOC entry 8708 (class 2606 OID 27690852)
-- Name: opportunity_premium_cover_detail fk_opportunity_premium_cover_detail_opportunity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_cover_detail
    ADD CONSTRAINT fk_opportunity_premium_cover_detail_opportunity FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8736 (class 2606 OID 27690857)
-- Name: opportunity_risk_location_map fk_opportunity_risk_location_map_addr; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_risk_location_map
    ADD CONSTRAINT fk_opportunity_risk_location_map_addr FOREIGN KEY (address_id) REFERENCES public.address(id);


--
-- TOC entry 8737 (class 2606 OID 27690862)
-- Name: opportunity_risk_location_map fk_opportunity_risk_location_map_opp; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_risk_location_map
    ADD CONSTRAINT fk_opportunity_risk_location_map_opp FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8609 (class 2606 OID 27690867)
-- Name: opportunity fk_opportunity_type_lid; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity
    ADD CONSTRAINT fk_opportunity_type_lid FOREIGN KEY (opportunity_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8619 (class 2606 OID 27690875)
-- Name: opportunity_broking_slip_version_cover_map_details fk_opty_broking_slip_version_cover_map_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_version_cover_map_details
    ADD CONSTRAINT fk_opty_broking_slip_version_cover_map_id FOREIGN KEY (cover_map_id) REFERENCES public.opportunity_cover_map(id);


--
-- TOC entry 8620 (class 2606 OID 27690883)
-- Name: opportunity_broking_slip_version_cover_map_details fk_opty_broking_slip_version_cover_map_opty_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_broking_slip_version_cover_map_details
    ADD CONSTRAINT fk_opty_broking_slip_version_cover_map_opty_id FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8612 (class 2606 OID 27690888)
-- Name: opportunity_activity_map fk_opty_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_activity_map
    ADD CONSTRAINT fk_opty_id FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8738 (class 2606 OID 27690893)
-- Name: org_branch fk_org_branch_organisation; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_branch
    ADD CONSTRAINT fk_org_branch_organisation FOREIGN KEY (organisation_id) REFERENCES public.organisation(id);


--
-- TOC entry 8537 (class 2606 OID 27690898)
-- Name: org_department fk_org_department_vertical; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_department
    ADD CONSTRAINT fk_org_department_vertical FOREIGN KEY (vertical_id) REFERENCES public.org_vertical(id);


--
-- TOC entry 8739 (class 2606 OID 27690903)
-- Name: org_sbu fk_org_sbu_organisation_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_sbu
    ADD CONSTRAINT fk_org_sbu_organisation_id FOREIGN KEY (organisation_id) REFERENCES public.organisation(id);


--
-- TOC entry 8742 (class 2606 OID 27690908)
-- Name: org_vertical fk_org_vertical_organisation; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_vertical
    ADD CONSTRAINT fk_org_vertical_organisation FOREIGN KEY (organisation_id) REFERENCES public.organisation(id);


--
-- TOC entry 8743 (class 2606 OID 27690913)
-- Name: organisation fk_organisation_country; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.organisation
    ADD CONSTRAINT fk_organisation_country FOREIGN KEY (country_id) REFERENCES public.country(id) NOT VALID;


--
-- TOC entry 8614 (class 2606 OID 27690918)
-- Name: opportunity_activity_participants fk_participant; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_activity_participants
    ADD CONSTRAINT fk_participant FOREIGN KEY (participant_id) REFERENCES public.users(id);


--
-- TOC entry 8783 (class 2606 OID 27690923)
-- Name: policy_participant_map fk_participant; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_participant_map
    ADD CONSTRAINT fk_participant FOREIGN KEY (participant_id) REFERENCES public.users(id);


--
-- TOC entry 8528 (class 2606 OID 27690928)
-- Name: company_rule_mapping fk_password_rule; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.company_rule_mapping
    ADD CONSTRAINT fk_password_rule FOREIGN KEY (rule_id) REFERENCES public.password_rules(id) ON DELETE CASCADE;


--
-- TOC entry 8767 (class 2606 OID 27690933)
-- Name: policy_endorsement_template_doc_map fk_petdm_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_endorsement_template_doc_map
    ADD CONSTRAINT fk_petdm_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8775 (class 2606 OID 27690938)
-- Name: policy_enrollment_template_doc_map fk_petdm_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_template_doc_map
    ADD CONSTRAINT fk_petdm_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8768 (class 2606 OID 27690943)
-- Name: policy_endorsement_template_doc_map fk_petdm_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_endorsement_template_doc_map
    ADD CONSTRAINT fk_petdm_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8769 (class 2606 OID 27690948)
-- Name: policy_endorsement_template_doc_map fk_petdm_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_endorsement_template_doc_map
    ADD CONSTRAINT fk_petdm_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8776 (class 2606 OID 27690953)
-- Name: policy_enrollment_template_doc_map fk_petdm_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_template_doc_map
    ADD CONSTRAINT fk_petdm_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8646 (class 2606 OID 27690958)
-- Name: opportunity_held_cover_note fk_placement_slip_deviations; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note
    ADD CONSTRAINT fk_placement_slip_deviations FOREIGN KEY (placement_slip_deviations_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8784 (class 2606 OID 27690963)
-- Name: policy_participant_map fk_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_participant_map
    ADD CONSTRAINT fk_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8787 (class 2606 OID 27690968)
-- Name: policy_risk_location_map fk_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_risk_location_map
    ADD CONSTRAINT fk_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8758 (class 2606 OID 27690973)
-- Name: policy_configuration_component_relation_map fk_policy_config_component_relation_map_detail_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_component_relation_map
    ADD CONSTRAINT fk_policy_config_component_relation_map_detail_id FOREIGN KEY (policy_configuration_component_detail_id) REFERENCES public.policy_configuration_components_detail(id) ON DELETE CASCADE;


--
-- TOC entry 8760 (class 2606 OID 27690978)
-- Name: policy_configuration_components_detail fk_policy_configuration_components_detail_club_sum_insured_lid; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_components_detail
    ADD CONSTRAINT fk_policy_configuration_components_detail_club_sum_insured_lid FOREIGN KEY (club_sum_insured_lid) REFERENCES public.lookup_data(id) ON DELETE SET NULL;


--
-- TOC entry 8755 (class 2606 OID 27690983)
-- Name: policy_configuration fk_policy_configuration_status_lid; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration
    ADD CONSTRAINT fk_policy_configuration_status_lid FOREIGN KEY (policy_configuration_status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8682 (class 2606 OID 27690988)
-- Name: opportunity_policy_confirmation_document_map fk_policy_confirmation; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_document_map
    ADD CONSTRAINT fk_policy_confirmation FOREIGN KEY (policy_confirmation_id) REFERENCES public.opportunity_policy_confirmation(id);


--
-- TOC entry 8683 (class 2606 OID 27690993)
-- Name: opportunity_policy_confirmation_insurer_map fk_policy_confirmation; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_insurer_map
    ADD CONSTRAINT fk_policy_confirmation FOREIGN KEY (policy_confirmation_id) REFERENCES public.opportunity_policy_confirmation(id);


--
-- TOC entry 8684 (class 2606 OID 27690998)
-- Name: opportunity_policy_confirmation_insurer_map fk_policy_confirmation_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation_insurer_map
    ADD CONSTRAINT fk_policy_confirmation_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8677 (class 2606 OID 27691003)
-- Name: opportunity_policy_confirmation fk_policy_data_reflected; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation
    ADD CONSTRAINT fk_policy_data_reflected FOREIGN KEY (policy_data_rectified_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8678 (class 2606 OID 27691008)
-- Name: opportunity_policy_confirmation fk_policy_data_wrong; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation
    ADD CONSTRAINT fk_policy_data_wrong FOREIGN KEY (policy_data_wrong_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8688 (class 2606 OID 27691013)
-- Name: opportunity_policy_docket_document_map fk_policy_docket; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket_document_map
    ADD CONSTRAINT fk_policy_docket FOREIGN KEY (policy_docket_id) REFERENCES public.opportunity_policy_docket(id);


--
-- TOC entry 8699 (class 2606 OID 27691018)
-- Name: opportunity_policy_hard_copy_document_map fk_policy_hard_copy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_document_map
    ADD CONSTRAINT fk_policy_hard_copy FOREIGN KEY (policy_hard_copy_id) REFERENCES public.opportunity_policy_hard_copy(id);


--
-- TOC entry 8696 (class 2606 OID 27691023)
-- Name: opportunity_policy_hard_copy_cover_detail fk_policy_hard_copy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_cover_detail
    ADD CONSTRAINT fk_policy_hard_copy FOREIGN KEY (policy_hard_copy_id) REFERENCES public.opportunity_policy_hard_copy(id);


--
-- TOC entry 8700 (class 2606 OID 27691028)
-- Name: opportunity_policy_hard_copy_insurer_map fk_policy_hard_copy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_insurer_map
    ADD CONSTRAINT fk_policy_hard_copy FOREIGN KEY (policy_hard_copy_id) REFERENCES public.opportunity_policy_hard_copy(id);


--
-- TOC entry 8701 (class 2606 OID 27691033)
-- Name: opportunity_policy_hard_copy_insurer_map fk_policy_hard_copy_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy_insurer_map
    ADD CONSTRAINT fk_policy_hard_copy_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8693 (class 2606 OID 27691038)
-- Name: opportunity_policy_hard_copy fk_policy_hard_copy_received; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT fk_policy_hard_copy_received FOREIGN KEY (policy_hard_copy_received_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8756 (class 2606 OID 27691043)
-- Name: policy_configuration fk_policy_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration
    ADD CONSTRAINT fk_policy_id FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8761 (class 2606 OID 27691048)
-- Name: policy_configuration_components_detail fk_policy_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_components_detail
    ADD CONSTRAINT fk_policy_id FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8762 (class 2606 OID 27691053)
-- Name: policy_configuration_template_doc_map fk_policy_template_doc_map_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_template_doc_map
    ADD CONSTRAINT fk_policy_template_doc_map_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8763 (class 2606 OID 27691058)
-- Name: policy_configuration_template_doc_map fk_policy_template_doc_map_policy; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration_template_doc_map
    ADD CONSTRAINT fk_policy_template_doc_map_policy FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8757 (class 2606 OID 27691063)
-- Name: policy_configuration fk_policy_type_lid; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_configuration
    ADD CONSTRAINT fk_policy_type_lid FOREIGN KEY (policy_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8789 (class 2606 OID 27691068)
-- Name: policy_type_segregation fk_policy_type_segregation_assc_plc_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_segregation
    ADD CONSTRAINT fk_policy_type_segregation_assc_plc_type FOREIGN KEY (assoc_active_policy_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8790 (class 2606 OID 27691073)
-- Name: policy_type_segregation fk_policy_type_segregation_iirm; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_segregation
    ADD CONSTRAINT fk_policy_type_segregation_iirm FOREIGN KEY (iirm_policy_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8791 (class 2606 OID 27691078)
-- Name: policy_type_segregation fk_policy_type_segregation_irdai; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_segregation
    ADD CONSTRAINT fk_policy_type_segregation_irdai FOREIGN KEY (irdai_policy_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8792 (class 2606 OID 27691083)
-- Name: policy_type_segregation fk_policy_type_segregation_policy_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_type_segregation
    ADD CONSTRAINT fk_policy_type_segregation_policy_type FOREIGN KEY (policy_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8505 (class 2606 OID 27691088)
-- Name: brokingslip_version_preferred_insurer_detail fk_preferred_insurer_details_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_insurer_detail
    ADD CONSTRAINT fk_preferred_insurer_details_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8506 (class 2606 OID 27691093)
-- Name: brokingslip_version_preferred_insurer_detail fk_preferred_insurer_details_insurer; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_insurer_detail
    ADD CONSTRAINT fk_preferred_insurer_details_insurer FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8507 (class 2606 OID 27691098)
-- Name: brokingslip_version_preferred_tpa_detail fk_preferred_tpa_details_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_tpa_detail
    ADD CONSTRAINT fk_preferred_tpa_details_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8508 (class 2606 OID 27691103)
-- Name: brokingslip_version_preferred_tpa_detail fk_preferred_tpa_details_tpa; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.brokingslip_version_preferred_tpa_detail
    ADD CONSTRAINT fk_preferred_tpa_details_tpa FOREIGN KEY (tpa_id) REFERENCES public.tpa(id);


--
-- TOC entry 8793 (class 2606 OID 27691108)
-- Name: professional_experience fk_professional_experience_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.professional_experience
    ADD CONSTRAINT fk_professional_experience_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8794 (class 2606 OID 27691113)
-- Name: qualification_experience fk_qualification_experience_contact; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.qualification_experience
    ADD CONSTRAINT fk_qualification_experience_contact FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8647 (class 2606 OID 27691118)
-- Name: opportunity_held_cover_note fk_resolution; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note
    ADD CONSTRAINT fk_resolution FOREIGN KEY (resolution_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8679 (class 2606 OID 27691123)
-- Name: opportunity_policy_confirmation fk_resolution; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation
    ADD CONSTRAINT fk_resolution FOREIGN KEY (resolution_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8694 (class 2606 OID 27691128)
-- Name: opportunity_policy_hard_copy fk_resolution; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT fk_resolution FOREIGN KEY (resolution_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8648 (class 2606 OID 27691133)
-- Name: opportunity_held_cover_note fk_revised_held_cover_note; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note
    ADD CONSTRAINT fk_revised_held_cover_note FOREIGN KEY (revised_held_cover_note_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8724 (class 2606 OID 27691138)
-- Name: opportunity_rfp_activity_document_map fk_rfp_detail; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_activity_document_map
    ADD CONSTRAINT fk_rfp_detail FOREIGN KEY (rfp_detail_id) REFERENCES public.opportunity_rfp_detail(id);


--
-- TOC entry 8735 (class 2606 OID 27691143)
-- Name: opportunity_rfp_tpa_detail fk_rfp_details; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_tpa_detail
    ADD CONSTRAINT fk_rfp_details FOREIGN KEY (opportunity_rfp_details_entry_id) REFERENCES public.opportunity_rfp_details_entry(id);


--
-- TOC entry 8734 (class 2606 OID 27691148)
-- Name: opportunity_rfp_insurer_detail fk_rfp_details; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_insurer_detail
    ADD CONSTRAINT fk_rfp_details FOREIGN KEY (opportunity_rfp_details_entry_id) REFERENCES public.opportunity_rfp_details_entry(id);


--
-- TOC entry 8725 (class 2606 OID 27691153)
-- Name: opportunity_rfp_client_contact_detail fk_rfp_details; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_client_contact_detail
    ADD CONSTRAINT fk_rfp_details FOREIGN KEY (opportunity_rfp_details_entry_id) REFERENCES public.opportunity_rfp_details_entry(id);


--
-- TOC entry 8729 (class 2606 OID 27691158)
-- Name: opportunity_rfp_credit_sharing fk_rfp_details; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_credit_sharing
    ADD CONSTRAINT fk_rfp_details FOREIGN KEY (opportunity_rfp_details_entry_id) REFERENCES public.opportunity_rfp_details_entry(id);


--
-- TOC entry 8733 (class 2606 OID 27691163)
-- Name: opportunity_rfp_details_entry_document_map fk_rfp_details; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_details_entry_document_map
    ADD CONSTRAINT fk_rfp_details FOREIGN KEY (opportunity_rfp_details_entry_id) REFERENCES public.opportunity_rfp_details_entry(id);


--
-- TOC entry 8795 (class 2606 OID 27691168)
-- Name: role_acl_category_action_map fk_role_acl_category_action_map_acl_category_action_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.role_acl_category_action_map
    ADD CONSTRAINT fk_role_acl_category_action_map_acl_category_action_id FOREIGN KEY (acl_category_action_id) REFERENCES public.acl_category_action_map(id);


--
-- TOC entry 8796 (class 2606 OID 27691173)
-- Name: role_acl_category_action_map fk_role_acl_category_action_map_role_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.role_acl_category_action_map
    ADD CONSTRAINT fk_role_acl_category_action_map_role_id FOREIGN KEY (role_id) REFERENCES public.roles(id);


--
-- TOC entry 8610 (class 2606 OID 27691178)
-- Name: opportunity fk_source_type_lid; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity
    ADD CONSTRAINT fk_source_type_lid FOREIGN KEY (source_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8593 (class 2606 OID 27691183)
-- Name: mstr_stage_activity_template fk_stage_activity_template_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_stage_activity_template
    ADD CONSTRAINT fk_stage_activity_template_activity FOREIGN KEY (activity_id) REFERENCES public.mstr_activity(id);


--
-- TOC entry 8594 (class 2606 OID 27691188)
-- Name: mstr_stage_activity_template fk_stage_activity_template_stage; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_stage_activity_template
    ADD CONSTRAINT fk_stage_activity_template_stage FOREIGN KEY (stage_id) REFERENCES public.mstr_stage(id);


--
-- TOC entry 8799 (class 2606 OID 27691193)
-- Name: state fk_state_country; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state
    ADD CONSTRAINT fk_state_country FOREIGN KEY (country_id) REFERENCES public.country(id);


--
-- TOC entry 8525 (class 2606 OID 27691198)
-- Name: state_gst_detail fk_state_gst_detail_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.state_gst_detail
    ADD CONSTRAINT fk_state_gst_detail_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8649 (class 2606 OID 27691203)
-- Name: opportunity_held_cover_note fk_status; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_held_cover_note
    ADD CONSTRAINT fk_status FOREIGN KEY (status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8680 (class 2606 OID 27691208)
-- Name: opportunity_policy_confirmation fk_status; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_confirmation
    ADD CONSTRAINT fk_status FOREIGN KEY (status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8686 (class 2606 OID 27691213)
-- Name: opportunity_policy_docket fk_status; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_docket
    ADD CONSTRAINT fk_status FOREIGN KEY (status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8695 (class 2606 OID 27691218)
-- Name: opportunity_policy_hard_copy fk_status; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_policy_hard_copy
    ADD CONSTRAINT fk_status FOREIGN KEY (status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8703 (class 2606 OID 27691223)
-- Name: opportunity_premium_calculation fk_status_type; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_premium_calculation
    ADD CONSTRAINT fk_status_type FOREIGN KEY (status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8800 (class 2606 OID 27691228)
-- Name: task fk_task_activity; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task
    ADD CONSTRAINT fk_task_activity FOREIGN KEY (activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8801 (class 2606 OID 27691233)
-- Name: task fk_task_assignee; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task
    ADD CONSTRAINT fk_task_assignee FOREIGN KEY (assignee_id) REFERENCES public.users(id);


--
-- TOC entry 8802 (class 2606 OID 27691238)
-- Name: task fk_task_company; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task
    ADD CONSTRAINT fk_task_company FOREIGN KEY (company_id) REFERENCES public.company(id);


--
-- TOC entry 8803 (class 2606 OID 27691243)
-- Name: task_document_map fk_task_document_map_document; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task_document_map
    ADD CONSTRAINT fk_task_document_map_document FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8804 (class 2606 OID 27691248)
-- Name: task_document_map fk_task_document_map_task; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.task_document_map
    ADD CONSTRAINT fk_task_document_map_task FOREIGN KEY (task_id) REFERENCES public.task(id);


--
-- TOC entry 8629 (class 2606 OID 27691253)
-- Name: opportunity_data_validation_document_map fk_task_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_data_validation_document_map
    ADD CONSTRAINT fk_task_id FOREIGN KEY (task_id) REFERENCES public.task(id);


--
-- TOC entry 8627 (class 2606 OID 27691258)
-- Name: opportunity_data_validation fk_task_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_data_validation
    ADD CONSTRAINT fk_task_id FOREIGN KEY (task_id) REFERENCES public.task(id);


--
-- TOC entry 8805 (class 2606 OID 27691263)
-- Name: tpa_address fk_tpa_address_address_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_address
    ADD CONSTRAINT fk_tpa_address_address_id FOREIGN KEY (address_id) REFERENCES public.address(id);


--
-- TOC entry 8806 (class 2606 OID 27691268)
-- Name: tpa_address fk_tpa_address_tpa_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_address
    ADD CONSTRAINT fk_tpa_address_tpa_id FOREIGN KEY (tpa_id) REFERENCES public.tpa(id);


--
-- TOC entry 8807 (class 2606 OID 27691273)
-- Name: tpa_contact fk_tpa_contact_contact_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_contact
    ADD CONSTRAINT fk_tpa_contact_contact_id FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8808 (class 2606 OID 27691278)
-- Name: tpa_contact fk_tpa_contact_tpa_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.tpa_contact
    ADD CONSTRAINT fk_tpa_contact_tpa_id FOREIGN KEY (tpa_id) REFERENCES public.tpa(id);


--
-- TOC entry 8607 (class 2606 OID 27691283)
-- Name: notification_log_receiver_record fk_user_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.notification_log_receiver_record
    ADD CONSTRAINT fk_user_id FOREIGN KEY (receiver_user_id) REFERENCES public.users(id) NOT VALID;


--
-- TOC entry 8809 (class 2606 OID 27691288)
-- Name: user_role fk_user_role_role_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.user_role
    ADD CONSTRAINT fk_user_role_role_id FOREIGN KEY (role_id) REFERENCES public.roles(id);


--
-- TOC entry 8810 (class 2606 OID 27691293)
-- Name: user_role fk_user_role_user_id; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.user_role
    ADD CONSTRAINT fk_user_role_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- TOC entry 8566 (class 2606 OID 27691298)
-- Name: localization_regulatory_fields_country_map localization_regulatory_fields_country_m_regulatory_key_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_regulatory_fields_country_map
    ADD CONSTRAINT localization_regulatory_fields_country_m_regulatory_key_id_fkey FOREIGN KEY (regulatory_key_id) REFERENCES public.localization_company_regulatory_fields(id);


--
-- TOC entry 8567 (class 2606 OID 27691303)
-- Name: localization_regulatory_fields_country_map localization_regulatory_fields_country_map_country_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_regulatory_fields_country_map
    ADD CONSTRAINT localization_regulatory_fields_country_map_country_id_fkey FOREIGN KEY (country_id) REFERENCES public.localization_country(id);


--
-- TOC entry 8568 (class 2606 OID 27691308)
-- Name: localization_report_fields_country_map localization_report_fields_country_map_country_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_report_fields_country_map
    ADD CONSTRAINT localization_report_fields_country_map_country_id_fkey FOREIGN KEY (country_id) REFERENCES public.localization_country(id);


--
-- TOC entry 8569 (class 2606 OID 27691313)
-- Name: localization_report_fields_country_map localization_report_fields_country_map_regulatory_key_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.localization_report_fields_country_map
    ADD CONSTRAINT localization_report_fields_country_map_regulatory_key_id_fkey FOREIGN KEY (regulatory_key_id) REFERENCES public.localization_report_fields(id);


--
-- TOC entry 8654 (class 2606 OID 27691318)
-- Name: opportunity_mandate_details_contact_map mandate_details_contact_map_contact_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_contact_map
    ADD CONSTRAINT mandate_details_contact_map_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES public.contact(id);


--
-- TOC entry 8655 (class 2606 OID 27691323)
-- Name: opportunity_mandate_details_contact_map mandate_details_contact_map_mandate_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_mandate_details_contact_map
    ADD CONSTRAINT mandate_details_contact_map_mandate_id_fkey FOREIGN KEY (mandate_id) REFERENCES public.opportunity_mandate_details_entry(id);


--
-- TOC entry 8584 (class 2606 OID 27691328)
-- Name: mstr_nudge_action mstr_nudge_action_nudge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_action
    ADD CONSTRAINT mstr_nudge_action_nudge_id_fkey FOREIGN KEY (nudge_id) REFERENCES public.mstr_nudge(id);


--
-- TOC entry 8585 (class 2606 OID 27691333)
-- Name: mstr_nudge_parameters mstr_nudge_parameters_nudge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_parameters
    ADD CONSTRAINT mstr_nudge_parameters_nudge_id_fkey FOREIGN KEY (nudge_id) REFERENCES public.mstr_nudge(id);


--
-- TOC entry 8586 (class 2606 OID 27691338)
-- Name: mstr_nudge_scope_role_mapping mstr_nudge_scope_role_mapping_nudge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_scope_role_mapping
    ADD CONSTRAINT mstr_nudge_scope_role_mapping_nudge_id_fkey FOREIGN KEY (nudge_id) REFERENCES public.mstr_nudge(id);


--
-- TOC entry 8587 (class 2606 OID 27691343)
-- Name: mstr_nudge_scope_role_mapping mstr_nudge_scope_role_mapping_scope_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_nudge_scope_role_mapping
    ADD CONSTRAINT mstr_nudge_scope_role_mapping_scope_id_fkey FOREIGN KEY (scope_id) REFERENCES public.mstr_nudge_scope(id);


--
-- TOC entry 8588 (class 2606 OID 27691348)
-- Name: mstr_org_service_weightage mstr_org_service_weightage_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.mstr_org_service_weightage
    ADD CONSTRAINT mstr_org_service_weightage_service_id_fkey FOREIGN KEY (service_id) REFERENCES public.mstr_service(id);


--
-- TOC entry 8637 (class 2606 OID 27691353)
-- Name: opportunity_final_negotiation_qcr_variation opportunity_final_negotiatio_opportunity_final_negotiatio_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_qcr_variation
    ADD CONSTRAINT opportunity_final_negotiatio_opportunity_final_negotiatio_fkey1 FOREIGN KEY (opportunity_final_negotiation_id) REFERENCES public.opportunity_final_negotiation(id);


--
-- TOC entry 8638 (class 2606 OID 27691358)
-- Name: opportunity_final_negotiation_service_level_agreement opportunity_final_negotiatio_opportunity_final_negotiatio_fkey2; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_service_level_agreement
    ADD CONSTRAINT opportunity_final_negotiatio_opportunity_final_negotiatio_fkey2 FOREIGN KEY (opportunity_final_negotiation_id) REFERENCES public.opportunity_final_negotiation(id);


--
-- TOC entry 8635 (class 2606 OID 27691363)
-- Name: opportunity_final_negotiation_doc_map opportunity_final_negotiatio_opportunity_final_negotiatio_fkey3; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_doc_map
    ADD CONSTRAINT opportunity_final_negotiatio_opportunity_final_negotiatio_fkey3 FOREIGN KEY (opportunity_final_negotiation_id) REFERENCES public.opportunity_final_negotiation(id);


--
-- TOC entry 8641 (class 2606 OID 27691368)
-- Name: opportunity_final_negotiation_tax_map opportunity_final_negotiatio_opportunity_final_negotiatio_fkey4; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_tax_map
    ADD CONSTRAINT opportunity_final_negotiatio_opportunity_final_negotiatio_fkey4 FOREIGN KEY (opportunity_final_negotiation_id) REFERENCES public.opportunity_final_negotiation(id);


--
-- TOC entry 8636 (class 2606 OID 27691373)
-- Name: opportunity_final_negotiation_doc_map opportunity_final_negotiation_doc_map_document_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_doc_map
    ADD CONSTRAINT opportunity_final_negotiation_doc_map_document_id_fkey FOREIGN KEY (document_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8632 (class 2606 OID 27691378)
-- Name: opportunity_final_negotiation opportunity_final_negotiation_finalized_quote_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation
    ADD CONSTRAINT opportunity_final_negotiation_finalized_quote_id_fkey FOREIGN KEY (finalized_quote_id) REFERENCES public.opportunity_quote_entry(id);


--
-- TOC entry 8633 (class 2606 OID 27691383)
-- Name: opportunity_final_negotiation opportunity_final_negotiation_lead_insurer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation
    ADD CONSTRAINT opportunity_final_negotiation_lead_insurer_id_fkey FOREIGN KEY (lead_insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8634 (class 2606 OID 27691388)
-- Name: opportunity_final_negotiation opportunity_final_negotiation_meeting_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation
    ADD CONSTRAINT opportunity_final_negotiation_meeting_id_fkey FOREIGN KEY (meeting_id) REFERENCES public.meeting(id);


--
-- TOC entry 8639 (class 2606 OID 27691393)
-- Name: opportunity_final_negotiation_sharing_detail opportunity_final_negotiation_opportunity_final_negotiatio_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_sharing_detail
    ADD CONSTRAINT opportunity_final_negotiation_opportunity_final_negotiatio_fkey FOREIGN KEY (opportunity_final_negotiation_id) REFERENCES public.opportunity_final_negotiation(id);


--
-- TOC entry 8640 (class 2606 OID 27691398)
-- Name: opportunity_final_negotiation_sharing_detail opportunity_final_negotiation_sharing_detail_insurer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_final_negotiation_sharing_detail
    ADD CONSTRAINT opportunity_final_negotiation_sharing_detail_insurer_id_fkey FOREIGN KEY (insurer_id) REFERENCES public.insurer(id);


--
-- TOC entry 8667 (class 2606 OID 27691403)
-- Name: opportunity_placement_slip_cd_detail opportunity_placement_slip_cd_detail_placement_slip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_cd_detail
    ADD CONSTRAINT opportunity_placement_slip_cd_detail_placement_slip_id_fkey FOREIGN KEY (placement_slip_id) REFERENCES public.opportunity_placement_slip_generation(id);


--
-- TOC entry 8668 (class 2606 OID 27691408)
-- Name: opportunity_placement_slip_cover_detail opportunity_placement_slip_cover_detail_placement_slip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_cover_detail
    ADD CONSTRAINT opportunity_placement_slip_cover_detail_placement_slip_id_fkey FOREIGN KEY (placement_slip_id) REFERENCES public.opportunity_placement_slip_generation(id);


--
-- TOC entry 8669 (class 2606 OID 27691413)
-- Name: opportunity_placement_slip_document_map opportunity_placement_slip_document_map_document_type_lid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_document_map
    ADD CONSTRAINT opportunity_placement_slip_document_map_document_type_lid_fkey FOREIGN KEY (document_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8670 (class 2606 OID 27691418)
-- Name: opportunity_placement_slip_document_map opportunity_placement_slip_document_map_placement_slip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_document_map
    ADD CONSTRAINT opportunity_placement_slip_document_map_placement_slip_id_fkey FOREIGN KEY (placement_slip_id) REFERENCES public.opportunity_placement_slip_generation(id);


--
-- TOC entry 8671 (class 2606 OID 27691423)
-- Name: opportunity_placement_slip_installement_detail opportunity_placement_slip_installement__placement_slip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_installement_detail
    ADD CONSTRAINT opportunity_placement_slip_installement__placement_slip_id_fkey FOREIGN KEY (placement_slip_id) REFERENCES public.opportunity_placement_slip_generation(id);


--
-- TOC entry 8672 (class 2606 OID 27691428)
-- Name: opportunity_placement_slip_insurer_map opportunity_placement_slip_insurer_map_placement_slip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_insurer_map
    ADD CONSTRAINT opportunity_placement_slip_insurer_map_placement_slip_id_fkey FOREIGN KEY (placement_slip_id) REFERENCES public.opportunity_placement_slip_generation(id);


--
-- TOC entry 8673 (class 2606 OID 27691433)
-- Name: opportunity_placement_slip_sharing_detail opportunity_placement_slip_sharing_detai_placement_slip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_sharing_detail
    ADD CONSTRAINT opportunity_placement_slip_sharing_detai_placement_slip_id_fkey FOREIGN KEY (placement_slip_id) REFERENCES public.opportunity_placement_slip_generation(id);


--
-- TOC entry 8674 (class 2606 OID 27691438)
-- Name: opportunity_placement_slip_tpa_map opportunity_placement_slip_tpa_map_placement_slip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_placement_slip_tpa_map
    ADD CONSTRAINT opportunity_placement_slip_tpa_map_placement_slip_id_fkey FOREIGN KEY (placement_slip_id) REFERENCES public.opportunity_placement_slip_generation(id);


--
-- TOC entry 8716 (class 2606 OID 27691443)
-- Name: opportunity_quote_comparison_report_document_map opportunity_quote_comparison_re_quote_comparison_report_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report_document_map
    ADD CONSTRAINT opportunity_quote_comparison_re_quote_comparison_report_id_fkey FOREIGN KEY (quote_comparison_report_id) REFERENCES public.opportunity_quote_comparison_report(id);


--
-- TOC entry 8713 (class 2606 OID 27691448)
-- Name: opportunity_quote_comparison_report opportunity_quote_comparison_repor_opportunity_activity_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report
    ADD CONSTRAINT opportunity_quote_comparison_repor_opportunity_activity_id_fkey FOREIGN KEY (opportunity_activity_id) REFERENCES public.opportunity_activity_map(id);


--
-- TOC entry 8717 (class 2606 OID 27691453)
-- Name: opportunity_quote_comparison_report_document_map opportunity_quote_comparison_report_docu_document_type_lid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report_document_map
    ADD CONSTRAINT opportunity_quote_comparison_report_docu_document_type_lid_fkey FOREIGN KEY (document_type_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8714 (class 2606 OID 27691458)
-- Name: opportunity_quote_comparison_report opportunity_quote_comparison_report_opportunity_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report
    ADD CONSTRAINT opportunity_quote_comparison_report_opportunity_id_fkey FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8715 (class 2606 OID 27691463)
-- Name: opportunity_quote_comparison_report opportunity_quote_comparison_report_status_lid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_comparison_report
    ADD CONSTRAINT opportunity_quote_comparison_report_status_lid_fkey FOREIGN KEY (status_lid) REFERENCES public.lookup_data(id);


--
-- TOC entry 8718 (class 2606 OID 27691468)
-- Name: opportunity_quote_cover_detail opportunity_quote_cover_detail_quote_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_cover_detail
    ADD CONSTRAINT opportunity_quote_cover_detail_quote_id_fkey FOREIGN KEY (quote_id) REFERENCES public.opportunity_quote_entry(id);


--
-- TOC entry 8720 (class 2606 OID 27691473)
-- Name: opportunity_quote_entry_document_map opportunity_quote_entry_documen_opportunity_quote_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_entry_document_map
    ADD CONSTRAINT opportunity_quote_entry_documen_opportunity_quote_entry_id_fkey FOREIGN KEY (opportunity_quote_entry_id) REFERENCES public.opportunity_quote_entry(id);


--
-- TOC entry 8721 (class 2606 OID 27691478)
-- Name: opportunity_quote_tax_map opportunity_quote_tax_map_opportunity_quote_entry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_quote_tax_map
    ADD CONSTRAINT opportunity_quote_tax_map_opportunity_quote_entry_id_fkey FOREIGN KEY (opportunity_quote_entry_id) REFERENCES public.opportunity_quote_entry(id);


--
-- TOC entry 8727 (class 2606 OID 27691483)
-- Name: opportunity_rfp_cover_detail opportunity_rfp_cover_detail_cover_map_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_cover_detail
    ADD CONSTRAINT opportunity_rfp_cover_detail_cover_map_id_fkey FOREIGN KEY (cover_map_id) REFERENCES public.opportunity_cover_map(id);


--
-- TOC entry 8728 (class 2606 OID 27691488)
-- Name: opportunity_rfp_cover_detail opportunity_rfp_cover_detail_opportunity_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.opportunity_rfp_cover_detail
    ADD CONSTRAINT opportunity_rfp_cover_detail_opportunity_id_fkey FOREIGN KEY (opportunity_id) REFERENCES public.opportunity(id);


--
-- TOC entry 8740 (class 2606 OID 27691493)
-- Name: org_service_tat_summary org_service_tat_summary_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_service_tat_summary
    ADD CONSTRAINT org_service_tat_summary_service_id_fkey FOREIGN KEY (service_id) REFERENCES public.mstr_service(id);


--
-- TOC entry 8741 (class 2606 OID 27691498)
-- Name: org_service_tat_summary org_service_tat_summary_tat_bucket_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.org_service_tat_summary
    ADD CONSTRAINT org_service_tat_summary_tat_bucket_id_fkey FOREIGN KEY (tat_bucket_id) REFERENCES public.mstr_tat_bucket(id);


--
-- TOC entry 8747 (class 2606 OID 27691503)
-- Name: policy_cd_number_map policy_cd_number_map_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_cd_number_map
    ADD CONSTRAINT policy_cd_number_map_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8748 (class 2606 OID 27691508)
-- Name: policy_claim policy_claim_dependent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim
    ADD CONSTRAINT policy_claim_dependent_id_fkey FOREIGN KEY (dependent_id) REFERENCES public.policy_enrollment_dependent(id) ON DELETE SET NULL;


--
-- TOC entry 8749 (class 2606 OID 27691513)
-- Name: policy_claim policy_claim_employee_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim
    ADD CONSTRAINT policy_claim_employee_id_fkey FOREIGN KEY (employee_id) REFERENCES public.policy_enrollment_employee(id);


--
-- TOC entry 8750 (class 2606 OID 27691518)
-- Name: policy_claim policy_claim_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim
    ADD CONSTRAINT policy_claim_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8752 (class 2606 OID 27691523)
-- Name: policy_claim_settlement policy_claim_settlement_claim_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim_settlement
    ADD CONSTRAINT policy_claim_settlement_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.policy_claim(id);


--
-- TOC entry 8753 (class 2606 OID 27691528)
-- Name: policy_claim_settlement policy_claim_settlement_source_file_upload_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim_settlement
    ADD CONSTRAINT policy_claim_settlement_source_file_upload_id_fkey FOREIGN KEY (source_file_upload_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8751 (class 2606 OID 27691533)
-- Name: policy_claim policy_claim_source_file_upload_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_claim
    ADD CONSTRAINT policy_claim_source_file_upload_id_fkey FOREIGN KEY (source_file_upload_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8764 (class 2606 OID 27691538)
-- Name: policy_cover_map policy_cover_map_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_cover_map
    ADD CONSTRAINT policy_cover_map_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8765 (class 2606 OID 27691543)
-- Name: policy_employee_enrollment_choice policy_employee_components_employee_enrollment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_employee_enrollment_choice
    ADD CONSTRAINT policy_employee_components_employee_enrollment_id_fkey FOREIGN KEY (employee_enrollment_id) REFERENCES public.policy_employee_enrollment(id);


--
-- TOC entry 8770 (class 2606 OID 27691548)
-- Name: policy_enrollment_dependent policy_enrollment_dependents_employee_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_dependent
    ADD CONSTRAINT policy_enrollment_dependents_employee_id_fkey FOREIGN KEY (employee_id) REFERENCES public.policy_enrollment_employee(id);


--
-- TOC entry 8771 (class 2606 OID 27691553)
-- Name: policy_enrollment_dependent policy_enrollment_dependents_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_dependent
    ADD CONSTRAINT policy_enrollment_dependents_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8773 (class 2606 OID 27691558)
-- Name: policy_enrollment_employee_policy_map policy_enrollment_employee_policy_map_employee_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee_policy_map
    ADD CONSTRAINT policy_enrollment_employee_policy_map_employee_id_fkey FOREIGN KEY (employee_id) REFERENCES public.policy_enrollment_employee(id);


--
-- TOC entry 8774 (class 2606 OID 27691563)
-- Name: policy_enrollment_employee_policy_map policy_enrollment_employee_policy_map_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee_policy_map
    ADD CONSTRAINT policy_enrollment_employee_policy_map_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8772 (class 2606 OID 27691568)
-- Name: policy_enrollment_employee policy_enrollment_employee_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_employee
    ADD CONSTRAINT policy_enrollment_employee_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- TOC entry 8777 (class 2606 OID 27691573)
-- Name: policy_enrollment_upload_summary policy_enrollment_upload_summa_document_processing_file_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_upload_summary
    ADD CONSTRAINT policy_enrollment_upload_summa_document_processing_file_id_fkey FOREIGN KEY (document_processing_file_id) REFERENCES public.document_processing_file(id);


--
-- TOC entry 8778 (class 2606 OID 27691578)
-- Name: policy_enrollment_upload_summary policy_enrollment_upload_summary_error_file_upload_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_upload_summary
    ADD CONSTRAINT policy_enrollment_upload_summary_error_file_upload_id_fkey FOREIGN KEY (error_file_upload_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8779 (class 2606 OID 27691583)
-- Name: policy_enrollment_upload_summary policy_enrollment_upload_summary_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_upload_summary
    ADD CONSTRAINT policy_enrollment_upload_summary_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8780 (class 2606 OID 27691588)
-- Name: policy_enrollment_upload_summary policy_enrollment_upload_summary_source_file_upload_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_upload_summary
    ADD CONSTRAINT policy_enrollment_upload_summary_source_file_upload_id_fkey FOREIGN KEY (source_file_upload_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8781 (class 2606 OID 27691593)
-- Name: policy_enrollment_upload_summary policy_enrollment_upload_summary_success_file_upload_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_enrollment_upload_summary
    ADD CONSTRAINT policy_enrollment_upload_summary_success_file_upload_id_fkey FOREIGN KEY (success_file_upload_id) REFERENCES public.file_uploads(id);


--
-- TOC entry 8782 (class 2606 OID 27691598)
-- Name: policy_insurer_map policy_insurer_map_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_insurer_map
    ADD CONSTRAINT policy_insurer_map_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8785 (class 2606 OID 27691603)
-- Name: policy_premium_installment_schedules policy_premium_installment_schedules_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_premium_installment_schedules
    ADD CONSTRAINT policy_premium_installment_schedules_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8788 (class 2606 OID 27691608)
-- Name: policy_tpa_map policy_tpa_map_policy_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.policy_tpa_map
    ADD CONSTRAINT policy_tpa_map_policy_id_fkey FOREIGN KEY (policy_id) REFERENCES public.policy(id);


--
-- TOC entry 8797 (class 2606 OID 27691613)
-- Name: service_tat_score_map service_tat_score_map_service_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.service_tat_score_map
    ADD CONSTRAINT service_tat_score_map_service_id_fkey FOREIGN KEY (service_id) REFERENCES public.mstr_service(id);


--
-- TOC entry 8798 (class 2606 OID 27691618)
-- Name: service_tat_score_map service_tat_score_map_tat_bucket_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: nl2sql_ai
--

ALTER TABLE ONLY public.service_tat_score_map
    ADD CONSTRAINT service_tat_score_map_tat_bucket_id_fkey FOREIGN KEY (tat_bucket_id) REFERENCES public.mstr_tat_bucket(id);


--
-- TOC entry 8989 (class 0 OID 0)
-- Dependencies: 7
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: pg_database_owner
--

GRANT ALL ON SCHEMA public TO nl2sql_ai;


-- Completed on 2026-02-05 17:54:57

--
--

