-- Name: temp_boundary_overlap; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.temp_boundary_overlap (
    id integer,
    name character varying(100),
    notes character varying(100),
    type text,
    borough text,
    olt bigint,
    total_premises numeric,
    mdu_premises numeric,
    mdu_with_wayleave numeric,
    sdu_premises numeric,
    mdu_buildings bigint,
    sdu_buildings bigint,
    pia_oh_premises numeric,
    pia_ug_l_premises numeric,
    pia_ug_c_premises numeric,
    civils_premises numeric,
    pia_oh_mdu_premises numeric,
    pia_oh_sdu_premises numeric,
    pia_ug_l_mdu_premises numeric,
    pia_ug_l_sdu_premises numeric,
    pia_ug_c_mdu_premises numeric,
    pia_ug_c_sdu_premises numeric,
    civils_mdu_premises numeric,
    civils_sdu_premises numeric,
    cab_name character varying,
    total_distance numeric,
    cluster_capex_budget numeric,
    mdu_low_capex numeric,
    sdu_low_capex numeric,
    capacity_low_capex numeric,
    civils_low_capex numeric,
    pia_ug_low_capex numeric,
    pia_oh_low_capex numeric,
    mdu_high_capex numeric,
    sdu_high_capex numeric,
    capacity_high_capex numeric,
    civils_high_capex numeric,
    pia_ug_high_capex numeric,
    pia_oh_high_capex numeric,
    mdu_wayleave_percent numeric,
    capex_low numeric,
    cppp_low numeric,
    capex_high numeric,
    cppp_high numeric,
    costing_datetime timestamp with time zone,
    geom public.geometry,
    int_name character varying(100),
    i public.geometry,
    r bigint
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'temp_boundary_overlap'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN notes OPTIONS (
    column_name 'notes'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN type OPTIONS (
    column_name 'type'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN olt OPTIONS (
    column_name 'olt'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN total_premises OPTIONS (
    column_name 'total_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN mdu_premises OPTIONS (
    column_name 'mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN mdu_with_wayleave OPTIONS (
    column_name 'mdu_with_wayleave'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN sdu_premises OPTIONS (
    column_name 'sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN mdu_buildings OPTIONS (
    column_name 'mdu_buildings'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN sdu_buildings OPTIONS (
    column_name 'sdu_buildings'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_oh_premises OPTIONS (
    column_name 'pia_oh_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_l_premises OPTIONS (
    column_name 'pia_ug_l_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_c_premises OPTIONS (
    column_name 'pia_ug_c_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN civils_premises OPTIONS (
    column_name 'civils_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_oh_mdu_premises OPTIONS (
    column_name 'pia_oh_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_oh_sdu_premises OPTIONS (
    column_name 'pia_oh_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_l_mdu_premises OPTIONS (
    column_name 'pia_ug_l_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_l_sdu_premises OPTIONS (
    column_name 'pia_ug_l_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_c_mdu_premises OPTIONS (
    column_name 'pia_ug_c_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_c_sdu_premises OPTIONS (
    column_name 'pia_ug_c_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN civils_mdu_premises OPTIONS (
    column_name 'civils_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN civils_sdu_premises OPTIONS (
    column_name 'civils_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN cab_name OPTIONS (
    column_name 'cab_name'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN total_distance OPTIONS (
    column_name 'total_distance'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN cluster_capex_budget OPTIONS (
    column_name 'cluster_capex_budget'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN mdu_low_capex OPTIONS (
    column_name 'mdu_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN sdu_low_capex OPTIONS (
    column_name 'sdu_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN capacity_low_capex OPTIONS (
    column_name 'capacity_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN civils_low_capex OPTIONS (
    column_name 'civils_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_low_capex OPTIONS (
    column_name 'pia_ug_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_oh_low_capex OPTIONS (
    column_name 'pia_oh_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN mdu_high_capex OPTIONS (
    column_name 'mdu_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN sdu_high_capex OPTIONS (
    column_name 'sdu_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN capacity_high_capex OPTIONS (
    column_name 'capacity_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN civils_high_capex OPTIONS (
    column_name 'civils_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_ug_high_capex OPTIONS (
    column_name 'pia_ug_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN pia_oh_high_capex OPTIONS (
    column_name 'pia_oh_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN mdu_wayleave_percent OPTIONS (
    column_name 'mdu_wayleave_percent'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN capex_low OPTIONS (
    column_name 'capex_low'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN cppp_low OPTIONS (
    column_name 'cppp_low'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN capex_high OPTIONS (
    column_name 'capex_high'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN cppp_high OPTIONS (
    column_name 'cppp_high'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN costing_datetime OPTIONS (
    column_name 'costing_datetime'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN int_name OPTIONS (
    column_name 'int_name'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN i OPTIONS (
    column_name 'i'
);
ALTER FOREIGN TABLE strategy.temp_boundary_overlap ALTER COLUMN r OPTIONS (
    column_name 'r'
);


--
-- Name: temp_dj_status; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.temp_dj_status (
    id integer,
    name character varying(22),
    premises bigint,
    s45_prems bigint,
    build_prems bigint,
    geom public.geometry
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'temp_dj_status'
);
ALTER FOREIGN TABLE strategy.temp_dj_status ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.temp_dj_status ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE strategy.temp_dj_status ALTER COLUMN premises OPTIONS (
    column_name 'premises'
);
ALTER FOREIGN TABLE strategy.temp_dj_status ALTER COLUMN s45_prems OPTIONS (
    column_name 's45_prems'
);
ALTER FOREIGN TABLE strategy.temp_dj_status ALTER COLUMN build_prems OPTIONS (
    column_name 'build_prems'
);
ALTER FOREIGN TABLE strategy.temp_dj_status ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: temp_harrow_clusters; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.temp_harrow_clusters (
    cluster_id text,
    total_premises numeric,
    mdu_premises numeric,
    mdu_with_wayleave numeric,
    mdu_with_wayleave_t50 numeric,
    mdu_with_wayleave_other numeric,
    sdu_premises numeric,
    mdu_buildings bigint,
    sdu_buildings bigint,
    pia_oh_premises numeric,
    pia_ug_l_premises numeric,
    pia_ug_c_premises numeric,
    civils_premises numeric,
    pia_oh_mdu_premises numeric,
    pia_oh_sdu_premises numeric,
    pia_ug_l_mdu_premises numeric,
    pia_ug_l_sdu_premises numeric,
    pia_ug_c_mdu_premises numeric,
    pia_ug_c_sdu_premises numeric,
    civils_mdu_premises numeric,
    civils_sdu_premises numeric,
    in_project_premises numeric,
    released_premises numeric,
    cab_name character varying,
    total_distance numeric,
    cluster_capex_budget numeric,
    mdu_low_capex numeric,
    sdu_low_capex numeric,
    capacity_low_capex numeric,
    civils_low_capex numeric,
    pia_ug_low_capex numeric,
    pia_oh_low_capex numeric,
    mdu_high_capex numeric,
    sdu_high_capex numeric,
    capacity_high_capex numeric,
    civils_high_capex numeric,
    pia_ug_high_capex numeric,
    pia_oh_high_capex numeric,
    mdu_wayleave_percent numeric,
    capex_low numeric,
    cppp_low numeric,
    capex_high numeric,
    cppp_high numeric,
    geom public.geometry
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'temp_harrow_clusters'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN total_premises OPTIONS (
    column_name 'total_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_premises OPTIONS (
    column_name 'mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_with_wayleave OPTIONS (
    column_name 'mdu_with_wayleave'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_with_wayleave_t50 OPTIONS (
    column_name 'mdu_with_wayleave_t50'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_with_wayleave_other OPTIONS (
    column_name 'mdu_with_wayleave_other'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN sdu_premises OPTIONS (
    column_name 'sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_buildings OPTIONS (
    column_name 'mdu_buildings'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN sdu_buildings OPTIONS (
    column_name 'sdu_buildings'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_oh_premises OPTIONS (
    column_name 'pia_oh_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_l_premises OPTIONS (
    column_name 'pia_ug_l_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_c_premises OPTIONS (
    column_name 'pia_ug_c_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN civils_premises OPTIONS (
    column_name 'civils_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_oh_mdu_premises OPTIONS (
    column_name 'pia_oh_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_oh_sdu_premises OPTIONS (
    column_name 'pia_oh_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_l_mdu_premises OPTIONS (
    column_name 'pia_ug_l_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_l_sdu_premises OPTIONS (
    column_name 'pia_ug_l_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_c_mdu_premises OPTIONS (
    column_name 'pia_ug_c_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_c_sdu_premises OPTIONS (
    column_name 'pia_ug_c_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN civils_mdu_premises OPTIONS (
    column_name 'civils_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN civils_sdu_premises OPTIONS (
    column_name 'civils_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN in_project_premises OPTIONS (
    column_name 'in_project_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN released_premises OPTIONS (
    column_name 'released_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN cab_name OPTIONS (
    column_name 'cab_name'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN total_distance OPTIONS (
    column_name 'total_distance'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN cluster_capex_budget OPTIONS (
    column_name 'cluster_capex_budget'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_low_capex OPTIONS (
    column_name 'mdu_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN sdu_low_capex OPTIONS (
    column_name 'sdu_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN capacity_low_capex OPTIONS (
    column_name 'capacity_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN civils_low_capex OPTIONS (
    column_name 'civils_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_low_capex OPTIONS (
    column_name 'pia_ug_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_oh_low_capex OPTIONS (
    column_name 'pia_oh_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_high_capex OPTIONS (
    column_name 'mdu_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN sdu_high_capex OPTIONS (
    column_name 'sdu_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN capacity_high_capex OPTIONS (
    column_name 'capacity_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN civils_high_capex OPTIONS (
    column_name 'civils_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_ug_high_capex OPTIONS (
    column_name 'pia_ug_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN pia_oh_high_capex OPTIONS (
    column_name 'pia_oh_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN mdu_wayleave_percent OPTIONS (
    column_name 'mdu_wayleave_percent'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN capex_low OPTIONS (
    column_name 'capex_low'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN cppp_low OPTIONS (
    column_name 'cppp_low'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN capex_high OPTIONS (
    column_name 'capex_high'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN cppp_high OPTIONS (
    column_name 'cppp_high'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: temp_harrow_clusters_rejected; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.temp_harrow_clusters_rejected (
    cluster_id text,
    total_premises numeric,
    mdu_premises numeric,
    mdu_with_wayleave numeric,
    mdu_with_wayleave_t50 numeric,
    mdu_with_wayleave_other numeric,
    sdu_premises numeric,
    mdu_buildings bigint,
    sdu_buildings bigint,
    pia_oh_premises numeric,
    pia_ug_l_premises numeric,
    pia_ug_c_premises numeric,
    civils_premises numeric,
    pia_oh_mdu_premises numeric,
    pia_oh_sdu_premises numeric,
    pia_ug_l_mdu_premises numeric,
    pia_ug_l_sdu_premises numeric,
    pia_ug_c_mdu_premises numeric,
    pia_ug_c_sdu_premises numeric,
    civils_mdu_premises numeric,
    civils_sdu_premises numeric,
    in_project_premises numeric,
    released_premises numeric,
    cab_name character varying,
    total_distance numeric,
    cluster_capex_budget numeric,
    mdu_low_capex numeric,
    sdu_low_capex numeric,
    capacity_low_capex numeric,
    civils_low_capex numeric,
    pia_ug_low_capex numeric,
    pia_oh_low_capex numeric,
    mdu_high_capex numeric,
    sdu_high_capex numeric,
    capacity_high_capex numeric,
    civils_high_capex numeric,
    pia_ug_high_capex numeric,
    pia_oh_high_capex numeric,
    mdu_wayleave_percent numeric,
    capex_low numeric,
    cppp_low numeric,
    capex_high numeric,
    cppp_high numeric,
    geom public.geometry
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'temp_harrow_clusters_rejected'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN total_premises OPTIONS (
    column_name 'total_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_premises OPTIONS (
    column_name 'mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_with_wayleave OPTIONS (
    column_name 'mdu_with_wayleave'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_with_wayleave_t50 OPTIONS (
    column_name 'mdu_with_wayleave_t50'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_with_wayleave_other OPTIONS (
    column_name 'mdu_with_wayleave_other'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN sdu_premises OPTIONS (
    column_name 'sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_buildings OPTIONS (
    column_name 'mdu_buildings'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN sdu_buildings OPTIONS (
    column_name 'sdu_buildings'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_oh_premises OPTIONS (
    column_name 'pia_oh_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_l_premises OPTIONS (
    column_name 'pia_ug_l_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_c_premises OPTIONS (
    column_name 'pia_ug_c_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN civils_premises OPTIONS (
    column_name 'civils_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_oh_mdu_premises OPTIONS (
    column_name 'pia_oh_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_oh_sdu_premises OPTIONS (
    column_name 'pia_oh_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_l_mdu_premises OPTIONS (
    column_name 'pia_ug_l_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_l_sdu_premises OPTIONS (
    column_name 'pia_ug_l_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_c_mdu_premises OPTIONS (
    column_name 'pia_ug_c_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_c_sdu_premises OPTIONS (
    column_name 'pia_ug_c_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN civils_mdu_premises OPTIONS (
    column_name 'civils_mdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN civils_sdu_premises OPTIONS (
    column_name 'civils_sdu_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN in_project_premises OPTIONS (
    column_name 'in_project_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN released_premises OPTIONS (
    column_name 'released_premises'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN cab_name OPTIONS (
    column_name 'cab_name'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN total_distance OPTIONS (
    column_name 'total_distance'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN cluster_capex_budget OPTIONS (
    column_name 'cluster_capex_budget'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_low_capex OPTIONS (
    column_name 'mdu_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN sdu_low_capex OPTIONS (
    column_name 'sdu_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN capacity_low_capex OPTIONS (
    column_name 'capacity_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN civils_low_capex OPTIONS (
    column_name 'civils_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_low_capex OPTIONS (
    column_name 'pia_ug_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_oh_low_capex OPTIONS (
    column_name 'pia_oh_low_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_high_capex OPTIONS (
    column_name 'mdu_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN sdu_high_capex OPTIONS (
    column_name 'sdu_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN capacity_high_capex OPTIONS (
    column_name 'capacity_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN civils_high_capex OPTIONS (
    column_name 'civils_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_ug_high_capex OPTIONS (
    column_name 'pia_ug_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN pia_oh_high_capex OPTIONS (
    column_name 'pia_oh_high_capex'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN mdu_wayleave_percent OPTIONS (
    column_name 'mdu_wayleave_percent'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN capex_low OPTIONS (
    column_name 'capex_low'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN cppp_low OPTIONS (
    column_name 'cppp_low'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN capex_high OPTIONS (
    column_name 'capex_high'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN cppp_high OPTIONS (
    column_name 'cppp_high'
);
ALTER FOREIGN TABLE strategy.temp_harrow_clusters_rejected ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: temp_peabody_stock; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.temp_peabody_stock (
    uprn bigint,
    classification_code character varying,
    class_description character varying,
    parent_uprn bigint,
    block text,
    postcode character varying(8),
    address text,
    business_name text,
    borough character varying(50),
    main_proprietor text,
    title_no text,
    property_type text,
    cross_reference character varying(50),
    udprn bigint,
    umprn integer,
    geom public.geometry(Point,27700),
    sprn integer,
    portfolio_id smallint,
    bd_status smallint,
    leasehold_portfolio_id integer,
    wayleave_date date,
    mdu_id bigint,
    class_type text,
    category_code smallint,
    wayleave_portfolio_id smallint,
    main_leaseholder text,
    leaseholder_managed boolean
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'temp_peabody_stock'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN uprn OPTIONS (
    column_name 'uprn'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN classification_code OPTIONS (
    column_name 'classification_code'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN class_description OPTIONS (
    column_name 'class_description'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN parent_uprn OPTIONS (
    column_name 'parent_uprn'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN block OPTIONS (
    column_name 'block'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN postcode OPTIONS (
    column_name 'postcode'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN address OPTIONS (
    column_name 'address'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN business_name OPTIONS (
    column_name 'business_name'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN main_proprietor OPTIONS (
    column_name 'main_proprietor'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN title_no OPTIONS (
    column_name 'title_no'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN property_type OPTIONS (
    column_name 'property_type'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN cross_reference OPTIONS (
    column_name 'cross_reference'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN udprn OPTIONS (
    column_name 'udprn'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN umprn OPTIONS (
    column_name 'umprn'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN sprn OPTIONS (
    column_name 'sprn'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN portfolio_id OPTIONS (
    column_name 'portfolio_id'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN bd_status OPTIONS (
    column_name 'bd_status'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN leasehold_portfolio_id OPTIONS (
    column_name 'leasehold_portfolio_id'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN wayleave_date OPTIONS (
    column_name 'wayleave_date'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN mdu_id OPTIONS (
    column_name 'mdu_id'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN class_type OPTIONS (
    column_name 'class_type'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN category_code OPTIONS (
    column_name 'category_code'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN wayleave_portfolio_id OPTIONS (
    column_name 'wayleave_portfolio_id'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN main_leaseholder OPTIONS (
    column_name 'main_leaseholder'
);
ALTER FOREIGN TABLE strategy.temp_peabody_stock ALTER COLUMN leaseholder_managed OPTIONS (
    column_name 'leaseholder_managed'
);


--
-- Name: temp_pia_model_check; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.temp_pia_model_check (
    id integer,
    hp_date date,
    uprn bigint,
    door_number character varying,
    postcode character varying,
    type character varying,
    block character varying,
    geom public.geometry(Point,27700),
    address text,
    status smallint,
    borough text,
    business_name text,
    main_proprietor text,
    last_status_update text,
    comment text,
    date_added date,
    project_id integer,
    portfolio_id integer,
    business_live integer,
    bd_status smallint,
    sprn integer,
    splitter_id text,
    sales_status smallint,
    declared_live_date date,
    install_type smallint,
    planning_ecd date,
    civils_done boolean,
    cabled boolean,
    spliced boolean,
    tested boolean,
    on_hold boolean,
    on_hold_category smallint,
    on_hold_subcategory smallint,
    on_hold_start date,
    on_hold_revisit date,
    on_hold_stop date,
    last_updater character varying,
    last_update_timestamp timestamp without time zone,
    mdu_id integer,
    forecast_live_date date,
    wayleave_date date,
    main_leaseholder text,
    leaseholder_managed boolean
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'temp_pia_model_check'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN hp_date OPTIONS (
    column_name 'hp_date'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN uprn OPTIONS (
    column_name 'uprn'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN door_number OPTIONS (
    column_name 'door_number'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN postcode OPTIONS (
    column_name 'postcode'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN type OPTIONS (
    column_name 'type'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN block OPTIONS (
    column_name 'block'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN address OPTIONS (
    column_name 'address'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN status OPTIONS (
    column_name 'status'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN business_name OPTIONS (
    column_name 'business_name'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN main_proprietor OPTIONS (
    column_name 'main_proprietor'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN last_status_update OPTIONS (
    column_name 'last_status_update'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN comment OPTIONS (
    column_name 'comment'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN date_added OPTIONS (
    column_name 'date_added'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN project_id OPTIONS (
    column_name 'project_id'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN portfolio_id OPTIONS (
    column_name 'portfolio_id'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN business_live OPTIONS (
    column_name 'business_live'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN bd_status OPTIONS (
    column_name 'bd_status'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN sprn OPTIONS (
    column_name 'sprn'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN splitter_id OPTIONS (
    column_name 'splitter_id'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN sales_status OPTIONS (
    column_name 'sales_status'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN declared_live_date OPTIONS (
    column_name 'declared_live_date'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN install_type OPTIONS (
    column_name 'install_type'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN planning_ecd OPTIONS (
    column_name 'planning_ecd'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN civils_done OPTIONS (
    column_name 'civils_done'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN cabled OPTIONS (
    column_name 'cabled'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN spliced OPTIONS (
    column_name 'spliced'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN tested OPTIONS (
    column_name 'tested'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN on_hold OPTIONS (
    column_name 'on_hold'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN on_hold_category OPTIONS (
    column_name 'on_hold_category'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN on_hold_subcategory OPTIONS (
    column_name 'on_hold_subcategory'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN on_hold_start OPTIONS (
    column_name 'on_hold_start'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN on_hold_revisit OPTIONS (
    column_name 'on_hold_revisit'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN on_hold_stop OPTIONS (
    column_name 'on_hold_stop'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN last_updater OPTIONS (
    column_name 'last_updater'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN last_update_timestamp OPTIONS (
    column_name 'last_update_timestamp'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN mdu_id OPTIONS (
    column_name 'mdu_id'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN forecast_live_date OPTIONS (
    column_name 'forecast_live_date'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN wayleave_date OPTIONS (
    column_name 'wayleave_date'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN main_leaseholder OPTIONS (
    column_name 'main_leaseholder'
);
ALTER FOREIGN TABLE strategy.temp_pia_model_check ALTER COLUMN leaseholder_managed OPTIONS (
    column_name 'leaseholder_managed'
);


--
-- Name: temp_project_jobs; Type: TABLE; Schema: strategy; Owner: -
--

CREATE TABLE strategy.temp_project_jobs (
    project_id integer,
    project_name character varying(150),
    project_status_desc character varying(100),
    project_manager character varying(100),
    account_name character varying(100),
    geom public.geometry,
    temp_id bigint
);


--
-- Name: temp_stocklist_analysis_output_template; Type: TABLE; Schema: strategy; Owner: -
--

CREATE TABLE strategy.temp_stocklist_analysis_output_template (
    stocklist_id integer,
    project_id integer,
    uprn bigint,
    classification_code character varying,
    class_description character varying,
    address text,
    postcode character varying(8),
    geom public.geometry(Point,27700),
    style_type text,
    stocklist_name character varying(100),
    account_id integer,
    account_name character varying(100),
    company_id integer,
    building_type text,
    building_use text,
    building_premises bigint,
    project_name character varying(100),
    toid character varying(50),
    rn bigint,
    target_1_example_address text,
    target_1_postcode text,
    target_1_target_distance double precision,
    target_1_calculated_heading_degrees double precision,
    target_2_point_name character varying(100),
    target_2_project_id integer,
    target_2_target_distance double precision,
    target_2_calculated_heading_degrees double precision,
    target_3_project_id integer,
    target_3_project_name character varying(100),
    target_3_target_distance double precision,
    target_3_calculated_heading_degrees double precision,
    t1_t2_similar_heading boolean,
    t1_t3_similar_heading boolean,
    t2_t3_similar_heading boolean,
    all_three_similar_heading boolean,
    aligned_pairs_count integer,
    target_matches_count integer
);


--
-- Name: test; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.test (
    uprn bigint,
    building_type text,
    building_premise_count bigint,
    borough character varying(22),
    ward character varying(70),
    geom public.geometry(Point,27700),
    cluster_id integer
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'test'
);
ALTER FOREIGN TABLE strategy.test ALTER COLUMN uprn OPTIONS (
    column_name 'uprn'
);
ALTER FOREIGN TABLE strategy.test ALTER COLUMN building_type OPTIONS (
    column_name 'building_type'
);
ALTER FOREIGN TABLE strategy.test ALTER COLUMN building_premise_count OPTIONS (
    column_name 'building_premise_count'
);
ALTER FOREIGN TABLE strategy.test ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.test ALTER COLUMN ward OPTIONS (
    column_name 'ward'
);
ALTER FOREIGN TABLE strategy.test ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.test ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);


--
-- Name: test2; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.test2 (
    uprn bigint,
    building_type text,
    building_premise_count bigint,
    borough character varying(22),
    ward character varying(70),
    sqm_per_premise bigint,
    geom public.geometry
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'test2'
);
ALTER FOREIGN TABLE strategy.test2 ALTER COLUMN uprn OPTIONS (
    column_name 'uprn'
);
ALTER FOREIGN TABLE strategy.test2 ALTER COLUMN building_type OPTIONS (
    column_name 'building_type'
);
ALTER FOREIGN TABLE strategy.test2 ALTER COLUMN building_premise_count OPTIONS (
    column_name 'building_premise_count'
);
ALTER FOREIGN TABLE strategy.test2 ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.test2 ALTER COLUMN ward OPTIONS (
    column_name 'ward'
);
ALTER FOREIGN TABLE strategy.test2 ALTER COLUMN sqm_per_premise OPTIONS (
    column_name 'sqm_per_premise'
);
ALTER FOREIGN TABLE strategy.test2 ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: test20220222a; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.test20220222a (
    sprn integer,
    cluster_id text,
    cluster_id_child_candidate text,
    cluster_id_parent_candidate text,
    geom public.geometry,
    moved integer
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'test20220222a'
);
ALTER FOREIGN TABLE strategy.test20220222a ALTER COLUMN sprn OPTIONS (
    column_name 'sprn'
);
ALTER FOREIGN TABLE strategy.test20220222a ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);
ALTER FOREIGN TABLE strategy.test20220222a ALTER COLUMN cluster_id_child_candidate OPTIONS (
    column_name 'cluster_id_child_candidate'
);
ALTER FOREIGN TABLE strategy.test20220222a ALTER COLUMN cluster_id_parent_candidate OPTIONS (
    column_name 'cluster_id_parent_candidate'
);
ALTER FOREIGN TABLE strategy.test20220222a ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.test20220222a ALTER COLUMN moved OPTIONS (
    column_name 'moved'
);


--
-- Name: test20220223a; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.test20220223a (
    wlperc numeric,
    cppp double precision,
    cluster_id text,
    cluster_premise_count numeric,
    mdu_premises numeric,
    mdu_with_wayleave numeric,
    sdu_premises numeric,
    pia_oh_premises numeric,
    pia_ug_premises numeric,
    civils_premises numeric,
    pia_oh_mdu_premises numeric,
    pia_oh_sdu_premises numeric,
    pia_ug_mdu_premises numeric,
    pia_ug_sdu_premises numeric,
    civils_mdu_premises numeric,
    civils_sdu_premises numeric,
    pia_oh_percent numeric,
    in_project_premises numeric,
    released_premises numeric,
    geom public.geometry,
    centriod public.geometry,
    id bigint,
    osm_id bigint,
    distance double precision,
    pole_distance double precision,
    pole_cost double precision,
    duct_distance double precision,
    duct_cost double precision,
    civils_distance double precision,
    civils_cost double precision,
    total_distance double precision,
    total_route_cost double precision,
    core_route_distance double precision,
    core_route_cost double precision
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'test20220223a'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN wlperc OPTIONS (
    column_name 'wlperc'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN cppp OPTIONS (
    column_name 'cppp'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN cluster_premise_count OPTIONS (
    column_name 'cluster_premise_count'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN mdu_premises OPTIONS (
    column_name 'mdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN mdu_with_wayleave OPTIONS (
    column_name 'mdu_with_wayleave'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN sdu_premises OPTIONS (
    column_name 'sdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pia_oh_premises OPTIONS (
    column_name 'pia_oh_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pia_ug_premises OPTIONS (
    column_name 'pia_ug_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN civils_premises OPTIONS (
    column_name 'civils_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pia_oh_mdu_premises OPTIONS (
    column_name 'pia_oh_mdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pia_oh_sdu_premises OPTIONS (
    column_name 'pia_oh_sdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pia_ug_mdu_premises OPTIONS (
    column_name 'pia_ug_mdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pia_ug_sdu_premises OPTIONS (
    column_name 'pia_ug_sdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN civils_mdu_premises OPTIONS (
    column_name 'civils_mdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN civils_sdu_premises OPTIONS (
    column_name 'civils_sdu_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pia_oh_percent OPTIONS (
    column_name 'pia_oh_percent'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN in_project_premises OPTIONS (
    column_name 'in_project_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN released_premises OPTIONS (
    column_name 'released_premises'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN centriod OPTIONS (
    column_name 'centriod'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN osm_id OPTIONS (
    column_name 'osm_id'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN distance OPTIONS (
    column_name 'distance'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pole_distance OPTIONS (
    column_name 'pole_distance'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN pole_cost OPTIONS (
    column_name 'pole_cost'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN duct_distance OPTIONS (
    column_name 'duct_distance'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN duct_cost OPTIONS (
    column_name 'duct_cost'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN civils_distance OPTIONS (
    column_name 'civils_distance'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN civils_cost OPTIONS (
    column_name 'civils_cost'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN total_distance OPTIONS (
    column_name 'total_distance'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN total_route_cost OPTIONS (
    column_name 'total_route_cost'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN core_route_distance OPTIONS (
    column_name 'core_route_distance'
);
ALTER FOREIGN TABLE strategy.test20220223a ALTER COLUMN core_route_cost OPTIONS (
    column_name 'core_route_cost'
);


--
-- Name: tree_canopies_stg0; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.tree_canopies_stg0 (
    fid character varying(20),
    pole_objectid bigint,
    pole_feed_geom public.geometry,
    tree_objectid integer
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'tree_canopies_stg0'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg0 ALTER COLUMN fid OPTIONS (
    column_name 'fid'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg0 ALTER COLUMN pole_objectid OPTIONS (
    column_name 'pole_objectid'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg0 ALTER COLUMN pole_feed_geom OPTIONS (
    column_name 'pole_feed_geom'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg0 ALTER COLUMN tree_objectid OPTIONS (
    column_name 'tree_objectid'
);


--
-- Name: tree_canopies_stg1; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.tree_canopies_stg1 (
    sprn integer,
    fid character varying(20),
    pole_objectid bigint,
    tree_objectid integer,
    geom public.geometry(Point,27700)
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'tree_canopies_stg1'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg1 ALTER COLUMN sprn OPTIONS (
    column_name 'sprn'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg1 ALTER COLUMN fid OPTIONS (
    column_name 'fid'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg1 ALTER COLUMN pole_objectid OPTIONS (
    column_name 'pole_objectid'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg1 ALTER COLUMN tree_objectid OPTIONS (
    column_name 'tree_objectid'
);
ALTER FOREIGN TABLE strategy.tree_canopies_stg1 ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: users; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.users (
    id bigint NOT NULL,
    username character varying(100) NOT NULL,
    manager character varying(100) NOT NULL,
    email character varying(50) NOT NULL,
    company integer NOT NULL,
    access_level integer NOT NULL,
    division integer NOT NULL,
    team integer NOT NULL,
    password character varying(255) NOT NULL,
    is_active integer NOT NULL,
    date_user_created timestamp without time zone,
    date_last_login timestamp without time zone,
    date_last_active timestamp without time zone
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'users'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN username OPTIONS (
    column_name 'username'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN manager OPTIONS (
    column_name 'manager'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN email OPTIONS (
    column_name 'email'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN company OPTIONS (
    column_name 'company'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN access_level OPTIONS (
    column_name 'access_level'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN division OPTIONS (
    column_name 'division'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN team OPTIONS (
    column_name 'team'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN password OPTIONS (
    column_name 'password'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN is_active OPTIONS (
    column_name 'is_active'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN date_user_created OPTIONS (
    column_name 'date_user_created'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN date_last_login OPTIONS (
    column_name 'date_last_login'
);
ALTER FOREIGN TABLE strategy.users ALTER COLUMN date_last_active OPTIONS (
    column_name 'date_last_active'
);


--
-- Name: voapropertyage; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.voapropertyage (
    area_code character varying(200),
    area_name character varying(200),
    bp_pre_1900 integer,
    bp_1900_1918 integer,
    bp_1919_1929 integer,
    bp_1930_1939 integer,
    bp_1945_1954 integer,
    bp_1955_1964 integer,
    bp_1965_1972 integer,
    bp_1973_1982 integer,
    bp_1983_1992 integer,
    bp_1993_1999 integer,
    bp_2000_2009 integer,
    bp_2010_2015 integer,
    bp_unknown integer,
    all_properties integer,
    mode1_val integer,
    mode1_type character varying(200),
    mode1_pc real,
    mode2_val integer,
    mode2_type character varying(200),
    mode2_pc real,
    mode2_mode1_ratio real
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'voapropertyage'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN area_code OPTIONS (
    column_name 'area_code'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN area_name OPTIONS (
    column_name 'area_name'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_pre_1900 OPTIONS (
    column_name 'bp_pre_1900'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1900_1918 OPTIONS (
    column_name 'bp_1900_1918'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1919_1929 OPTIONS (
    column_name 'bp_1919_1929'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1930_1939 OPTIONS (
    column_name 'bp_1930_1939'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1945_1954 OPTIONS (
    column_name 'bp_1945_1954'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1955_1964 OPTIONS (
    column_name 'bp_1955_1964'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1965_1972 OPTIONS (
    column_name 'bp_1965_1972'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1973_1982 OPTIONS (
    column_name 'bp_1973_1982'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1983_1992 OPTIONS (
    column_name 'bp_1983_1992'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_1993_1999 OPTIONS (
    column_name 'bp_1993_1999'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_2000_2009 OPTIONS (
    column_name 'bp_2000_2009'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_2010_2015 OPTIONS (
    column_name 'bp_2010_2015'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN bp_unknown OPTIONS (
    column_name 'bp_unknown'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN all_properties OPTIONS (
    column_name 'all_properties'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN mode1_val OPTIONS (
    column_name 'mode1_val'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN mode1_type OPTIONS (
    column_name 'mode1_type'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN mode1_pc OPTIONS (
    column_name 'mode1_pc'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN mode2_val OPTIONS (
    column_name 'mode2_val'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN mode2_type OPTIONS (
    column_name 'mode2_type'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN mode2_pc OPTIONS (
    column_name 'mode2_pc'
);
ALTER FOREIGN TABLE strategy.voapropertyage ALTER COLUMN mode2_mode1_ratio OPTIONS (
    column_name 'mode2_mode1_ratio'
);


--
-- Name: voapropertyage_geom_new; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.voapropertyage_geom_new (
    area_code character varying(200),
    area_name character varying(200),
    bp_pre_1900 integer,
    bp_1900_1918 integer,
    bp_1919_1929 integer,
    bp_1930_1939 integer,
    bp_1945_1954 integer,
    bp_1955_1964 integer,
    bp_1965_1972 integer,
    bp_1973_1982 integer,
    bp_1983_1992 integer,
    bp_1993_1999 integer,
    bp_2000_2009 integer,
    bp_2010_2015 integer,
    bp_unknown integer,
    all_properties integer,
    mode1_val integer,
    mode1_type character varying(200),
    mode1_pc real,
    mode2_val integer,
    mode2_type character varying(200),
    mode2_pc real,
    mode2_mode1_ratio real,
    percent_not_lead_in numeric,
    percent_lead_in numeric,
    geom public.geometry(MultiPolygon,27700)
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'voapropertyage_geom_new'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN area_code OPTIONS (
    column_name 'area_code'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN area_name OPTIONS (
    column_name 'area_name'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_pre_1900 OPTIONS (
    column_name 'bp_pre_1900'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1900_1918 OPTIONS (
    column_name 'bp_1900_1918'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1919_1929 OPTIONS (
    column_name 'bp_1919_1929'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1930_1939 OPTIONS (
    column_name 'bp_1930_1939'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1945_1954 OPTIONS (
    column_name 'bp_1945_1954'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1955_1964 OPTIONS (
    column_name 'bp_1955_1964'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1965_1972 OPTIONS (
    column_name 'bp_1965_1972'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1973_1982 OPTIONS (
    column_name 'bp_1973_1982'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1983_1992 OPTIONS (
    column_name 'bp_1983_1992'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_1993_1999 OPTIONS (
    column_name 'bp_1993_1999'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_2000_2009 OPTIONS (
    column_name 'bp_2000_2009'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_2010_2015 OPTIONS (
    column_name 'bp_2010_2015'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN bp_unknown OPTIONS (
    column_name 'bp_unknown'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN all_properties OPTIONS (
    column_name 'all_properties'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN mode1_val OPTIONS (
    column_name 'mode1_val'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN mode1_type OPTIONS (
    column_name 'mode1_type'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN mode1_pc OPTIONS (
    column_name 'mode1_pc'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN mode2_val OPTIONS (
    column_name 'mode2_val'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN mode2_type OPTIONS (
    column_name 'mode2_type'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN mode2_pc OPTIONS (
    column_name 'mode2_pc'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN mode2_mode1_ratio OPTIONS (
    column_name 'mode2_mode1_ratio'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN percent_not_lead_in OPTIONS (
    column_name 'percent_not_lead_in'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN percent_lead_in OPTIONS (
    column_name 'percent_lead_in'
);
ALTER FOREIGN TABLE strategy.voapropertyage_geom_new ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: vu_watford_hld_boundaries; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vu_watford_hld_boundaries (
    id integer NOT NULL,
    geom public.geometry(MultiPolygon,27700),
    fid bigint,
    name character varying(254),
    count numeric
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vu_watford_hld_boundaries'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries ALTER COLUMN fid OPTIONS (
    column_name 'fid'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries ALTER COLUMN count OPTIONS (
    column_name 'count'
);


--
-- Name: vu_watford_hld_boundaries_db; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vu_watford_hld_boundaries_db (
    id integer NOT NULL,
    geom public.geometry(MultiPolygon,27700),
    fid bigint,
    name character varying(254),
    count numeric
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vu_watford_hld_boundaries_db'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries_db ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries_db ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries_db ALTER COLUMN fid OPTIONS (
    column_name 'fid'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries_db ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE strategy.vu_watford_hld_boundaries_db ALTER COLUMN count OPTIONS (
    column_name 'count'
);


--
-- Name: vw_homes_passed_report; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vw_homes_passed_report (
    project_id integer,
    classification text,
    type character varying,
    install_type smallint,
    hp_date date,
    metric text,
    count bigint,
    borough text,
    pm text,
    contractor text
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vw_homes_passed_report'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN project_id OPTIONS (
    column_name 'project_id'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN classification OPTIONS (
    column_name 'classification'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN type OPTIONS (
    column_name 'type'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN install_type OPTIONS (
    column_name 'install_type'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN hp_date OPTIONS (
    column_name 'hp_date'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN metric OPTIONS (
    column_name 'metric'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN count OPTIONS (
    column_name 'count'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN pm OPTIONS (
    column_name 'pm'
);
ALTER FOREIGN TABLE strategy.vw_homes_passed_report ALTER COLUMN contractor OPTIONS (
    column_name 'contractor'
);


--
-- Name: vw_london_boroughs; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vw_london_boroughs (
    released_percent numeric,
    id integer,
    geom public.geometry(MultiPolygon,27700),
    borough character varying(22),
    gss_code character varying(9),
    hectares double precision,
    nonld_area double precision,
    area double precision,
    total_units integer,
    total_wayleave_units integer,
    total_wayleave_mdu integer,
    total_council_owned integer,
    percentage_council_units real,
    other_proprietor_mdu_units integer,
    total_wayleave_sdu integer,
    total_buildings_5_to_9 integer,
    total_units_5_to_9 integer,
    total_buildings_10_to_24 integer,
    total_units_10_to_24 integer,
    total_buildings_25_to_49 integer,
    total_units_25_to_49 integer,
    total_buildings_50_to_99 integer,
    total_units_50_to_99 integer,
    total_buildings_over_100 integer,
    total_units_over_100 integer,
    exchanges smallint,
    units integer,
    unitperexc real,
    inner_london boolean,
    live_units integer,
    customers integer,
    total_road_length bigint,
    total_built_pia bigint,
    total_mdu integer,
    total_sdu integer,
    pia_in_progress bigint,
    pia_rfb bigint,
    landlords_over_100units integer,
    total_pf_mdu integer,
    wayleave integer,
    ward_count bigint,
    project_count bigint,
    total_projects numeric,
    fill_opacity numeric
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vw_london_boroughs'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN released_percent OPTIONS (
    column_name 'released_percent'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN gss_code OPTIONS (
    column_name 'gss_code'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN hectares OPTIONS (
    column_name 'hectares'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN nonld_area OPTIONS (
    column_name 'nonld_area'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN area OPTIONS (
    column_name 'area'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_units OPTIONS (
    column_name 'total_units'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_wayleave_units OPTIONS (
    column_name 'total_wayleave_units'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_wayleave_mdu OPTIONS (
    column_name 'total_wayleave_mdu'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_council_owned OPTIONS (
    column_name 'total_council_owned'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN percentage_council_units OPTIONS (
    column_name 'percentage_council_units'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN other_proprietor_mdu_units OPTIONS (
    column_name 'other_proprietor_mdu_units'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_wayleave_sdu OPTIONS (
    column_name 'total_wayleave_sdu'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_buildings_5_to_9 OPTIONS (
    column_name 'total_buildings_5_to_9'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_units_5_to_9 OPTIONS (
    column_name 'total_units_5_to_9'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_buildings_10_to_24 OPTIONS (
    column_name 'total_buildings_10_to_24'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_units_10_to_24 OPTIONS (
    column_name 'total_units_10_to_24'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_buildings_25_to_49 OPTIONS (
    column_name 'total_buildings_25_to_49'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_units_25_to_49 OPTIONS (
    column_name 'total_units_25_to_49'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_buildings_50_to_99 OPTIONS (
    column_name 'total_buildings_50_to_99'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_units_50_to_99 OPTIONS (
    column_name 'total_units_50_to_99'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_buildings_over_100 OPTIONS (
    column_name 'total_buildings_over_100'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_units_over_100 OPTIONS (
    column_name 'total_units_over_100'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN exchanges OPTIONS (
    column_name 'exchanges'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN units OPTIONS (
    column_name 'units'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN unitperexc OPTIONS (
    column_name 'unitperexc'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN inner_london OPTIONS (
    column_name 'inner_london'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN live_units OPTIONS (
    column_name 'live_units'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN customers OPTIONS (
    column_name 'customers'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_road_length OPTIONS (
    column_name 'total_road_length'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_built_pia OPTIONS (
    column_name 'total_built_pia'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_mdu OPTIONS (
    column_name 'total_mdu'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_sdu OPTIONS (
    column_name 'total_sdu'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN pia_in_progress OPTIONS (
    column_name 'pia_in_progress'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN pia_rfb OPTIONS (
    column_name 'pia_rfb'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN landlords_over_100units OPTIONS (
    column_name 'landlords_over_100units'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_pf_mdu OPTIONS (
    column_name 'total_pf_mdu'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN wayleave OPTIONS (
    column_name 'wayleave'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN ward_count OPTIONS (
    column_name 'ward_count'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN project_count OPTIONS (
    column_name 'project_count'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN total_projects OPTIONS (
    column_name 'total_projects'
);
ALTER FOREIGN TABLE strategy.vw_london_boroughs ALTER COLUMN fill_opacity OPTIONS (
    column_name 'fill_opacity'
);


--
-- Name: vw_london_wards; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vw_london_wards (
    borough_id integer,
    released_percent numeric,
    total_units integer,
    id integer,
    ward character varying(70),
    code character varying(9),
    geom public.geometry(MultiPolygon,27700),
    area double precision,
    total_mdu integer,
    total_pf_mdu integer,
    total_toppf integer,
    comment character varying,
    length_comsof integer,
    total_sdu integer,
    total2_4 integer,
    virginsdu integer,
    virgin1_4 integer,
    virginsdu_pc integer,
    virgin1_4_pc integer,
    neil_wardmonth smallint,
    passed2019 boolean,
    total5_9 smallint,
    exchangeid integer,
    liveinprogress integer,
    liveinprogress_huawei integer,
    project_count bigint,
    fill_opacity numeric
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vw_london_wards'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN borough_id OPTIONS (
    column_name 'borough_id'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN released_percent OPTIONS (
    column_name 'released_percent'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN total_units OPTIONS (
    column_name 'total_units'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN ward OPTIONS (
    column_name 'ward'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN code OPTIONS (
    column_name 'code'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN area OPTIONS (
    column_name 'area'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN total_mdu OPTIONS (
    column_name 'total_mdu'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN total_pf_mdu OPTIONS (
    column_name 'total_pf_mdu'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN total_toppf OPTIONS (
    column_name 'total_toppf'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN comment OPTIONS (
    column_name 'comment'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN length_comsof OPTIONS (
    column_name 'length_comsof'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN total_sdu OPTIONS (
    column_name 'total_sdu'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN total2_4 OPTIONS (
    column_name 'total2_4'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN virginsdu OPTIONS (
    column_name 'virginsdu'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN virgin1_4 OPTIONS (
    column_name 'virgin1_4'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN virginsdu_pc OPTIONS (
    column_name 'virginsdu_pc'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN virgin1_4_pc OPTIONS (
    column_name 'virgin1_4_pc'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN neil_wardmonth OPTIONS (
    column_name 'neil_wardmonth'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN passed2019 OPTIONS (
    column_name 'passed2019'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN total5_9 OPTIONS (
    column_name 'total5_9'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN exchangeid OPTIONS (
    column_name 'exchangeid'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN liveinprogress OPTIONS (
    column_name 'liveinprogress'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN liveinprogress_huawei OPTIONS (
    column_name 'liveinprogress_huawei'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN project_count OPTIONS (
    column_name 'project_count'
);
ALTER FOREIGN TABLE strategy.vw_london_wards ALTER COLUMN fill_opacity OPTIONS (
    column_name 'fill_opacity'
);


--
-- Name: vw_project_detail; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vw_project_detail (
    uprn bigint,
    address text,
    borough character varying(50),
    id integer,
    name character varying(100),
    created_datetime timestamp without time zone,
    building_type text,
    building_type_icon_size text,
    geom public.geometry(Point,27700)
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vw_project_detail'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN uprn OPTIONS (
    column_name 'uprn'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN address OPTIONS (
    column_name 'address'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN created_datetime OPTIONS (
    column_name 'created_datetime'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN building_type OPTIONS (
    column_name 'building_type'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN building_type_icon_size OPTIONS (
    column_name 'building_type_icon_size'
);
ALTER FOREIGN TABLE strategy.vw_project_detail ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: vw_projects; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vw_projects (
    borough_id integer,
    borough character varying(22),
    id integer,
    ref character varying(30),
    date_added date,
    ward_id integer,
    ward character varying(70),
    overlaparea double precision,
    geom public.geometry(MultiPolygon,27700)
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vw_projects'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN borough_id OPTIONS (
    column_name 'borough_id'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN ref OPTIONS (
    column_name 'ref'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN date_added OPTIONS (
    column_name 'date_added'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN ward_id OPTIONS (
    column_name 'ward_id'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN ward OPTIONS (
    column_name 'ward'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN overlaparea OPTIONS (
    column_name 'overlaparea'
);
ALTER FOREIGN TABLE strategy.vw_projects ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: vw_strategic_clusters_summary; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vw_strategic_clusters_summary (
    cluster_run_id integer,
    cluster_run_name character varying(100),
    cluster_run_description text,
    cluster_run_datetime timestamp without time zone,
    cluster_count bigint,
    total_premises numeric,
    mdu_premises numeric,
    sdu_premises numeric
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vw_strategic_clusters_summary'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN cluster_run_id OPTIONS (
    column_name 'cluster_run_id'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN cluster_run_name OPTIONS (
    column_name 'cluster_run_name'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN cluster_run_description OPTIONS (
    column_name 'cluster_run_description'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN cluster_run_datetime OPTIONS (
    column_name 'cluster_run_datetime'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN cluster_count OPTIONS (
    column_name 'cluster_count'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN total_premises OPTIONS (
    column_name 'total_premises'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN mdu_premises OPTIONS (
    column_name 'mdu_premises'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_summary ALTER COLUMN sdu_premises OPTIONS (
    column_name 'sdu_premises'
);


--
-- Name: vw_strategic_clusters_to_delivery_premises; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises (
    id integer,
    sprn integer,
    fid character varying(20),
    cluster_run_id integer,
    cluster_run_datetime timestamp without time zone,
    cluster_id text,
    address text,
    postcode character varying(8),
    building_type text,
    pia_type text,
    project_id integer,
    lead_project integer,
    status smallint,
    cab_name character varying,
    cab_status integer,
    cab_live_date date,
    classification_code character varying,
    class_description character varying,
    borough character varying(50),
    class_type text,
    geom public.geometry(Point,27700)
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'vw_strategic_clusters_to_delivery_premises'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN sprn OPTIONS (
    column_name 'sprn'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN fid OPTIONS (
    column_name 'fid'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN cluster_run_id OPTIONS (
    column_name 'cluster_run_id'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN cluster_run_datetime OPTIONS (
    column_name 'cluster_run_datetime'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN address OPTIONS (
    column_name 'address'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN postcode OPTIONS (
    column_name 'postcode'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN building_type OPTIONS (
    column_name 'building_type'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN pia_type OPTIONS (
    column_name 'pia_type'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN project_id OPTIONS (
    column_name 'project_id'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN lead_project OPTIONS (
    column_name 'lead_project'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN status OPTIONS (
    column_name 'status'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN cab_name OPTIONS (
    column_name 'cab_name'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN cab_status OPTIONS (
    column_name 'cab_status'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN cab_live_date OPTIONS (
    column_name 'cab_live_date'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN classification_code OPTIONS (
    column_name 'classification_code'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN class_description OPTIONS (
    column_name 'class_description'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN class_type OPTIONS (
    column_name 'class_type'
);
ALTER FOREIGN TABLE strategy.vw_strategic_clusters_to_delivery_premises ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: watford_cluster_check; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.watford_cluster_check (
    name character varying(254),
    id integer,
    cluster_run_id integer,
    cluster_run_datetime timestamp without time zone,
    cluster_id text,
    total_premises numeric,
    mdu_premises numeric,
    mdu_with_wayleave numeric,
    mdu_with_wayleave_t50 numeric,
    mdu_with_wayleave_other numeric,
    sdu_premises numeric,
    mdu_buildings bigint,
    sdu_buildings bigint,
    pia_oh_premises numeric,
    pia_ug_premises numeric,
    civils_premises numeric,
    pia_oh_mdu_premises numeric,
    pia_oh_sdu_premises numeric,
    pia_ug_mdu_premises numeric,
    pia_ug_sdu_premises numeric,
    civils_mdu_premises numeric,
    civils_sdu_premises numeric,
    in_project_premises numeric,
    released_premises numeric,
    cab_name character varying,
    pole_distance double precision,
    duct_distance double precision,
    civils_distance double precision,
    total_distance double precision,
    cluster_capex_budget numeric,
    mdu_low_capex numeric,
    sdu_low_capex numeric,
    capacity_low_capex numeric,
    civils_low_capex numeric,
    pia_ug_low_capex numeric,
    pia_oh_low_capex numeric,
    mdu_high_capex numeric,
    sdu_high_capex numeric,
    capacity_high_capex numeric,
    civils_high_capex numeric,
    pia_ug_high_capex numeric,
    pia_oh_high_capex numeric,
    mdu_wayleave_percent numeric,
    capex_low numeric,
    cppp_low numeric,
    capex_high numeric,
    cppp_high numeric,
    geom public.geometry,
    i public.geometry,
    ia double precision,
    iap double precision,
    r bigint,
    cluster_check text
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'watford_cluster_check'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cluster_run_id OPTIONS (
    column_name 'cluster_run_id'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cluster_run_datetime OPTIONS (
    column_name 'cluster_run_datetime'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN total_premises OPTIONS (
    column_name 'total_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_premises OPTIONS (
    column_name 'mdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_with_wayleave OPTIONS (
    column_name 'mdu_with_wayleave'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_with_wayleave_t50 OPTIONS (
    column_name 'mdu_with_wayleave_t50'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_with_wayleave_other OPTIONS (
    column_name 'mdu_with_wayleave_other'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN sdu_premises OPTIONS (
    column_name 'sdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_buildings OPTIONS (
    column_name 'mdu_buildings'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN sdu_buildings OPTIONS (
    column_name 'sdu_buildings'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_oh_premises OPTIONS (
    column_name 'pia_oh_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_ug_premises OPTIONS (
    column_name 'pia_ug_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN civils_premises OPTIONS (
    column_name 'civils_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_oh_mdu_premises OPTIONS (
    column_name 'pia_oh_mdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_oh_sdu_premises OPTIONS (
    column_name 'pia_oh_sdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_ug_mdu_premises OPTIONS (
    column_name 'pia_ug_mdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_ug_sdu_premises OPTIONS (
    column_name 'pia_ug_sdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN civils_mdu_premises OPTIONS (
    column_name 'civils_mdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN civils_sdu_premises OPTIONS (
    column_name 'civils_sdu_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN in_project_premises OPTIONS (
    column_name 'in_project_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN released_premises OPTIONS (
    column_name 'released_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cab_name OPTIONS (
    column_name 'cab_name'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pole_distance OPTIONS (
    column_name 'pole_distance'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN duct_distance OPTIONS (
    column_name 'duct_distance'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN civils_distance OPTIONS (
    column_name 'civils_distance'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN total_distance OPTIONS (
    column_name 'total_distance'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cluster_capex_budget OPTIONS (
    column_name 'cluster_capex_budget'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_low_capex OPTIONS (
    column_name 'mdu_low_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN sdu_low_capex OPTIONS (
    column_name 'sdu_low_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN capacity_low_capex OPTIONS (
    column_name 'capacity_low_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN civils_low_capex OPTIONS (
    column_name 'civils_low_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_ug_low_capex OPTIONS (
    column_name 'pia_ug_low_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_oh_low_capex OPTIONS (
    column_name 'pia_oh_low_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_high_capex OPTIONS (
    column_name 'mdu_high_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN sdu_high_capex OPTIONS (
    column_name 'sdu_high_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN capacity_high_capex OPTIONS (
    column_name 'capacity_high_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN civils_high_capex OPTIONS (
    column_name 'civils_high_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_ug_high_capex OPTIONS (
    column_name 'pia_ug_high_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN pia_oh_high_capex OPTIONS (
    column_name 'pia_oh_high_capex'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN mdu_wayleave_percent OPTIONS (
    column_name 'mdu_wayleave_percent'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN capex_low OPTIONS (
    column_name 'capex_low'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cppp_low OPTIONS (
    column_name 'cppp_low'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN capex_high OPTIONS (
    column_name 'capex_high'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cppp_high OPTIONS (
    column_name 'cppp_high'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN i OPTIONS (
    column_name 'i'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN ia OPTIONS (
    column_name 'ia'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN iap OPTIONS (
    column_name 'iap'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN r OPTIONS (
    column_name 'r'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check ALTER COLUMN cluster_check OPTIONS (
    column_name 'cluster_check'
);


--
-- Name: watford_cluster_check_db; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.watford_cluster_check_db (
    name character varying(254),
    count numeric,
    cluster_id text,
    total_premises numeric,
    borough text,
    geom public.geometry,
    i public.geometry,
    ia double precision,
    iap double precision,
    r bigint,
    cluster_check text
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'watford_cluster_check_db'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN count OPTIONS (
    column_name 'count'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN cluster_id OPTIONS (
    column_name 'cluster_id'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN total_premises OPTIONS (
    column_name 'total_premises'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN i OPTIONS (
    column_name 'i'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN ia OPTIONS (
    column_name 'ia'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN iap OPTIONS (
    column_name 'iap'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN r OPTIONS (
    column_name 'r'
);
ALTER FOREIGN TABLE strategy.watford_cluster_check_db ALTER COLUMN cluster_check OPTIONS (
    column_name 'cluster_check'
);


--
-- Name: ways_harrow; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.ways_harrow (
    gid bigint,
    geom public.geometry
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'ways_harrow'
);
ALTER FOREIGN TABLE strategy.ways_harrow ALTER COLUMN gid OPTIONS (
    column_name 'gid'
);
ALTER FOREIGN TABLE strategy.ways_harrow ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: ways_havering; Type: FOREIGN TABLE; Schema: strategy; Owner: -
--

CREATE FOREIGN TABLE strategy.ways_havering (
    gid bigint,
    geom public.geometry
)
SERVER geo_db
OPTIONS (
    schema_name 'strategy',
    table_name 'ways_havering'
);
ALTER FOREIGN TABLE strategy.ways_havering ALTER COLUMN gid OPTIONS (
    column_name 'gid'
);
ALTER FOREIGN TABLE strategy.ways_havering ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: Misc; Type: TABLE; Schema: temp; Owner: -
--

CREATE TABLE temp."Misc" (
    id integer NOT NULL,
    geom public.geometry(LineString,27700),
    "Misc" character varying(255)
);


--
-- Name: Misc_id_seq; Type: SEQUENCE; Schema: temp; Owner: -
--

CREATE SEQUENCE temp."Misc_id_seq"
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: Misc_id_seq; Type: SEQUENCE OWNED BY; Schema: temp; Owner: -
--

ALTER SEQUENCE temp."Misc_id_seq" OWNED BY temp."Misc".id;


--
-- Name: Points; Type: TABLE; Schema: temp; Owner: -
--

CREATE TABLE temp."Points" (
    id integer NOT NULL,
    geom public.geometry(Point,27700),
    "Name" character varying(255)
);


--
-- Name: Points_id_seq; Type: SEQUENCE; Schema: temp; Owner: -
--

CREATE SEQUENCE temp."Points_id_seq"
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: Points_id_seq; Type: SEQUENCE OWNED BY; Schema: temp; Owner: -
--

ALTER SEQUENCE temp."Points_id_seq" OWNED BY temp."Points".id;


--
-- Name: Stages; Type: TABLE; Schema: temp; Owner: -
--

CREATE TABLE temp."Stages" (
    id integer NOT NULL,
    geom public.geometry(LineString,27700),
    "StageName" character varying(255)
);


--
-- Name: Stages_id_seq; Type: SEQUENCE; Schema: temp; Owner: -
--

CREATE SEQUENCE temp."Stages_id_seq"
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: Stages_id_seq; Type: SEQUENCE OWNED BY; Schema: temp; Owner: -
--

ALTER SEQUENCE temp."Stages_id_seq" OWNED BY temp."Stages".id;


--
-- Name: cluster_boundary_points; Type: TABLE; Schema: temp; Owner: -
--

CREATE TABLE temp.cluster_boundary_points (
    exchange_1141_code character varying(255),
    geom public.geometry
);


--
-- Name: estimates; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.estimates (
    project_id integer,
    costing_datetime timestamp with time zone,
    total_premises numeric,
    mdu_premises numeric,
    mdu_with_wayleave numeric,
    sdu_premises numeric,
    mdu_buildings bigint,
    sdu_buildings bigint,
    pia_oh_premises numeric,
    pia_ug_l_premises numeric,
    pia_ug_c_premises numeric,
    civils_premises numeric,
    pia_oh_mdu_premises numeric,
    pia_oh_sdu_premises numeric,
    pia_ug_l_mdu_premises numeric,
    pia_ug_l_sdu_premises numeric,
    pia_ug_c_mdu_premises numeric,
    pia_ug_c_sdu_premises numeric,
    civils_mdu_premises numeric,
    civils_sdu_premises numeric,
    cab_name character varying,
    total_distance numeric,
    cluster_capex_budget numeric,
    mdu_low_capex numeric,
    sdu_low_capex numeric,
    capacity_low_capex numeric,
    civils_low_capex numeric,
    pia_ug_low_capex numeric,
    pia_oh_low_capex numeric,
    mdu_high_capex numeric,
    sdu_high_capex numeric,
    capacity_high_capex numeric,
    civils_high_capex numeric,
    pia_ug_high_capex numeric,
    pia_oh_high_capex numeric,
    mdu_wayleave_percent numeric,
    capex_low numeric,
    cppp_low numeric,
    capex_high numeric,
    cppp_high numeric,
    percent_ugl_to_ugc character varying(100),
    fibre_count integer,
    distribution_distance numeric,
    distribution_capex_low numeric,
    distribution_cppp_low numeric,
    distribution_capex_high numeric,
    distribution_cppp_high numeric
)
SERVER geo_server
OPTIONS (
    schema_name 'temp',
    table_name 'estimates'
);


--
-- Name: geography_columns; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.geography_columns (
    f_table_catalog name,
    f_table_schema name,
    f_table_name name,
    f_geography_column name,
    coord_dimension integer,
    srid integer,
    type text
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'geography_columns'
);
ALTER FOREIGN TABLE temp.geography_columns ALTER COLUMN f_table_catalog OPTIONS (
    column_name 'f_table_catalog'
);
ALTER FOREIGN TABLE temp.geography_columns ALTER COLUMN f_table_schema OPTIONS (
    column_name 'f_table_schema'
);
ALTER FOREIGN TABLE temp.geography_columns ALTER COLUMN f_table_name OPTIONS (
    column_name 'f_table_name'
);
ALTER FOREIGN TABLE temp.geography_columns ALTER COLUMN f_geography_column OPTIONS (
    column_name 'f_geography_column'
);
ALTER FOREIGN TABLE temp.geography_columns ALTER COLUMN coord_dimension OPTIONS (
    column_name 'coord_dimension'
);
ALTER FOREIGN TABLE temp.geography_columns ALTER COLUMN srid OPTIONS (
    column_name 'srid'
);
ALTER FOREIGN TABLE temp.geography_columns ALTER COLUMN type OPTIONS (
    column_name 'type'
);


--
-- Name: geometry_columns; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.geometry_columns (
    f_table_catalog character varying(256) COLLATE pg_catalog."C",
    f_table_schema name,
    f_table_name name,
    f_geometry_column name,
    coord_dimension integer,
    srid integer,
    type character varying(30)
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'geometry_columns'
);
ALTER FOREIGN TABLE temp.geometry_columns ALTER COLUMN f_table_catalog OPTIONS (
    column_name 'f_table_catalog'
);
ALTER FOREIGN TABLE temp.geometry_columns ALTER COLUMN f_table_schema OPTIONS (
    column_name 'f_table_schema'
);
ALTER FOREIGN TABLE temp.geometry_columns ALTER COLUMN f_table_name OPTIONS (
    column_name 'f_table_name'
);
ALTER FOREIGN TABLE temp.geometry_columns ALTER COLUMN f_geometry_column OPTIONS (
    column_name 'f_geometry_column'
);
ALTER FOREIGN TABLE temp.geometry_columns ALTER COLUMN coord_dimension OPTIONS (
    column_name 'coord_dimension'
);
ALTER FOREIGN TABLE temp.geometry_columns ALTER COLUMN srid OPTIONS (
    column_name 'srid'
);
ALTER FOREIGN TABLE temp.geometry_columns ALTER COLUMN type OPTIONS (
    column_name 'type'
);


--
-- Name: openreach_duct_test_vertices_pgr_main_component; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.openreach_duct_test_vertices_pgr_main_component (
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'openreach_duct_test_vertices_pgr_main_component'
);


--
-- Name: pia_structure_clusters_stg0; Type: TABLE; Schema: temp; Owner: -
--

CREATE TABLE temp.pia_structure_clusters_stg0 (
    objectid bigint,
    exchange_1141_code character varying(255),
    object_class character varying(255),
    type_name character varying(255),
    category_name character varying(255),
    geom public.geometry,
    cid integer
);


--
-- Name: pia_structure_clusters_stg1; Type: TABLE; Schema: temp; Owner: -
--

CREATE TABLE temp.pia_structure_clusters_stg1 (
    exchange_1141_code character varying(255),
    cid integer,
    cluster_count bigint,
    geom public.geometry,
    r bigint,
    t numeric,
    p numeric
);


--
-- Name: pia_structure_clusters_stg1_test; Type: TABLE; Schema: temp; Owner: -
--

CREATE TABLE temp.pia_structure_clusters_stg1_test (
    exchange_1141_code character varying(255),
    geom public.geometry
);


--
-- Name: planet_osm_line; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.planet_osm_line (
    osm_id bigint,
    access text,
    "addr:housename" text,
    "addr:housenumber" text,
    "addr:interpolation" text,
    admin_level text,
    aerialway text,
    aeroway text,
    amenity text,
    area text,
    barrier text,
    bicycle text,
    brand text,
    bridge text,
    boundary text,
    building text,
    construction text,
    covered text,
    culvert text,
    cutting text,
    denomination text,
    disused text,
    embankment text,
    foot text,
    "generator:source" text,
    harbour text,
    highway text,
    maxspeed text,
    historic text,
    horse text,
    intermittent text,
    junction text,
    landuse text,
    layer text,
    leisure text,
    lock text,
    man_made text,
    military text,
    motorcar text,
    name text,
    "natural" text,
    office text,
    oneway text,
    operator text,
    place text,
    population text,
    power text,
    power_source text,
    public_transport text,
    railway text,
    ref text,
    religion text,
    route text,
    service text,
    shop text,
    sport text,
    surface text,
    toll text,
    tourism text,
    "tower:type" text,
    tracktype text,
    tunnel text,
    water text,
    waterway text,
    wetland text,
    width text,
    wood text,
    z_order integer,
    way_area real,
    way public.geometry(LineString,3857)
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'planet_osm_line'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN osm_id OPTIONS (
    column_name 'osm_id'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN access OPTIONS (
    column_name 'access'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN "addr:housename" OPTIONS (
    column_name 'addr:housename'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN "addr:housenumber" OPTIONS (
    column_name 'addr:housenumber'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN "addr:interpolation" OPTIONS (
    column_name 'addr:interpolation'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN admin_level OPTIONS (
    column_name 'admin_level'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN aerialway OPTIONS (
    column_name 'aerialway'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN aeroway OPTIONS (
    column_name 'aeroway'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN amenity OPTIONS (
    column_name 'amenity'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN area OPTIONS (
    column_name 'area'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN barrier OPTIONS (
    column_name 'barrier'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN bicycle OPTIONS (
    column_name 'bicycle'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN brand OPTIONS (
    column_name 'brand'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN bridge OPTIONS (
    column_name 'bridge'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN boundary OPTIONS (
    column_name 'boundary'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN building OPTIONS (
    column_name 'building'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN construction OPTIONS (
    column_name 'construction'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN covered OPTIONS (
    column_name 'covered'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN culvert OPTIONS (
    column_name 'culvert'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN cutting OPTIONS (
    column_name 'cutting'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN denomination OPTIONS (
    column_name 'denomination'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN disused OPTIONS (
    column_name 'disused'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN embankment OPTIONS (
    column_name 'embankment'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN foot OPTIONS (
    column_name 'foot'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN "generator:source" OPTIONS (
    column_name 'generator:source'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN harbour OPTIONS (
    column_name 'harbour'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN highway OPTIONS (
    column_name 'highway'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN maxspeed OPTIONS (
    column_name 'maxspeed'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN historic OPTIONS (
    column_name 'historic'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN horse OPTIONS (
    column_name 'horse'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN intermittent OPTIONS (
    column_name 'intermittent'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN junction OPTIONS (
    column_name 'junction'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN landuse OPTIONS (
    column_name 'landuse'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN layer OPTIONS (
    column_name 'layer'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN leisure OPTIONS (
    column_name 'leisure'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN lock OPTIONS (
    column_name 'lock'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN man_made OPTIONS (
    column_name 'man_made'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN military OPTIONS (
    column_name 'military'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN motorcar OPTIONS (
    column_name 'motorcar'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN "natural" OPTIONS (
    column_name 'natural'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN office OPTIONS (
    column_name 'office'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN oneway OPTIONS (
    column_name 'oneway'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN operator OPTIONS (
    column_name 'operator'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN place OPTIONS (
    column_name 'place'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN population OPTIONS (
    column_name 'population'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN power OPTIONS (
    column_name 'power'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN power_source OPTIONS (
    column_name 'power_source'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN public_transport OPTIONS (
    column_name 'public_transport'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN railway OPTIONS (
    column_name 'railway'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN ref OPTIONS (
    column_name 'ref'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN religion OPTIONS (
    column_name 'religion'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN route OPTIONS (
    column_name 'route'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN service OPTIONS (
    column_name 'service'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN shop OPTIONS (
    column_name 'shop'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN sport OPTIONS (
    column_name 'sport'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN surface OPTIONS (
    column_name 'surface'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN toll OPTIONS (
    column_name 'toll'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN tourism OPTIONS (
    column_name 'tourism'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN "tower:type" OPTIONS (
    column_name 'tower:type'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN tracktype OPTIONS (
    column_name 'tracktype'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN tunnel OPTIONS (
    column_name 'tunnel'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN water OPTIONS (
    column_name 'water'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN waterway OPTIONS (
    column_name 'waterway'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN wetland OPTIONS (
    column_name 'wetland'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN width OPTIONS (
    column_name 'width'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN wood OPTIONS (
    column_name 'wood'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN z_order OPTIONS (
    column_name 'z_order'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN way_area OPTIONS (
    column_name 'way_area'
);
ALTER FOREIGN TABLE temp.planet_osm_line ALTER COLUMN way OPTIONS (
    column_name 'way'
);


--
-- Name: planet_osm_point; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.planet_osm_point (
    osm_id bigint,
    access text,
    "addr:housename" text,
    "addr:housenumber" text,
    "addr:interpolation" text,
    admin_level text,
    aerialway text,
    aeroway text,
    amenity text,
    area text,
    barrier text,
    bicycle text,
    brand text,
    bridge text,
    boundary text,
    building text,
    capital text,
    construction text,
    covered text,
    culvert text,
    cutting text,
    denomination text,
    disused text,
    ele text,
    embankment text,
    foot text,
    "generator:source" text,
    harbour text,
    highway text,
    maxspeed text,
    historic text,
    horse text,
    intermittent text,
    junction text,
    landuse text,
    layer text,
    leisure text,
    lock text,
    man_made text,
    military text,
    motorcar text,
    name text,
    "natural" text,
    office text,
    oneway text,
    operator text,
    place text,
    population text,
    power text,
    power_source text,
    public_transport text,
    railway text,
    ref text,
    religion text,
    route text,
    service text,
    shop text,
    sport text,
    surface text,
    toll text,
    tourism text,
    "tower:type" text,
    tunnel text,
    water text,
    waterway text,
    wetland text,
    width text,
    wood text,
    z_order integer,
    way public.geometry(Point,3857)
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'planet_osm_point'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN osm_id OPTIONS (
    column_name 'osm_id'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN access OPTIONS (
    column_name 'access'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN "addr:housename" OPTIONS (
    column_name 'addr:housename'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN "addr:housenumber" OPTIONS (
    column_name 'addr:housenumber'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN "addr:interpolation" OPTIONS (
    column_name 'addr:interpolation'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN admin_level OPTIONS (
    column_name 'admin_level'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN aerialway OPTIONS (
    column_name 'aerialway'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN aeroway OPTIONS (
    column_name 'aeroway'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN amenity OPTIONS (
    column_name 'amenity'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN area OPTIONS (
    column_name 'area'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN barrier OPTIONS (
    column_name 'barrier'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN bicycle OPTIONS (
    column_name 'bicycle'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN brand OPTIONS (
    column_name 'brand'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN bridge OPTIONS (
    column_name 'bridge'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN boundary OPTIONS (
    column_name 'boundary'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN building OPTIONS (
    column_name 'building'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN capital OPTIONS (
    column_name 'capital'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN construction OPTIONS (
    column_name 'construction'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN covered OPTIONS (
    column_name 'covered'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN culvert OPTIONS (
    column_name 'culvert'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN cutting OPTIONS (
    column_name 'cutting'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN denomination OPTIONS (
    column_name 'denomination'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN disused OPTIONS (
    column_name 'disused'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN ele OPTIONS (
    column_name 'ele'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN embankment OPTIONS (
    column_name 'embankment'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN foot OPTIONS (
    column_name 'foot'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN "generator:source" OPTIONS (
    column_name 'generator:source'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN harbour OPTIONS (
    column_name 'harbour'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN highway OPTIONS (
    column_name 'highway'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN maxspeed OPTIONS (
    column_name 'maxspeed'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN historic OPTIONS (
    column_name 'historic'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN horse OPTIONS (
    column_name 'horse'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN intermittent OPTIONS (
    column_name 'intermittent'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN junction OPTIONS (
    column_name 'junction'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN landuse OPTIONS (
    column_name 'landuse'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN layer OPTIONS (
    column_name 'layer'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN leisure OPTIONS (
    column_name 'leisure'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN lock OPTIONS (
    column_name 'lock'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN man_made OPTIONS (
    column_name 'man_made'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN military OPTIONS (
    column_name 'military'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN motorcar OPTIONS (
    column_name 'motorcar'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN "natural" OPTIONS (
    column_name 'natural'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN office OPTIONS (
    column_name 'office'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN oneway OPTIONS (
    column_name 'oneway'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN operator OPTIONS (
    column_name 'operator'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN place OPTIONS (
    column_name 'place'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN population OPTIONS (
    column_name 'population'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN power OPTIONS (
    column_name 'power'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN power_source OPTIONS (
    column_name 'power_source'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN public_transport OPTIONS (
    column_name 'public_transport'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN railway OPTIONS (
    column_name 'railway'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN ref OPTIONS (
    column_name 'ref'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN religion OPTIONS (
    column_name 'religion'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN route OPTIONS (
    column_name 'route'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN service OPTIONS (
    column_name 'service'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN shop OPTIONS (
    column_name 'shop'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN sport OPTIONS (
    column_name 'sport'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN surface OPTIONS (
    column_name 'surface'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN toll OPTIONS (
    column_name 'toll'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN tourism OPTIONS (
    column_name 'tourism'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN "tower:type" OPTIONS (
    column_name 'tower:type'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN tunnel OPTIONS (
    column_name 'tunnel'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN water OPTIONS (
    column_name 'water'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN waterway OPTIONS (
    column_name 'waterway'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN wetland OPTIONS (
    column_name 'wetland'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN width OPTIONS (
    column_name 'width'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN wood OPTIONS (
    column_name 'wood'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN z_order OPTIONS (
    column_name 'z_order'
);
ALTER FOREIGN TABLE temp.planet_osm_point ALTER COLUMN way OPTIONS (
    column_name 'way'
);


--
-- Name: planet_osm_polygon; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.planet_osm_polygon (
    osm_id bigint,
    access text,
    "addr:housename" text,
    "addr:housenumber" text,
    "addr:interpolation" text,
    admin_level text,
    aerialway text,
    aeroway text,
    amenity text,
    area text,
    barrier text,
    bicycle text,
    brand text,
    bridge text,
    boundary text,
    building text,
    construction text,
    covered text,
    culvert text,
    cutting text,
    denomination text,
    disused text,
    embankment text,
    foot text,
    "generator:source" text,
    harbour text,
    highway text,
    maxspeed text,
    historic text,
    horse text,
    intermittent text,
    junction text,
    landuse text,
    layer text,
    leisure text,
    lock text,
    man_made text,
    military text,
    motorcar text,
    name text,
    "natural" text,
    office text,
    oneway text,
    operator text,
    place text,
    population text,
    power text,
    power_source text,
    public_transport text,
    railway text,
    ref text,
    religion text,
    route text,
    service text,
    shop text,
    sport text,
    surface text,
    toll text,
    tourism text,
    "tower:type" text,
    tracktype text,
    tunnel text,
    water text,
    waterway text,
    wetland text,
    width text,
    wood text,
    z_order integer,
    way_area real,
    way public.geometry(Geometry,3857)
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'planet_osm_polygon'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN osm_id OPTIONS (
    column_name 'osm_id'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN access OPTIONS (
    column_name 'access'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN "addr:housename" OPTIONS (
    column_name 'addr:housename'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN "addr:housenumber" OPTIONS (
    column_name 'addr:housenumber'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN "addr:interpolation" OPTIONS (
    column_name 'addr:interpolation'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN admin_level OPTIONS (
    column_name 'admin_level'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN aerialway OPTIONS (
    column_name 'aerialway'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN aeroway OPTIONS (
    column_name 'aeroway'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN amenity OPTIONS (
    column_name 'amenity'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN area OPTIONS (
    column_name 'area'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN barrier OPTIONS (
    column_name 'barrier'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN bicycle OPTIONS (
    column_name 'bicycle'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN brand OPTIONS (
    column_name 'brand'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN bridge OPTIONS (
    column_name 'bridge'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN boundary OPTIONS (
    column_name 'boundary'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN building OPTIONS (
    column_name 'building'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN construction OPTIONS (
    column_name 'construction'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN covered OPTIONS (
    column_name 'covered'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN culvert OPTIONS (
    column_name 'culvert'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN cutting OPTIONS (
    column_name 'cutting'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN denomination OPTIONS (
    column_name 'denomination'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN disused OPTIONS (
    column_name 'disused'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN embankment OPTIONS (
    column_name 'embankment'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN foot OPTIONS (
    column_name 'foot'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN "generator:source" OPTIONS (
    column_name 'generator:source'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN harbour OPTIONS (
    column_name 'harbour'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN highway OPTIONS (
    column_name 'highway'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN maxspeed OPTIONS (
    column_name 'maxspeed'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN historic OPTIONS (
    column_name 'historic'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN horse OPTIONS (
    column_name 'horse'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN intermittent OPTIONS (
    column_name 'intermittent'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN junction OPTIONS (
    column_name 'junction'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN landuse OPTIONS (
    column_name 'landuse'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN layer OPTIONS (
    column_name 'layer'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN leisure OPTIONS (
    column_name 'leisure'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN lock OPTIONS (
    column_name 'lock'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN man_made OPTIONS (
    column_name 'man_made'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN military OPTIONS (
    column_name 'military'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN motorcar OPTIONS (
    column_name 'motorcar'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN "natural" OPTIONS (
    column_name 'natural'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN office OPTIONS (
    column_name 'office'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN oneway OPTIONS (
    column_name 'oneway'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN operator OPTIONS (
    column_name 'operator'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN place OPTIONS (
    column_name 'place'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN population OPTIONS (
    column_name 'population'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN power OPTIONS (
    column_name 'power'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN power_source OPTIONS (
    column_name 'power_source'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN public_transport OPTIONS (
    column_name 'public_transport'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN railway OPTIONS (
    column_name 'railway'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN ref OPTIONS (
    column_name 'ref'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN religion OPTIONS (
    column_name 'religion'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN route OPTIONS (
    column_name 'route'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN service OPTIONS (
    column_name 'service'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN shop OPTIONS (
    column_name 'shop'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN sport OPTIONS (
    column_name 'sport'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN surface OPTIONS (
    column_name 'surface'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN toll OPTIONS (
    column_name 'toll'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN tourism OPTIONS (
    column_name 'tourism'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN "tower:type" OPTIONS (
    column_name 'tower:type'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN tracktype OPTIONS (
    column_name 'tracktype'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN tunnel OPTIONS (
    column_name 'tunnel'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN water OPTIONS (
    column_name 'water'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN waterway OPTIONS (
    column_name 'waterway'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN wetland OPTIONS (
    column_name 'wetland'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN width OPTIONS (
    column_name 'width'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN wood OPTIONS (
    column_name 'wood'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN z_order OPTIONS (
    column_name 'z_order'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN way_area OPTIONS (
    column_name 'way_area'
);
ALTER FOREIGN TABLE temp.planet_osm_polygon ALTER COLUMN way OPTIONS (
    column_name 'way'
);


--
-- Name: planet_osm_roads; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.planet_osm_roads (
    osm_id bigint,
    access text,
    "addr:housename" text,
    "addr:housenumber" text,
    "addr:interpolation" text,
    admin_level text,
    aerialway text,
    aeroway text,
    amenity text,
    area text,
    barrier text,
    bicycle text,
    brand text,
    bridge text,
    boundary text,
    building text,
    construction text,
    covered text,
    culvert text,
    cutting text,
    denomination text,
    disused text,
    embankment text,
    foot text,
    "generator:source" text,
    harbour text,
    highway text,
    maxspeed text,
    historic text,
    horse text,
    intermittent text,
    junction text,
    landuse text,
    layer text,
    leisure text,
    lock text,
    man_made text,
    military text,
    motorcar text,
    name text,
    "natural" text,
    office text,
    oneway text,
    operator text,
    place text,
    population text,
    power text,
    power_source text,
    public_transport text,
    railway text,
    ref text,
    religion text,
    route text,
    service text,
    shop text,
    sport text,
    surface text,
    toll text,
    tourism text,
    "tower:type" text,
    tracktype text,
    tunnel text,
    water text,
    waterway text,
    wetland text,
    width text,
    wood text,
    z_order integer,
    way_area real,
    way public.geometry(LineString,3857)
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'planet_osm_roads'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN osm_id OPTIONS (
    column_name 'osm_id'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN access OPTIONS (
    column_name 'access'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN "addr:housename" OPTIONS (
    column_name 'addr:housename'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN "addr:housenumber" OPTIONS (
    column_name 'addr:housenumber'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN "addr:interpolation" OPTIONS (
    column_name 'addr:interpolation'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN admin_level OPTIONS (
    column_name 'admin_level'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN aerialway OPTIONS (
    column_name 'aerialway'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN aeroway OPTIONS (
    column_name 'aeroway'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN amenity OPTIONS (
    column_name 'amenity'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN area OPTIONS (
    column_name 'area'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN barrier OPTIONS (
    column_name 'barrier'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN bicycle OPTIONS (
    column_name 'bicycle'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN brand OPTIONS (
    column_name 'brand'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN bridge OPTIONS (
    column_name 'bridge'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN boundary OPTIONS (
    column_name 'boundary'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN building OPTIONS (
    column_name 'building'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN construction OPTIONS (
    column_name 'construction'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN covered OPTIONS (
    column_name 'covered'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN culvert OPTIONS (
    column_name 'culvert'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN cutting OPTIONS (
    column_name 'cutting'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN denomination OPTIONS (
    column_name 'denomination'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN disused OPTIONS (
    column_name 'disused'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN embankment OPTIONS (
    column_name 'embankment'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN foot OPTIONS (
    column_name 'foot'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN "generator:source" OPTIONS (
    column_name 'generator:source'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN harbour OPTIONS (
    column_name 'harbour'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN highway OPTIONS (
    column_name 'highway'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN maxspeed OPTIONS (
    column_name 'maxspeed'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN historic OPTIONS (
    column_name 'historic'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN horse OPTIONS (
    column_name 'horse'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN intermittent OPTIONS (
    column_name 'intermittent'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN junction OPTIONS (
    column_name 'junction'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN landuse OPTIONS (
    column_name 'landuse'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN layer OPTIONS (
    column_name 'layer'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN leisure OPTIONS (
    column_name 'leisure'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN lock OPTIONS (
    column_name 'lock'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN man_made OPTIONS (
    column_name 'man_made'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN military OPTIONS (
    column_name 'military'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN motorcar OPTIONS (
    column_name 'motorcar'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN name OPTIONS (
    column_name 'name'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN "natural" OPTIONS (
    column_name 'natural'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN office OPTIONS (
    column_name 'office'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN oneway OPTIONS (
    column_name 'oneway'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN operator OPTIONS (
    column_name 'operator'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN place OPTIONS (
    column_name 'place'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN population OPTIONS (
    column_name 'population'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN power OPTIONS (
    column_name 'power'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN power_source OPTIONS (
    column_name 'power_source'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN public_transport OPTIONS (
    column_name 'public_transport'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN railway OPTIONS (
    column_name 'railway'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN ref OPTIONS (
    column_name 'ref'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN religion OPTIONS (
    column_name 'religion'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN route OPTIONS (
    column_name 'route'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN service OPTIONS (
    column_name 'service'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN shop OPTIONS (
    column_name 'shop'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN sport OPTIONS (
    column_name 'sport'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN surface OPTIONS (
    column_name 'surface'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN toll OPTIONS (
    column_name 'toll'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN tourism OPTIONS (
    column_name 'tourism'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN "tower:type" OPTIONS (
    column_name 'tower:type'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN tracktype OPTIONS (
    column_name 'tracktype'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN tunnel OPTIONS (
    column_name 'tunnel'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN water OPTIONS (
    column_name 'water'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN waterway OPTIONS (
    column_name 'waterway'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN wetland OPTIONS (
    column_name 'wetland'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN width OPTIONS (
    column_name 'width'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN wood OPTIONS (
    column_name 'wood'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN z_order OPTIONS (
    column_name 'z_order'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN way_area OPTIONS (
    column_name 'way_area'
);
ALTER FOREIGN TABLE temp.planet_osm_roads ALTER COLUMN way OPTIONS (
    column_name 'way'
);


--
-- Name: pt; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.pt (
    id integer,
    hp_date date,
    uprn bigint,
    door_number character varying,
    postcode character varying,
    type character varying,
    block character varying,
    geom public.geometry(Point,27700),
    address text,
    status smallint NOT NULL,
    borough text,
    business_name text,
    main_proprietor text,
    last_status_update text,
    comment text,
    date_added date,
    project_id integer,
    portfolio_id integer,
    business_live integer,
    bd_status smallint,
    sprn integer NOT NULL,
    splitter_id text,
    sales_status smallint NOT NULL,
    declared_live_date date,
    install_type smallint NOT NULL,
    planning_ecd date,
    civils_done boolean NOT NULL,
    cabled boolean NOT NULL,
    spliced boolean NOT NULL,
    tested boolean NOT NULL,
    on_hold boolean NOT NULL,
    on_hold_category smallint,
    on_hold_subcategory smallint,
    on_hold_start date,
    on_hold_revisit date,
    on_hold_stop date,
    last_updater character varying,
    last_update_timestamp timestamp without time zone,
    mdu_id integer,
    forecast_live_date date,
    wayleave_date date,
    main_leaseholder text,
    leaseholder_managed boolean NOT NULL,
    provider integer
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'pt'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN hp_date OPTIONS (
    column_name 'hp_date'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN uprn OPTIONS (
    column_name 'uprn'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN door_number OPTIONS (
    column_name 'door_number'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN postcode OPTIONS (
    column_name 'postcode'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN type OPTIONS (
    column_name 'type'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN block OPTIONS (
    column_name 'block'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN address OPTIONS (
    column_name 'address'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN status OPTIONS (
    column_name 'status'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN business_name OPTIONS (
    column_name 'business_name'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN main_proprietor OPTIONS (
    column_name 'main_proprietor'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN last_status_update OPTIONS (
    column_name 'last_status_update'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN comment OPTIONS (
    column_name 'comment'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN date_added OPTIONS (
    column_name 'date_added'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN project_id OPTIONS (
    column_name 'project_id'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN portfolio_id OPTIONS (
    column_name 'portfolio_id'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN business_live OPTIONS (
    column_name 'business_live'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN bd_status OPTIONS (
    column_name 'bd_status'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN sprn OPTIONS (
    column_name 'sprn'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN splitter_id OPTIONS (
    column_name 'splitter_id'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN sales_status OPTIONS (
    column_name 'sales_status'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN declared_live_date OPTIONS (
    column_name 'declared_live_date'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN install_type OPTIONS (
    column_name 'install_type'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN planning_ecd OPTIONS (
    column_name 'planning_ecd'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN civils_done OPTIONS (
    column_name 'civils_done'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN cabled OPTIONS (
    column_name 'cabled'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN spliced OPTIONS (
    column_name 'spliced'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN tested OPTIONS (
    column_name 'tested'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN on_hold OPTIONS (
    column_name 'on_hold'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN on_hold_category OPTIONS (
    column_name 'on_hold_category'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN on_hold_subcategory OPTIONS (
    column_name 'on_hold_subcategory'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN on_hold_start OPTIONS (
    column_name 'on_hold_start'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN on_hold_revisit OPTIONS (
    column_name 'on_hold_revisit'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN on_hold_stop OPTIONS (
    column_name 'on_hold_stop'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN last_updater OPTIONS (
    column_name 'last_updater'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN last_update_timestamp OPTIONS (
    column_name 'last_update_timestamp'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN mdu_id OPTIONS (
    column_name 'mdu_id'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN forecast_live_date OPTIONS (
    column_name 'forecast_live_date'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN wayleave_date OPTIONS (
    column_name 'wayleave_date'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN main_leaseholder OPTIONS (
    column_name 'main_leaseholder'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN leaseholder_managed OPTIONS (
    column_name 'leaseholder_managed'
);
ALTER FOREIGN TABLE temp.pt ALTER COLUMN provider OPTIONS (
    column_name 'provider'
);


--
-- Name: pt_backup; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.pt_backup (
    id integer,
    hp_date date,
    uprn bigint,
    door_number character varying,
    postcode character varying,
    type character varying,
    block character varying,
    geom public.geometry(Point,27700),
    address text,
    status smallint,
    borough text,
    business_name text,
    main_proprietor text,
    last_status_update text,
    comment text,
    date_added date,
    project_id integer,
    portfolio_id integer,
    business_live integer,
    bd_status smallint,
    sprn integer,
    splitter_id text,
    sales_status smallint,
    declared_live_date date,
    install_type smallint,
    planning_ecd date,
    civils_done boolean,
    cabled boolean,
    spliced boolean,
    tested boolean,
    on_hold boolean,
    on_hold_category smallint,
    on_hold_subcategory smallint,
    on_hold_start date,
    on_hold_revisit date,
    on_hold_stop date,
    last_updater character varying,
    last_update_timestamp timestamp without time zone,
    mdu_id integer,
    forecast_live_date date,
    wayleave_date date
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'pt_backup'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN hp_date OPTIONS (
    column_name 'hp_date'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN uprn OPTIONS (
    column_name 'uprn'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN door_number OPTIONS (
    column_name 'door_number'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN postcode OPTIONS (
    column_name 'postcode'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN type OPTIONS (
    column_name 'type'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN block OPTIONS (
    column_name 'block'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN address OPTIONS (
    column_name 'address'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN status OPTIONS (
    column_name 'status'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN business_name OPTIONS (
    column_name 'business_name'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN main_proprietor OPTIONS (
    column_name 'main_proprietor'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN last_status_update OPTIONS (
    column_name 'last_status_update'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN comment OPTIONS (
    column_name 'comment'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN date_added OPTIONS (
    column_name 'date_added'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN project_id OPTIONS (
    column_name 'project_id'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN portfolio_id OPTIONS (
    column_name 'portfolio_id'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN business_live OPTIONS (
    column_name 'business_live'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN bd_status OPTIONS (
    column_name 'bd_status'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN sprn OPTIONS (
    column_name 'sprn'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN splitter_id OPTIONS (
    column_name 'splitter_id'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN sales_status OPTIONS (
    column_name 'sales_status'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN declared_live_date OPTIONS (
    column_name 'declared_live_date'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN install_type OPTIONS (
    column_name 'install_type'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN planning_ecd OPTIONS (
    column_name 'planning_ecd'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN civils_done OPTIONS (
    column_name 'civils_done'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN cabled OPTIONS (
    column_name 'cabled'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN spliced OPTIONS (
    column_name 'spliced'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN tested OPTIONS (
    column_name 'tested'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN on_hold OPTIONS (
    column_name 'on_hold'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN on_hold_category OPTIONS (
    column_name 'on_hold_category'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN on_hold_subcategory OPTIONS (
    column_name 'on_hold_subcategory'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN on_hold_start OPTIONS (
    column_name 'on_hold_start'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN on_hold_revisit OPTIONS (
    column_name 'on_hold_revisit'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN on_hold_stop OPTIONS (
    column_name 'on_hold_stop'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN last_updater OPTIONS (
    column_name 'last_updater'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN last_update_timestamp OPTIONS (
    column_name 'last_update_timestamp'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN mdu_id OPTIONS (
    column_name 'mdu_id'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN forecast_live_date OPTIONS (
    column_name 'forecast_live_date'
);
ALTER FOREIGN TABLE temp.pt_backup ALTER COLUMN wayleave_date OPTIONS (
    column_name 'wayleave_date'
);


--
-- Name: pt_dates; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.pt_dates (
    id integer NOT NULL,
    address text,
    borough text,
    date_added date,
    hp_start_date date,
    hp_date date,
    last_update text,
    latest_status smallint,
    to20 date,
    to40 date,
    to50 date,
    to60 date,
    tolive date,
    to_sales_status_3 timestamp without time zone,
    to30 date,
    to45 date,
    status_downgrade timestamp without time zone
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'pt_dates'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN address OPTIONS (
    column_name 'address'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN borough OPTIONS (
    column_name 'borough'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN date_added OPTIONS (
    column_name 'date_added'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN hp_start_date OPTIONS (
    column_name 'hp_start_date'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN hp_date OPTIONS (
    column_name 'hp_date'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN last_update OPTIONS (
    column_name 'last_update'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN latest_status OPTIONS (
    column_name 'latest_status'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN to20 OPTIONS (
    column_name 'to20'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN to40 OPTIONS (
    column_name 'to40'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN to50 OPTIONS (
    column_name 'to50'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN to60 OPTIONS (
    column_name 'to60'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN tolive OPTIONS (
    column_name 'tolive'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN to_sales_status_3 OPTIONS (
    column_name 'to_sales_status_3'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN to30 OPTIONS (
    column_name 'to30'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN to45 OPTIONS (
    column_name 'to45'
);
ALTER FOREIGN TABLE temp.pt_dates ALTER COLUMN status_downgrade OPTIONS (
    column_name 'status_downgrade'
);


--
-- Name: pt_live_postcodes; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.pt_live_postcodes (
    postcode character varying,
    geom public.geometry(Point,27700)
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'pt_live_postcodes'
);
ALTER FOREIGN TABLE temp.pt_live_postcodes ALTER COLUMN postcode OPTIONS (
    column_name 'postcode'
);
ALTER FOREIGN TABLE temp.pt_live_postcodes ALTER COLUMN geom OPTIONS (
    column_name 'geom'
);


--
-- Name: raster_columns; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.raster_columns (
    r_table_catalog name,
    r_table_schema name,
    r_table_name name,
    r_raster_column name,
    srid integer,
    scale_x double precision,
    scale_y double precision,
    blocksize_x integer,
    blocksize_y integer,
    same_alignment boolean,
    regular_blocking boolean,
    num_bands integer,
    pixel_types text[] COLLATE pg_catalog."C",
    nodata_values double precision[],
    out_db boolean[],
    extent public.geometry,
    spatial_index boolean
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'raster_columns'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN r_table_catalog OPTIONS (
    column_name 'r_table_catalog'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN r_table_schema OPTIONS (
    column_name 'r_table_schema'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN r_table_name OPTIONS (
    column_name 'r_table_name'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN r_raster_column OPTIONS (
    column_name 'r_raster_column'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN srid OPTIONS (
    column_name 'srid'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN scale_x OPTIONS (
    column_name 'scale_x'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN scale_y OPTIONS (
    column_name 'scale_y'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN blocksize_x OPTIONS (
    column_name 'blocksize_x'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN blocksize_y OPTIONS (
    column_name 'blocksize_y'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN same_alignment OPTIONS (
    column_name 'same_alignment'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN regular_blocking OPTIONS (
    column_name 'regular_blocking'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN num_bands OPTIONS (
    column_name 'num_bands'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN pixel_types OPTIONS (
    column_name 'pixel_types'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN nodata_values OPTIONS (
    column_name 'nodata_values'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN out_db OPTIONS (
    column_name 'out_db'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN extent OPTIONS (
    column_name 'extent'
);
ALTER FOREIGN TABLE temp.raster_columns ALTER COLUMN spatial_index OPTIONS (
    column_name 'spatial_index'
);


--
-- Name: raster_overviews; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.raster_overviews (
    o_table_catalog name,
    o_table_schema name,
    o_table_name name,
    o_raster_column name,
    r_table_catalog name,
    r_table_schema name COLLATE pg_catalog."default",
    r_table_name name COLLATE pg_catalog."default",
    r_raster_column name COLLATE pg_catalog."default",
    overview_factor integer
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'raster_overviews'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN o_table_catalog OPTIONS (
    column_name 'o_table_catalog'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN o_table_schema OPTIONS (
    column_name 'o_table_schema'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN o_table_name OPTIONS (
    column_name 'o_table_name'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN o_raster_column OPTIONS (
    column_name 'o_raster_column'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN r_table_catalog OPTIONS (
    column_name 'r_table_catalog'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN r_table_schema OPTIONS (
    column_name 'r_table_schema'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN r_table_name OPTIONS (
    column_name 'r_table_name'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN r_raster_column OPTIONS (
    column_name 'r_raster_column'
);
ALTER FOREIGN TABLE temp.raster_overviews ALTER COLUMN overview_factor OPTIONS (
    column_name 'overview_factor'
);


--
-- Name: route_optimizer_template; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.route_optimizer_template (
    start_id integer,
    start_geom public.geometry,
    start_postcode text,
    dest_id integer,
    dest_geom public.geometry,
    dest_postcode text,
    route public.geometry,
    route_distance double precision
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'route_optimizer_template'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN start_id OPTIONS (
    column_name 'start_id'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN start_geom OPTIONS (
    column_name 'start_geom'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN start_postcode OPTIONS (
    column_name 'start_postcode'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN dest_id OPTIONS (
    column_name 'dest_id'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN dest_geom OPTIONS (
    column_name 'dest_geom'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN dest_postcode OPTIONS (
    column_name 'dest_postcode'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN route OPTIONS (
    column_name 'route'
);
ALTER FOREIGN TABLE temp.route_optimizer_template ALTER COLUMN route_distance OPTIONS (
    column_name 'route_distance'
);


--
-- Name: spatial_ref_sys; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.spatial_ref_sys (
    srid integer NOT NULL,
    auth_name character varying(256),
    auth_srid integer,
    srtext character varying(2048),
    proj4text character varying(2048)
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'spatial_ref_sys'
);
ALTER FOREIGN TABLE temp.spatial_ref_sys ALTER COLUMN srid OPTIONS (
    column_name 'srid'
);
ALTER FOREIGN TABLE temp.spatial_ref_sys ALTER COLUMN auth_name OPTIONS (
    column_name 'auth_name'
);
ALTER FOREIGN TABLE temp.spatial_ref_sys ALTER COLUMN auth_srid OPTIONS (
    column_name 'auth_srid'
);
ALTER FOREIGN TABLE temp.spatial_ref_sys ALTER COLUMN srtext OPTIONS (
    column_name 'srtext'
);
ALTER FOREIGN TABLE temp.spatial_ref_sys ALTER COLUMN proj4text OPTIONS (
    column_name 'proj4text'
);


--
-- Name: temp_routes_326807; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.temp_routes_326807 (
    start_id bigint,
    start_geom public.geometry,
    start_postcode character varying(12),
    start_node bigint,
    dest_id bigint,
    dest_geom public.geometry,
    dest_postcode character varying(12),
    dest_node bigint,
    route public.geometry,
    route_distance numeric,
    route_time double precision
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'temp_routes_326807'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN start_id OPTIONS (
    column_name 'start_id'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN start_geom OPTIONS (
    column_name 'start_geom'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN start_postcode OPTIONS (
    column_name 'start_postcode'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN start_node OPTIONS (
    column_name 'start_node'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN dest_id OPTIONS (
    column_name 'dest_id'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN dest_geom OPTIONS (
    column_name 'dest_geom'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN dest_postcode OPTIONS (
    column_name 'dest_postcode'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN dest_node OPTIONS (
    column_name 'dest_node'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN route OPTIONS (
    column_name 'route'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN route_distance OPTIONS (
    column_name 'route_distance'
);
ALTER FOREIGN TABLE temp.temp_routes_326807 ALTER COLUMN route_time OPTIONS (
    column_name 'route_time'
);


--
-- Name: temp_routes_733750; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.temp_routes_733750 (
    start_id bigint,
    start_geom public.geometry,
    start_postcode character varying(12),
    start_node bigint,
    dest_id bigint,
    dest_geom public.geometry,
    dest_postcode character varying(12),
    dest_node bigint,
    route public.geometry,
    route_distance numeric,
    route_time double precision
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'temp_routes_733750'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN start_id OPTIONS (
    column_name 'start_id'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN start_geom OPTIONS (
    column_name 'start_geom'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN start_postcode OPTIONS (
    column_name 'start_postcode'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN start_node OPTIONS (
    column_name 'start_node'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN dest_id OPTIONS (
    column_name 'dest_id'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN dest_geom OPTIONS (
    column_name 'dest_geom'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN dest_postcode OPTIONS (
    column_name 'dest_postcode'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN dest_node OPTIONS (
    column_name 'dest_node'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN route OPTIONS (
    column_name 'route'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN route_distance OPTIONS (
    column_name 'route_distance'
);
ALTER FOREIGN TABLE temp.temp_routes_733750 ALTER COLUMN route_time OPTIONS (
    column_name 'route_time'
);


--
-- Name: us_gaz; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.us_gaz (
    id integer NOT NULL,
    seq integer,
    word text,
    stdword text,
    token integer,
    is_custom boolean NOT NULL
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'us_gaz'
);
ALTER FOREIGN TABLE temp.us_gaz ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE temp.us_gaz ALTER COLUMN seq OPTIONS (
    column_name 'seq'
);
ALTER FOREIGN TABLE temp.us_gaz ALTER COLUMN word OPTIONS (
    column_name 'word'
);
ALTER FOREIGN TABLE temp.us_gaz ALTER COLUMN stdword OPTIONS (
    column_name 'stdword'
);
ALTER FOREIGN TABLE temp.us_gaz ALTER COLUMN token OPTIONS (
    column_name 'token'
);
ALTER FOREIGN TABLE temp.us_gaz ALTER COLUMN is_custom OPTIONS (
    column_name 'is_custom'
);


--
-- Name: us_lex; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.us_lex (
    id integer NOT NULL,
    seq integer,
    word text,
    stdword text,
    token integer,
    is_custom boolean NOT NULL
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'us_lex'
);
ALTER FOREIGN TABLE temp.us_lex ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE temp.us_lex ALTER COLUMN seq OPTIONS (
    column_name 'seq'
);
ALTER FOREIGN TABLE temp.us_lex ALTER COLUMN word OPTIONS (
    column_name 'word'
);
ALTER FOREIGN TABLE temp.us_lex ALTER COLUMN stdword OPTIONS (
    column_name 'stdword'
);
ALTER FOREIGN TABLE temp.us_lex ALTER COLUMN token OPTIONS (
    column_name 'token'
);
ALTER FOREIGN TABLE temp.us_lex ALTER COLUMN is_custom OPTIONS (
    column_name 'is_custom'
);


--
-- Name: us_rules; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.us_rules (
    id integer NOT NULL,
    rule text,
    is_custom boolean NOT NULL
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'us_rules'
);
ALTER FOREIGN TABLE temp.us_rules ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE temp.us_rules ALTER COLUMN rule OPTIONS (
    column_name 'rule'
);
ALTER FOREIGN TABLE temp.us_rules ALTER COLUMN is_custom OPTIONS (
    column_name 'is_custom'
);


--
-- Name: users; Type: FOREIGN TABLE; Schema: temp; Owner: -
--

CREATE FOREIGN TABLE temp.users (
    id bigint NOT NULL,
    username character varying(100) NOT NULL,
    manager character varying(100) NOT NULL,
    email character varying(50) NOT NULL,
    company integer NOT NULL,
    access_level integer NOT NULL,
    division integer NOT NULL,
    team integer NOT NULL,
    password character varying(255) NOT NULL,
    is_active integer NOT NULL,
    date_user_created timestamp without time zone,
    date_last_login timestamp without time zone,
    date_last_active timestamp without time zone
)
SERVER geo_db
OPTIONS (
    schema_name 'public',
    table_name 'users'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN id OPTIONS (
    column_name 'id'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN username OPTIONS (
    column_name 'username'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN manager OPTIONS (
    column_name 'manager'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN email OPTIONS (
    column_name 'email'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN company OPTIONS (
    column_name 'company'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN access_level OPTIONS (
    column_name 'access_level'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN division OPTIONS (
    column_name 'division'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN team OPTIONS (
    column_name 'team'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN password OPTIONS (
    column_name 'password'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN is_active OPTIONS (
    column_name 'is_active'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN date_user_created OPTIONS (
    column_name 'date_user_created'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN date_last_login OPTIONS (
    column_name 'date_last_login'
);
ALTER FOREIGN TABLE temp.users ALTER COLUMN date_last_active OPTIONS (
    column_name 'date_last_active'
);


--
-- Name: active_sessions; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.active_sessions (
    session_record_id bigint NOT NULL,
    user_id bigint NOT NULL,
    session_id character varying(128) NOT NULL,
    login_log_id bigint,
    created_at timestamp without time zone DEFAULT now(),
    last_seen_at timestamp without time zone DEFAULT now()
);


--
-- Name: active_sessions_session_record_id_seq; Type: SEQUENCE; Schema: users; Owner: -
--

CREATE SEQUENCE users.active_sessions_session_record_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: active_sessions_session_record_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: -
--

ALTER SEQUENCE users.active_sessions_session_record_id_seq OWNED BY users.active_sessions.session_record_id;


--
-- Name: companies_company_id_seq; Type: SEQUENCE; Schema: users; Owner: -
--

CREATE SEQUENCE users.companies_company_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: companies_company_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: -
--

ALTER SEQUENCE users.companies_company_id_seq OWNED BY users.companies.company_id;


--
-- Name: role_permissions; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.role_permissions (
    permission_id integer NOT NULL,
    role_id integer NOT NULL,
    module character varying(50) NOT NULL,
    permission_level character varying(10) DEFAULT 'read'::character varying NOT NULL
);


--
-- Name: role_permissions_permission_id_seq; Type: SEQUENCE; Schema: users; Owner: -
--

CREATE SEQUENCE users.role_permissions_permission_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: role_permissions_permission_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: -
--

ALTER SEQUENCE users.role_permissions_permission_id_seq OWNED BY users.role_permissions.permission_id;


--
-- Name: roles; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.roles (
    role_id integer NOT NULL,
    role_name character varying,
    role_description character varying
);


--
-- Name: roles_role_id_seq; Type: SEQUENCE; Schema: users; Owner: -
--

CREATE SEQUENCE users.roles_role_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: roles_role_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: -
--

ALTER SEQUENCE users.roles_role_id_seq OWNED BY users.roles.role_id;


--
-- Name: user_item_permissions; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.user_item_permissions (
    permission_id bigint NOT NULL,
    user_id bigint NOT NULL,
    item_type character varying(20) NOT NULL,
    item_id integer NOT NULL,
    permission_level character varying(10) DEFAULT 'read'::character varying NOT NULL,
    granted_datetime timestamp without time zone DEFAULT now(),
    granted_by bigint
);


--
-- Name: user_item_permissions_permission_id_seq; Type: SEQUENCE; Schema: users; Owner: -
--

CREATE SEQUENCE users.user_item_permissions_permission_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: user_item_permissions_permission_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: -
--

ALTER SEQUENCE users.user_item_permissions_permission_id_seq OWNED BY users.user_item_permissions.permission_id;


--
-- Name: user_roles; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.user_roles (
    user_id bigint NOT NULL,
    role_id integer NOT NULL,
    granted_datetime timestamp without time zone DEFAULT now(),
    granted_by bigint
);


--
-- Name: users_backup_20260312; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.users_backup_20260312 (
    id bigint,
    username character varying(100),
    manager character varying(100),
    email character varying(50),
    company integer,
    role integer,
    division integer,
    team integer,
    password character varying(255),
    is_active integer,
    date_user_created timestamp without time zone,
    date_last_login timestamp without time zone,
    date_last_active timestamp without time zone
);


--
-- Name: users_backup_20260312_b; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.users_backup_20260312_b (
    user_id bigint,
    username character varying(100),
    manager character varying(100),
    email character varying(50),
    company integer,
    role integer,
    division integer,
    team integer,
    password character varying(255),
    is_active integer,
    date_user_created timestamp without time zone,
    date_last_login timestamp without time zone,
    date_last_active timestamp without time zone
);


--
-- Name: users_id_seq; Type: SEQUENCE; Schema: users; Owner: -
--

CREATE SEQUENCE users.users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: -
--

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


--
-- Name: users_login_log; Type: TABLE; Schema: users; Owner: -
--

CREATE TABLE users.users_login_log (
    user_id integer NOT NULL,
    ip_address inet,
    user_agent text,
    accept_language text,
    "timestamp" timestamp without time zone,
    id bigint NOT NULL,
    session_id character varying(128),
    last_active_datetime timestamp without time zone,
    logout_at timestamp without time zone,
    logout_reason character varying(30)
);


--
-- Name: users_login_log_id_seq; Type: SEQUENCE; Schema: users; Owner: -
--

CREATE SEQUENCE users.users_login_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: users_login_log_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: -
--

ALTER SEQUENCE users.users_login_log_id_seq OWNED BY users.users_login_log.id;


--
-- Name: agreement_access_log; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_access_log (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    user_id integer,
    access_type character varying(50),
    access_datetime timestamp without time zone DEFAULT now()
);


--
-- Name: agreement_access_log_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_access_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_access_log_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_access_log_id_seq OWNED BY wayleave.agreement_access_log.id;


--
-- Name: agreement_field_category; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_category (
    id integer NOT NULL,
    section_id integer,
    category_name character varying(150) NOT NULL,
    display_order integer DEFAULT 0 NOT NULL,
    is_active boolean DEFAULT true NOT NULL
);


--
-- Name: agreement_field_category_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_category_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_category_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_category_id_seq OWNED BY wayleave.agreement_field_category.id;


--
-- Name: agreement_field_dropdown_options; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_dropdown_options (
    id integer NOT NULL,
    field_id integer NOT NULL,
    option_value character varying(250) NOT NULL,
    option_label character varying(250) NOT NULL,
    display_order integer DEFAULT 0 NOT NULL,
    is_active boolean DEFAULT true NOT NULL
);


--
-- Name: agreement_field_dropdown_options_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_dropdown_options_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_dropdown_options_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_dropdown_options_id_seq OWNED BY wayleave.agreement_field_dropdown_options.id;


--
-- Name: agreement_field_sections; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_sections (
    id integer NOT NULL,
    section_name character varying(150) NOT NULL,
    display_order integer DEFAULT 0 NOT NULL,
    is_active boolean DEFAULT true NOT NULL
);


--
-- Name: agreement_field_sections_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_sections_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_sections_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_sections_id_seq OWNED BY wayleave.agreement_field_sections.id;


--
-- Name: agreement_field_sub_category; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_sub_category (
    id integer NOT NULL,
    category_id integer,
    sub_category_name character varying(150) NOT NULL,
    display_order integer DEFAULT 0 NOT NULL,
    is_active boolean DEFAULT true NOT NULL
);


--
-- Name: agreement_field_sub_category_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_sub_category_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_sub_category_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_sub_category_id_seq OWNED BY wayleave.agreement_field_sub_category.id;


--
-- Name: agreement_field_values_boolean; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_boolean (
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value boolean,
    modified_datetime timestamp without time zone DEFAULT now() NOT NULL,
    modified_user integer NOT NULL
);


--
-- Name: agreement_field_values_boolean_history; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_boolean_history (
    history_id bigint NOT NULL,
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value boolean,
    history_action character varying(20) NOT NULL,
    history_datetime timestamp without time zone DEFAULT now() NOT NULL,
    history_user integer NOT NULL
);


--
-- Name: agreement_field_values_boolean_history_history_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_values_boolean_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_values_boolean_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_values_boolean_history_history_id_seq OWNED BY wayleave.agreement_field_values_boolean_history.history_id;


--
-- Name: agreement_field_values_date; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_date (
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value date,
    modified_datetime timestamp without time zone DEFAULT now() NOT NULL,
    modified_user integer NOT NULL
);


--
-- Name: agreement_field_values_date_history; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_date_history (
    history_id bigint NOT NULL,
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value date,
    history_action character varying(20) NOT NULL,
    history_datetime timestamp without time zone DEFAULT now() NOT NULL,
    history_user integer NOT NULL
);


--
-- Name: agreement_field_values_date_history_history_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_values_date_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_values_date_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_values_date_history_history_id_seq OWNED BY wayleave.agreement_field_values_date_history.history_id;


--
-- Name: agreement_field_values_int; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_int (
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value bigint,
    modified_datetime timestamp without time zone DEFAULT now() NOT NULL,
    modified_user integer NOT NULL
);


--
-- Name: agreement_field_values_int_history; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_int_history (
    history_id bigint NOT NULL,
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value bigint,
    history_action character varying(20) NOT NULL,
    history_datetime timestamp without time zone DEFAULT now() NOT NULL,
    history_user integer NOT NULL
);


--
-- Name: agreement_field_values_int_history_history_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_values_int_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_values_int_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_values_int_history_history_id_seq OWNED BY wayleave.agreement_field_values_int_history.history_id;


--
-- Name: agreement_field_values_numeric; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_numeric (
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value numeric(20,6),
    modified_datetime timestamp without time zone DEFAULT now() NOT NULL,
    modified_user integer NOT NULL
);


--
-- Name: agreement_field_values_numeric_history; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_numeric_history (
    history_id bigint NOT NULL,
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value numeric(20,6),
    history_action character varying(20) NOT NULL,
    history_datetime timestamp without time zone DEFAULT now() NOT NULL,
    history_user integer NOT NULL
);


--
-- Name: agreement_field_values_numeric_history_history_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_values_numeric_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_values_numeric_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_values_numeric_history_history_id_seq OWNED BY wayleave.agreement_field_values_numeric_history.history_id;


--
-- Name: agreement_field_values_text; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_text (
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value text,
    modified_datetime timestamp without time zone DEFAULT now() NOT NULL,
    modified_user integer NOT NULL
);


--
-- Name: agreement_field_values_text_history; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_field_values_text_history (
    history_id bigint NOT NULL,
    agreement_id integer NOT NULL,
    field_id integer NOT NULL,
    field_value text,
    history_action character varying(20) NOT NULL,
    history_datetime timestamp without time zone DEFAULT now() NOT NULL,
    history_user integer NOT NULL
);


--
-- Name: agreement_field_values_text_history_history_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_field_values_text_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_field_values_text_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_field_values_text_history_history_id_seq OWNED BY wayleave.agreement_field_values_text_history.history_id;


--
-- Name: agreement_fields; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_fields (
    field_id integer NOT NULL,
    field_section integer,
    field_category integer,
    field_sub_category integer,
    field_display_order integer DEFAULT 0 NOT NULL,
    field_data_type character varying(20) NOT NULL,
    field_name character varying(200) NOT NULL,
    field_form_id character varying(100) NOT NULL,
    field_input_type character varying(30) NOT NULL,
    field_required boolean DEFAULT false NOT NULL,
    field_active boolean DEFAULT true NOT NULL,
    field_spacer_after boolean DEFAULT false NOT NULL,
    field_type character varying(20) DEFAULT 'dynamic'::character varying NOT NULL
);


--
-- Name: agreement_fields_field_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_fields_field_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_fields_field_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_fields_field_id_seq OWNED BY wayleave.agreement_fields.field_id;


--
-- Name: agreement_journal; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_journal (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    user_id integer NOT NULL,
    log_datetime timestamp without time zone DEFAULT now() NOT NULL,
    log_text text NOT NULL,
    is_system boolean DEFAULT false NOT NULL
);


--
-- Name: agreement_journal_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_journal_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_journal_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_journal_id_seq OWNED BY wayleave.agreement_journal.id;


--
-- Name: agreement_landregistry; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_landregistry (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    title_number character varying(50) NOT NULL,
    tenure character varying(20),
    added_user integer NOT NULL,
    added_datetime timestamp without time zone DEFAULT now() NOT NULL,
    is_deleted boolean DEFAULT false NOT NULL
);


--
-- Name: agreement_landregistry_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_landregistry_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_landregistry_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_landregistry_id_seq OWNED BY wayleave.agreement_landregistry.id;


--
-- Name: agreement_polygon_uprns; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_polygon_uprns (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    uprn bigint NOT NULL,
    is_assigned boolean DEFAULT true NOT NULL,
    is_approved boolean DEFAULT false NOT NULL,
    actioned_user_id integer NOT NULL,
    action_datetime timestamp without time zone DEFAULT now() NOT NULL,
    approved_user_id integer,
    approved_datetime timestamp without time zone
);


--
-- Name: agreement_polygon_uprns_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_polygon_uprns_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_polygon_uprns_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_polygon_uprns_id_seq OWNED BY wayleave.agreement_polygon_uprns.id;


--
-- Name: agreement_polygons; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_polygons (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    geom public.geometry(Polygon,27700) NOT NULL,
    label character varying(250),
    added_user integer NOT NULL,
    added_datetime timestamp without time zone DEFAULT now() NOT NULL,
    modified_user integer,
    modified_datetime timestamp without time zone,
    is_deleted boolean DEFAULT false NOT NULL
);


--
-- Name: agreement_polygons_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_polygons_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_polygons_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_polygons_id_seq OWNED BY wayleave.agreement_polygons.id;


--
-- Name: agreement_releases; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_releases (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    uprn bigint NOT NULL,
    release_date date,
    sales_ref character varying(100),
    pic_ref character varying(100),
    notes text,
    released_user integer,
    released_datetime timestamp without time zone,
    created_datetime timestamp without time zone DEFAULT now() NOT NULL,
    created_user integer NOT NULL,
    modified_datetime timestamp without time zone,
    modified_user integer,
    is_deleted boolean DEFAULT false NOT NULL
);


--
-- Name: agreement_releases_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_releases_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_releases_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_releases_id_seq OWNED BY wayleave.agreement_releases.id;


--
-- Name: agreement_status; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_status (
    id integer NOT NULL,
    description character varying(100) NOT NULL,
    display_order integer DEFAULT 0 NOT NULL,
    is_active boolean DEFAULT true NOT NULL
);


--
-- Name: agreement_status_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_status_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_status_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_status_id_seq OWNED BY wayleave.agreement_status.id;


--
-- Name: agreement_stocklists; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_stocklists (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    stocklist_id integer NOT NULL,
    added_user integer NOT NULL,
    added_datetime timestamp without time zone DEFAULT now() NOT NULL,
    is_deleted boolean DEFAULT false NOT NULL
);


--
-- Name: agreement_stocklists_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_stocklists_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_stocklists_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_stocklists_id_seq OWNED BY wayleave.agreement_stocklists.id;


--
-- Name: agreement_uprns; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreement_uprns (
    id bigint NOT NULL,
    agreement_id integer NOT NULL,
    uprn bigint NOT NULL,
    added_user integer NOT NULL,
    added_datetime timestamp without time zone DEFAULT now() NOT NULL,
    is_deleted boolean DEFAULT false NOT NULL
);


--
-- Name: agreement_uprns_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreement_uprns_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreement_uprns_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreement_uprns_id_seq OWNED BY wayleave.agreement_uprns.id;


--
-- Name: agreements; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreements (
    agreement_id integer NOT NULL,
    agreement_name character varying(250) NOT NULL,
    agreement_reference character varying(100),
    agreement_status_id integer,
    agreement_type character varying(50),
    wayleave_team character varying(100),
    bd_manager integer,
    ecd_date date,
    signed_date date,
    geom public.geometry(MultiPolygon,27700),
    parent_agreement_id integer,
    company_id integer,
    account_id integer,
    is_deleted boolean DEFAULT false NOT NULL,
    created_datetime timestamp without time zone DEFAULT now() NOT NULL,
    created_user integer NOT NULL,
    modified_datetime timestamp without time zone DEFAULT now() NOT NULL,
    modified_user integer NOT NULL
);


--
-- Name: agreements_agreement_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreements_agreement_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreements_agreement_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreements_agreement_id_seq OWNED BY wayleave.agreements.agreement_id;


--
-- Name: agreements_history; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.agreements_history (
    history_id bigint NOT NULL,
    agreement_id integer NOT NULL,
    agreement_name character varying(250),
    agreement_reference character varying(100),
    agreement_status_id integer,
    agreement_type character varying(50),
    wayleave_team character varying(100),
    bd_manager integer,
    ecd_date date,
    signed_date date,
    parent_agreement_id integer,
    company_id integer,
    account_id integer,
    is_deleted boolean,
    history_action character varying(20) NOT NULL,
    history_field character varying(100),
    history_old_value text,
    history_new_value text,
    history_datetime timestamp without time zone DEFAULT now() NOT NULL,
    history_user integer NOT NULL
);


--
-- Name: agreements_history_history_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.agreements_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: agreements_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.agreements_history_history_id_seq OWNED BY wayleave.agreements_history.history_id;


--
-- Name: teams; Type: TABLE; Schema: wayleave; Owner: -
--

CREATE TABLE wayleave.teams (
    id integer NOT NULL,
    team_name character varying(100) NOT NULL,
    display_order integer DEFAULT 0 NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_datetime timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: teams_id_seq; Type: SEQUENCE; Schema: wayleave; Owner: -
--

CREATE SEQUENCE wayleave.teams_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: teams_id_seq; Type: SEQUENCE OWNED BY; Schema: wayleave; Owner: -
--

ALTER SEQUENCE wayleave.teams_id_seq OWNED BY wayleave.teams.id;


--
-- Name: vw_agreement_polygons; Type: VIEW; Schema: wayleave; Owner: -
--

CREATE VIEW wayleave.vw_agreement_polygons AS
 SELECT agreement_polygons.id,
    agreement_polygons.agreement_id,
    agreement_polygons.label,
    agreement_polygons.geom
   FROM wayleave.agreement_polygons
  WHERE (agreement_polygons.is_deleted = false);


--
-- Name: vw_file_uploads; Type: VIEW; Schema: wayleave; Owner: -
--

CREATE VIEW wayleave.vw_file_uploads AS
 SELECT fu.id,
    fu.file_id,
    to_char(fu.file_upload_datetime, 'DD mon YYYY HH24:MI'::text) AS file_upload_datetime,
    fu.file_upload_datetime AS file_upload_datetime_raw,
    u.username,
    fu.file_upload_user,
    fu.file_name,
    fu.file_type,
    fu.agreement_id,
    fu.file_category,
    fu.file_description,
    fu.file_size,
    fu.file_size_raw,
    fu.file_location
   FROM (public.file_uploads fu
     LEFT JOIN users.users u ON ((fu.file_upload_user = u.id)))
  WHERE (((fu.entity)::text = 'wayleave'::text) AND (fu.file_is_deleted = false))
  ORDER BY fu.file_upload_datetime DESC;


--
-- Name: vw_uprns_from_boundary; Type: VIEW; Schema: wayleave; Owner: -
--

CREATE VIEW wayleave.vw_uprns_from_boundary AS
 SELECT apu.agreement_id,
    apu.uprn,
    apu.is_approved,
    abp.address AS address_full,
    abp.geom,
        CASE
            WHEN (r.uprn IS NOT NULL) THEN true
            ELSE false
        END AS released
   FROM ((wayleave.agreement_polygon_uprns apu
     JOIN basedata.abp abp ON ((abp.uprn = apu.uprn)))
     LEFT JOIN wayleave.agreement_releases r ON (((r.agreement_id = apu.agreement_id) AND (r.uprn = apu.uprn) AND (r.is_deleted = false))))
  WHERE (apu.is_assigned = true);


--
-- Name: vw_uprns_from_direct; Type: VIEW; Schema: wayleave; Owner: -
--

CREATE VIEW wayleave.vw_uprns_from_direct AS
 SELECT au.agreement_id,
    au.uprn,
    abp.address AS address_full,
    abp.geom,
        CASE
            WHEN (r.uprn IS NOT NULL) THEN true
            ELSE false
        END AS released
   FROM ((wayleave.agreement_uprns au
     JOIN basedata.abp abp ON ((abp.uprn = au.uprn)))
     LEFT JOIN wayleave.agreement_releases r ON (((r.agreement_id = au.agreement_id) AND (r.uprn = au.uprn) AND (r.is_deleted = false))))
  WHERE (au.is_deleted = false);


--
-- Name: vw_uprns_from_stocklists; Type: VIEW; Schema: wayleave; Owner: -
--

CREATE VIEW wayleave.vw_uprns_from_stocklists AS
 SELECT ast.agreement_id,
    sp.uprn,
    abp.address AS address_full,
    abp.geom,
        CASE
            WHEN (r.uprn IS NOT NULL) THEN true
            ELSE false
        END AS released
   FROM (((wayleave.agreement_stocklists ast
     JOIN stocklists.stocklist_premises sp ON ((sp.stocklist_id = ast.stocklist_id)))
     JOIN basedata.abp abp ON ((abp.uprn = sp.uprn)))
     LEFT JOIN wayleave.agreement_releases r ON (((r.agreement_id = ast.agreement_id) AND (r.uprn = sp.uprn) AND (r.is_deleted = false))))
  WHERE (ast.is_deleted = false);


--
-- Name: vw_uprns_from_titles; Type: VIEW; Schema: wayleave; Owner: -
--

CREATE VIEW wayleave.vw_uprns_from_titles AS
 SELECT alr.agreement_id,
    abp.uprn,
    abp.address AS address_full,
    abp.geom,
        CASE
            WHEN (r.uprn IS NOT NULL) THEN true
            ELSE false
        END AS released
   FROM ((wayleave.agreement_landregistry alr
     JOIN basedata.abp abp ON ((abp.title_no = (alr.title_number)::text)))
     LEFT JOIN wayleave.agreement_releases r ON (((r.agreement_id = alr.agreement_id) AND (r.uprn = abp.uprn) AND (r.is_deleted = false))))
  WHERE ((alr.is_deleted = false) AND (abp.uprn IS NOT NULL));


--
-- Name: account_access_log id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_access_log ALTER COLUMN id SET DEFAULT nextval('accounts.account_access_log_id_seq'::regclass);


--
-- Name: account_field_category field_category_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_category ALTER COLUMN field_category_id SET DEFAULT nextval('accounts.account_field_category_field_category_id_seq'::regclass);


--
-- Name: account_field_dropdown_options dropdown_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_dropdown_options ALTER COLUMN dropdown_id SET DEFAULT nextval('accounts.account_field_dropdown_options_dropdown_id_seq'::regclass);


--
-- Name: account_field_sections field_section_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_sections ALTER COLUMN field_section_id SET DEFAULT nextval('accounts.account_field_sections_field_section_id_seq'::regclass);


--
-- Name: account_field_sub_category field_sub_category_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_sub_category ALTER COLUMN field_sub_category_id SET DEFAULT nextval('accounts.account_field_sub_category_field_sub_category_id_seq'::regclass);


--
-- Name: account_field_values_boolean value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_boolean_value_id_seq'::regclass);


--
-- Name: account_field_values_boolean_history value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean_history ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_boolean_history_value_id_seq'::regclass);


--
-- Name: account_field_values_date value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_date_value_id_seq'::regclass);


--
-- Name: account_field_values_date_history value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date_history ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_date_history_value_id_seq'::regclass);


--
-- Name: account_field_values_int value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_int_value_id_seq'::regclass);


--
-- Name: account_field_values_int_history value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int_history ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_int_history_value_id_seq'::regclass);


--
-- Name: account_field_values_numeric value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_numeric_value_id_seq'::regclass);


--
-- Name: account_field_values_numeric_history value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric_history ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_numeric_history_value_id_seq'::regclass);


--
-- Name: account_field_values_text value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_text_value_id_seq'::regclass);


--
-- Name: account_field_values_text_history value_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text_history ALTER COLUMN value_id SET DEFAULT nextval('accounts.account_field_values_text_history_value_id_seq'::regclass);


--
-- Name: account_fields field_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_fields ALTER COLUMN field_id SET DEFAULT nextval('accounts.account_fields_field_id_seq'::regclass);


--
-- Name: account_journal id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_journal ALTER COLUMN id SET DEFAULT nextval('accounts.newtable_id_seq'::regclass);


--
-- Name: accounts account_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts ALTER COLUMN account_id SET DEFAULT nextval('accounts.accounts_account_id_seq'::regclass);


--
-- Name: accounts_history account_id; Type: DEFAULT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts_history ALTER COLUMN account_id SET DEFAULT nextval('accounts.accounts_history_account_id_seq'::regclass);


--
-- Name: openreach id; Type: DEFAULT; Schema: competitor_data; Owner: -
--

ALTER TABLE ONLY competitor_data.openreach ALTER COLUMN id SET DEFAULT nextval('competitor_data.openreach_id_seq'::regclass);


--
-- Name: ccod_address_matches match_id; Type: DEFAULT; Schema: landregistry; Owner: -
--

ALTER TABLE ONLY landregistry.ccod_address_matches ALTER COLUMN match_id SET DEFAULT nextval('landregistry.ccod_address_matches_match_id_seq'::regclass);


--
-- Name: duct_segment_test id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_segment_test ALTER COLUMN id SET DEFAULT nextval('openreach.duct_segment_test_id_seq'::regclass);


--
-- Name: duct_segment_test_vertices_pgr id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_segment_test_vertices_pgr ALTER COLUMN id SET DEFAULT nextval('openreach.duct_segment_test_vertices_pgr_id_seq'::regclass);


--
-- Name: duct_test_vertices_pgr id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_test_vertices_pgr ALTER COLUMN id SET DEFAULT nextval('openreach.duct_test_vertices_pgr_id_seq'::regclass);


--
-- Name: duct_vertices_pgr id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_vertices_pgr ALTER COLUMN id SET DEFAULT nextval('openreach.duct_vertices_pgr_id_seq'::regclass);


--
-- Name: import_duct id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.import_duct ALTER COLUMN id SET DEFAULT nextval('openreach.import_duct_id_seq'::regclass);


--
-- Name: import_structure id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.import_structure ALTER COLUMN id SET DEFAULT nextval('openreach.import_structure_id_seq'::regclass);


--
-- Name: span_coupler fid; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.span_coupler ALTER COLUMN fid SET DEFAULT nextval('openreach.span_coupler_fid_seq'::regclass);


--
-- Name: spans id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.spans ALTER COLUMN id SET DEFAULT nextval('openreach.spans_fid_seq'::regclass);


--
-- Name: spans_vertices_pgr id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.spans_vertices_pgr ALTER COLUMN id SET DEFAULT nextval('openreach.spans_vertices_pgr_id_seq'::regclass);


--
-- Name: subset_vertices_pgr id; Type: DEFAULT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.subset_vertices_pgr ALTER COLUMN id SET DEFAULT nextval('openreach.subset_vertices_pgr_id_seq'::regclass);


--
-- Name: project_access_log id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_access_log ALTER COLUMN id SET DEFAULT nextval('projects.project_access_log_id_seq'::regclass);


--
-- Name: project_field_category field_category_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_category ALTER COLUMN field_category_id SET DEFAULT nextval('projects.project_field_category_field_category_id_seq'::regclass);


--
-- Name: project_field_dropdown_options dropdown_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_dropdown_options ALTER COLUMN dropdown_id SET DEFAULT nextval('projects.project_field_dropdown_options_dropdown_id_seq'::regclass);


--
-- Name: project_field_sections field_section_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_sections ALTER COLUMN field_section_id SET DEFAULT nextval('projects.project_field_sections_field_section_id_seq'::regclass);


--
-- Name: project_field_sub_category field_sub_category_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_sub_category ALTER COLUMN field_sub_category_id SET DEFAULT nextval('projects.newtable_field_sub_category_id_seq'::regclass);


--
-- Name: project_field_values_boolean value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_boolean_value_id_seq'::regclass);


--
-- Name: project_field_values_boolean_history value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean_history ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_boolean_history_value_id_seq'::regclass);


--
-- Name: project_field_values_date value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_date_value_id_seq'::regclass);


--
-- Name: project_field_values_date_history value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date_history ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_date_history_value_id_seq'::regclass);


--
-- Name: project_field_values_int value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_int_value_id_seq'::regclass);


--
-- Name: project_field_values_int_history value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int_history ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_int_history_value_id_seq'::regclass);


--
-- Name: project_field_values_numeric value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_numeric_value_id_seq'::regclass);


--
-- Name: project_field_values_numeric_history value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric_history ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_numeric_history_value_id_seq'::regclass);


--
-- Name: project_field_values_text value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_text_value_id_seq'::regclass);


--
-- Name: project_field_values_text_history value_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text_history ALTER COLUMN value_id SET DEFAULT nextval('projects.project_field_values_text_history_value_id_seq'::regclass);


--
-- Name: project_fields field_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_fields ALTER COLUMN field_id SET DEFAULT nextval('projects.project_fields_field_id_seq'::regclass);


--
-- Name: project_file_uploads id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_file_uploads ALTER COLUMN id SET DEFAULT nextval('projects.project_file_uploads_id_seq'::regclass);


--
-- Name: project_journal id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_journal ALTER COLUMN id SET DEFAULT nextval('projects.project_journal_id_seq'::regclass);


--
-- Name: projects project_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects ALTER COLUMN project_id SET DEFAULT nextval('projects.projects_project_id_seq'::regclass);


--
-- Name: projects_history history_id; Type: DEFAULT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects_history ALTER COLUMN history_id SET DEFAULT nextval('projects.projects_history_history_id_seq'::regclass);


--
-- Name: network_cables cable_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_cables ALTER COLUMN cable_id SET DEFAULT nextval('prospector.network_cables_cable_id_seq'::regclass);


--
-- Name: network_cables_history history_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_cables_history ALTER COLUMN history_id SET DEFAULT nextval('prospector.network_cables_history_history_id_seq'::regclass);


--
-- Name: network_duct duct_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_duct ALTER COLUMN duct_id SET DEFAULT nextval('prospector.network_duct_duct_id_seq'::regclass);


--
-- Name: network_points point_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_points ALTER COLUMN point_id SET DEFAULT nextval('prospector.network_points_point_id_seq'::regclass);


--
-- Name: network_structures structure_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_structures ALTER COLUMN structure_id SET DEFAULT nextval('prospector.network_structures_structure_id_seq'::regclass);


--
-- Name: network_subduct subduct_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_subduct ALTER COLUMN subduct_id SET DEFAULT nextval('prospector.network_subduct_subduct_id_seq'::regclass);


--
-- Name: opportunity opportunity_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.opportunity ALTER COLUMN opportunity_id SET DEFAULT nextval('prospector.opportunity_opportunity_id_seq'::regclass);


--
-- Name: opportunity_access_log id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.opportunity_access_log ALTER COLUMN id SET DEFAULT nextval('prospector.opportunity_access_log_id_seq'::regclass);


--
-- Name: opportunity_project_link id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.opportunity_project_link ALTER COLUMN id SET DEFAULT nextval('prospector.opportunity_project_link_id_seq'::regclass);


--
-- Name: pia_blockages blockage_id; Type: DEFAULT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.pia_blockages ALTER COLUMN blockage_id SET DEFAULT nextval('prospector.pia_blockages_blockage_id_seq'::regclass);


--
-- Name: file_uploads id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: geolynx_address_staging id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: geolynx_identifiers id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: map_layers layer_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.map_layers ALTER COLUMN layer_id SET DEFAULT nextval('public.map_layers_id_seq'::regclass);


--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: reports report_id; Type: DEFAULT; Schema: reports; Owner: -
--

ALTER TABLE ONLY reports.reports ALTER COLUMN report_id SET DEFAULT nextval('reports.newtable_report_id_seq'::regclass);


--
-- Name: stocklist_access_log id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_access_log ALTER COLUMN id SET DEFAULT nextval('stocklists.stocklist_access_log_id_seq'::regclass);


--
-- Name: stocklist_field_category field_category_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_category ALTER COLUMN field_category_id SET DEFAULT nextval('stocklists.stocklist_field_category_field_category_id_seq'::regclass);


--
-- Name: stocklist_field_dropdown_options dropdown_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_dropdown_options ALTER COLUMN dropdown_id SET DEFAULT nextval('stocklists.stocklist_field_dropdown_options_dropdown_id_seq'::regclass);


--
-- Name: stocklist_field_sections field_section_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_sections ALTER COLUMN field_section_id SET DEFAULT nextval('stocklists.stocklist_field_sections_field_section_id_seq'::regclass);


--
-- Name: stocklist_field_sub_category field_sub_category_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_sub_category ALTER COLUMN field_sub_category_id SET DEFAULT nextval('stocklists.stocklist_field_sub_category_field_sub_category_id_seq'::regclass);


--
-- Name: stocklist_field_values_boolean value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_boolean_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_boolean_history value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean_history ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_boolean_history_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_date value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_date_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_date_history value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date_history ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_date_history_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_int value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_int_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_int_history value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int_history ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_int_history_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_numeric value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_numeric_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_numeric_history value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric_history ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_numeric_history_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_text value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_text_value_id_seq'::regclass);


--
-- Name: stocklist_field_values_text_history value_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text_history ALTER COLUMN value_id SET DEFAULT nextval('stocklists.stocklist_field_values_text_history_value_id_seq'::regclass);


--
-- Name: stocklist_fields field_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_fields ALTER COLUMN field_id SET DEFAULT nextval('stocklists.stocklist_fields_field_id_seq'::regclass);


--
-- Name: stocklist_journal id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_journal ALTER COLUMN id SET DEFAULT nextval('stocklists.stocklist_journal_id_seq'::regclass);


--
-- Name: stocklist_premises id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_premises ALTER COLUMN id SET DEFAULT nextval('stocklists.stocklist_premises_id_seq'::regclass);


--
-- Name: stocklists stocklist_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists ALTER COLUMN stocklist_id SET DEFAULT nextval('stocklists.stocklists_stocklist_id_seq'::regclass);


--
-- Name: stocklists_history stocklist_id; Type: DEFAULT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists_history ALTER COLUMN stocklist_id SET DEFAULT nextval('stocklists.stocklists_history_stocklist_id_seq'::regclass);


--
-- Name: distance_analysis_tables id; Type: DEFAULT; Schema: strategy; Owner: -
--

ALTER TABLE ONLY strategy.distance_analysis_tables ALTER COLUMN id SET DEFAULT nextval('strategy.distance_analysis_tables_id_seq'::regclass);


--
-- Name: Misc id; Type: DEFAULT; Schema: temp; Owner: -
--

ALTER TABLE ONLY temp."Misc" ALTER COLUMN id SET DEFAULT nextval('temp."Misc_id_seq"'::regclass);


--
-- Name: Points id; Type: DEFAULT; Schema: temp; Owner: -
--

ALTER TABLE ONLY temp."Points" ALTER COLUMN id SET DEFAULT nextval('temp."Points_id_seq"'::regclass);


--
-- Name: Stages id; Type: DEFAULT; Schema: temp; Owner: -
--

ALTER TABLE ONLY temp."Stages" ALTER COLUMN id SET DEFAULT nextval('temp."Stages_id_seq"'::regclass);


--
-- Name: active_sessions session_record_id; Type: DEFAULT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.active_sessions ALTER COLUMN session_record_id SET DEFAULT nextval('users.active_sessions_session_record_id_seq'::regclass);


--
-- Name: companies company_id; Type: DEFAULT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.companies ALTER COLUMN company_id SET DEFAULT nextval('users.companies_company_id_seq'::regclass);


--
-- Name: role_permissions permission_id; Type: DEFAULT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.role_permissions ALTER COLUMN permission_id SET DEFAULT nextval('users.role_permissions_permission_id_seq'::regclass);


--
-- Name: roles role_id; Type: DEFAULT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.roles ALTER COLUMN role_id SET DEFAULT nextval('users.roles_role_id_seq'::regclass);


--
-- Name: user_item_permissions permission_id; Type: DEFAULT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_item_permissions ALTER COLUMN permission_id SET DEFAULT nextval('users.user_item_permissions_permission_id_seq'::regclass);


--
-- Name: users id; Type: DEFAULT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.users ALTER COLUMN id SET DEFAULT nextval('users.users_id_seq'::regclass);


--
-- Name: users_login_log id; Type: DEFAULT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.users_login_log ALTER COLUMN id SET DEFAULT nextval('users.users_login_log_id_seq'::regclass);


--
-- Name: agreement_access_log id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_access_log ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_access_log_id_seq'::regclass);


--
-- Name: agreement_field_category id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_category ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_field_category_id_seq'::regclass);


--
-- Name: agreement_field_dropdown_options id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_dropdown_options ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_field_dropdown_options_id_seq'::regclass);


--
-- Name: agreement_field_sections id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_sections ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_field_sections_id_seq'::regclass);


--
-- Name: agreement_field_sub_category id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_sub_category ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_field_sub_category_id_seq'::regclass);


--
-- Name: agreement_field_values_boolean_history history_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_boolean_history ALTER COLUMN history_id SET DEFAULT nextval('wayleave.agreement_field_values_boolean_history_history_id_seq'::regclass);


--
-- Name: agreement_field_values_date_history history_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_date_history ALTER COLUMN history_id SET DEFAULT nextval('wayleave.agreement_field_values_date_history_history_id_seq'::regclass);


--
-- Name: agreement_field_values_int_history history_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_int_history ALTER COLUMN history_id SET DEFAULT nextval('wayleave.agreement_field_values_int_history_history_id_seq'::regclass);


--
-- Name: agreement_field_values_numeric_history history_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_numeric_history ALTER COLUMN history_id SET DEFAULT nextval('wayleave.agreement_field_values_numeric_history_history_id_seq'::regclass);


--
-- Name: agreement_field_values_text_history history_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_text_history ALTER COLUMN history_id SET DEFAULT nextval('wayleave.agreement_field_values_text_history_history_id_seq'::regclass);


--
-- Name: agreement_fields field_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_fields ALTER COLUMN field_id SET DEFAULT nextval('wayleave.agreement_fields_field_id_seq'::regclass);


--
-- Name: agreement_journal id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_journal ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_journal_id_seq'::regclass);


--
-- Name: agreement_landregistry id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_landregistry ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_landregistry_id_seq'::regclass);


--
-- Name: agreement_polygon_uprns id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_polygon_uprns ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_polygon_uprns_id_seq'::regclass);


--
-- Name: agreement_polygons id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_polygons ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_polygons_id_seq'::regclass);


--
-- Name: agreement_releases id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_releases ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_releases_id_seq'::regclass);


--
-- Name: agreement_status id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_status ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_status_id_seq'::regclass);


--
-- Name: agreement_stocklists id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_stocklists ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_stocklists_id_seq'::regclass);


--
-- Name: agreement_uprns id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_uprns ALTER COLUMN id SET DEFAULT nextval('wayleave.agreement_uprns_id_seq'::regclass);


--
-- Name: agreements agreement_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreements ALTER COLUMN agreement_id SET DEFAULT nextval('wayleave.agreements_agreement_id_seq'::regclass);


--
-- Name: agreements_history history_id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreements_history ALTER COLUMN history_id SET DEFAULT nextval('wayleave.agreements_history_history_id_seq'::regclass);


--
-- Name: teams id; Type: DEFAULT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.teams ALTER COLUMN id SET DEFAULT nextval('wayleave.teams_id_seq'::regclass);


--
-- Name: account_access_log account_access_log_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_access_log
    ADD CONSTRAINT account_access_log_pk PRIMARY KEY (id);


--
-- Name: account_field_category account_field_category_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_category
    ADD CONSTRAINT account_field_category_pk PRIMARY KEY (field_category_id);


--
-- Name: account_field_dropdown_options account_field_dropdown_options_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_dropdown_options
    ADD CONSTRAINT account_field_dropdown_options_pk PRIMARY KEY (dropdown_id);


--
-- Name: account_field_sections account_field_sections_unique; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_sections
    ADD CONSTRAINT account_field_sections_unique UNIQUE (field_section_id);


--
-- Name: account_field_sub_category account_field_sub_category_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_sub_category
    ADD CONSTRAINT account_field_sub_category_pk PRIMARY KEY (field_sub_category_id);


--
-- Name: account_field_values_boolean account_field_values_boolean_field_id_account_id_key; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean
    ADD CONSTRAINT account_field_values_boolean_field_id_account_id_key UNIQUE (field_id, account_id);


--
-- Name: account_field_values_boolean_history account_field_values_boolean_history_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean_history
    ADD CONSTRAINT account_field_values_boolean_history_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_boolean account_field_values_boolean_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean
    ADD CONSTRAINT account_field_values_boolean_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_date account_field_values_date_field_id_account_id_key; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date
    ADD CONSTRAINT account_field_values_date_field_id_account_id_key UNIQUE (field_id, account_id);


--
-- Name: account_field_values_date_history account_field_values_date_history_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date_history
    ADD CONSTRAINT account_field_values_date_history_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_date account_field_values_date_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date
    ADD CONSTRAINT account_field_values_date_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_int account_field_values_int_field_id_account_id_key; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int
    ADD CONSTRAINT account_field_values_int_field_id_account_id_key UNIQUE (field_id, account_id);


--
-- Name: account_field_values_int_history account_field_values_int_history_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int_history
    ADD CONSTRAINT account_field_values_int_history_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_int account_field_values_int_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int
    ADD CONSTRAINT account_field_values_int_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_numeric account_field_values_numeric_field_id_account_id_key; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric
    ADD CONSTRAINT account_field_values_numeric_field_id_account_id_key UNIQUE (field_id, account_id);


--
-- Name: account_field_values_numeric_history account_field_values_numeric_history_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric_history
    ADD CONSTRAINT account_field_values_numeric_history_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_numeric account_field_values_numeric_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric
    ADD CONSTRAINT account_field_values_numeric_pk PRIMARY KEY (value_id);


--
-- Name: account_field_values_text account_field_values_text_field_id_account_id_key; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text
    ADD CONSTRAINT account_field_values_text_field_id_account_id_key UNIQUE (field_id, account_id);


--
-- Name: account_field_values_text_history account_field_values_text_history_unique; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text_history
    ADD CONSTRAINT account_field_values_text_history_unique PRIMARY KEY (value_id);


--
-- Name: account_field_values_text account_field_values_text_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text
    ADD CONSTRAINT account_field_values_text_pk PRIMARY KEY (value_id);


--
-- Name: account_fields account_fields_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_fields
    ADD CONSTRAINT account_fields_pk PRIMARY KEY (field_id);


--
-- Name: account_status account_status_un; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_status
    ADD CONSTRAINT account_status_un UNIQUE (account_status_id);


--
-- Name: accounts accounts_pk; Type: CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts
    ADD CONSTRAINT accounts_pk PRIMARY KEY (account_id);


--
-- Name: bduk_fmp_work_may_2026_20260601_geom bduk_fmp_work_may_2026_20260601_geom_pk; Type: CONSTRAINT; Schema: adhoc; Owner: -
--

ALTER TABLE ONLY adhoc.bduk_fmp_work_may_2026_20260601_geom
    ADD CONSTRAINT bduk_fmp_work_may_2026_20260601_geom_pk PRIMARY KEY (uprn);


--
-- Name: bduk_go_list_fmp_work_20251003_address_geom bduk_go_list_fmp_work_20251003_address_geom_unique; Type: CONSTRAINT; Schema: adhoc; Owner: -
--

ALTER TABLE ONLY adhoc.bduk_go_list_fmp_work_20251003_address_geom
    ADD CONSTRAINT bduk_go_list_fmp_work_20251003_address_geom_unique UNIQUE (uprn);


--
-- Name: bduk_import bduk_import_pk; Type: CONSTRAINT; Schema: adhoc; Owner: -
--

ALTER TABLE ONLY adhoc.bduk_import
    ADD CONSTRAINT bduk_import_pk PRIMARY KEY (uprn);


--
-- Name: bsr_high_rise_register_final_20251003_geom bsr_high_rise_register_final_20251003_geom_pk; Type: CONSTRAINT; Schema: adhoc; Owner: -
--

ALTER TABLE ONLY adhoc.bsr_high_rise_register_final_20251003_geom
    ADD CONSTRAINT bsr_high_rise_register_final_20251003_geom_pk PRIMARY KEY (id);


--
-- Name: tbl_abp_import tbl_abp_import_pk; Type: CONSTRAINT; Schema: adhoc; Owner: -
--

ALTER TABLE ONLY adhoc.tbl_abp_import
    ADD CONSTRAINT tbl_abp_import_pk PRIMARY KEY (uprn);


--
-- Name: abp_import abp_import_pkey; Type: CONSTRAINT; Schema: basedata; Owner: -
--

ALTER TABLE ONLY basedata.abp_import
    ADD CONSTRAINT abp_import_pkey PRIMARY KEY (uprn);


--
-- Name: bduk_uk_geom bduk_uk_geom_unique; Type: CONSTRAINT; Schema: basedata; Owner: -
--

ALTER TABLE ONLY basedata.bduk_uk_geom
    ADD CONSTRAINT bduk_uk_geom_unique UNIQUE (uprn);


--
-- Name: tbl_uk_postcode_unit tbl_uk_postcode_unit_pk; Type: CONSTRAINT; Schema: basedata; Owner: -
--

ALTER TABLE ONLY basedata.tbl_uk_postcode_unit
    ADD CONSTRAINT tbl_uk_postcode_unit_pk PRIMARY KEY (postcode);


--
-- Name: uprn_address uprn_address_pkey; Type: CONSTRAINT; Schema: basedata; Owner: -
--

ALTER TABLE ONLY basedata.uprn_address
    ADD CONSTRAINT uprn_address_pkey PRIMARY KEY (uprn);


--
-- Name: openreach openreach_pkey; Type: CONSTRAINT; Schema: competitor_data; Owner: -
--

ALTER TABLE ONLY competitor_data.openreach
    ADD CONSTRAINT openreach_pkey PRIMARY KEY (id);


--
-- Name: openreach openreach_uprn_key; Type: CONSTRAINT; Schema: competitor_data; Owner: -
--

ALTER TABLE ONLY competitor_data.openreach
    ADD CONSTRAINT openreach_uprn_key UNIQUE (uprn);


--
-- Name: ccod_company_summary ccod_company_summary_pk; Type: CONSTRAINT; Schema: landregistry; Owner: -
--

ALTER TABLE ONLY landregistry.ccod_company_summary
    ADD CONSTRAINT ccod_company_summary_pk PRIMARY KEY (company_id);


--
-- Name: ccod_address_matches match_id_pk; Type: CONSTRAINT; Schema: landregistry; Owner: -
--

ALTER TABLE ONLY landregistry.ccod_address_matches
    ADD CONSTRAINT match_id_pk PRIMARY KEY (match_id);


--
-- Name: chamber chamber_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.chamber
    ADD CONSTRAINT chamber_pkey PRIMARY KEY (objectid);


--
-- Name: duct duct_pk; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct
    ADD CONSTRAINT duct_pk PRIMARY KEY (objectid);


--
-- Name: duct_segment_test duct_segment_test_pk; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_segment_test
    ADD CONSTRAINT duct_segment_test_pk PRIMARY KEY (id);


--
-- Name: duct_segment_test_vertices_pgr duct_segment_test_vertices_pgr_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_segment_test_vertices_pgr
    ADD CONSTRAINT duct_segment_test_vertices_pgr_pkey PRIMARY KEY (id);


--
-- Name: duct_test duct_test_pk; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_test
    ADD CONSTRAINT duct_test_pk PRIMARY KEY (objectid);


--
-- Name: duct_test_vertices_pgr duct_test_vertices_pgr_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_test_vertices_pgr
    ADD CONSTRAINT duct_test_vertices_pgr_pkey PRIMARY KEY (id);


--
-- Name: duct_vertices_pgr duct_vertices_pgr_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.duct_vertices_pgr
    ADD CONSTRAINT duct_vertices_pgr_pkey PRIMARY KEY (id);


--
-- Name: openreach_exchange_polygons openreach_exchange_polygons_pk; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.openreach_exchange_polygons
    ADD CONSTRAINT openreach_exchange_polygons_pk PRIMARY KEY (exchange_1141_code);


--
-- Name: pole pole_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.pole
    ADD CONSTRAINT pole_pkey PRIMARY KEY (objectid);


--
-- Name: span_coupler span_coupler_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.span_coupler
    ADD CONSTRAINT span_coupler_pkey PRIMARY KEY (fid);


--
-- Name: spans spans_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.spans
    ADD CONSTRAINT spans_pkey PRIMARY KEY (id);


--
-- Name: spans_vertices_pgr spans_vertices_pgr_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.spans_vertices_pgr
    ADD CONSTRAINT spans_vertices_pgr_pkey PRIMARY KEY (id);


--
-- Name: subset_vertices_pgr subset_vertices_pgr_pkey; Type: CONSTRAINT; Schema: openreach; Owner: -
--

ALTER TABLE ONLY openreach.subset_vertices_pgr
    ADD CONSTRAINT subset_vertices_pgr_pkey PRIMARY KEY (id);


--
-- Name: osmm_highways_street osmm_highways_street_pk; Type: CONSTRAINT; Schema: ordnancesurvey; Owner: -
--

ALTER TABLE ONLY ordnancesurvey.osmm_highways_street
    ADD CONSTRAINT osmm_highways_street_pk PRIMARY KEY (usrn);


--
-- Name: project_access_log project_access_log_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_access_log
    ADD CONSTRAINT project_access_log_pk PRIMARY KEY (id);


--
-- Name: project_field_category project_field_category_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_category
    ADD CONSTRAINT project_field_category_pk PRIMARY KEY (field_category_id);


--
-- Name: project_field_dropdown_options project_field_dropdown_options_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_dropdown_options
    ADD CONSTRAINT project_field_dropdown_options_pk PRIMARY KEY (dropdown_id);


--
-- Name: project_field_sections project_field_sections_unique; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_sections
    ADD CONSTRAINT project_field_sections_unique UNIQUE (field_section_id);


--
-- Name: project_field_sub_category project_field_sub_category_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_sub_category
    ADD CONSTRAINT project_field_sub_category_pk PRIMARY KEY (field_sub_category_id);


--
-- Name: project_field_values_boolean project_field_values_boolean_field_id_project_id_key; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean
    ADD CONSTRAINT project_field_values_boolean_field_id_project_id_key UNIQUE (field_id, project_id);


--
-- Name: project_field_values_boolean_history project_field_values_boolean_history_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean_history
    ADD CONSTRAINT project_field_values_boolean_history_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_boolean project_field_values_boolean_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean
    ADD CONSTRAINT project_field_values_boolean_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_date project_field_values_date_field_id_project_id_key; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date
    ADD CONSTRAINT project_field_values_date_field_id_project_id_key UNIQUE (field_id, project_id);


--
-- Name: project_field_values_date_history project_field_values_date_history_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date_history
    ADD CONSTRAINT project_field_values_date_history_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_date project_field_values_date_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date
    ADD CONSTRAINT project_field_values_date_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_int project_field_values_int_field_id_project_id_key; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int
    ADD CONSTRAINT project_field_values_int_field_id_project_id_key UNIQUE (field_id, project_id);


--
-- Name: project_field_values_int_history project_field_values_int_history_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int_history
    ADD CONSTRAINT project_field_values_int_history_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_int project_field_values_int_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int
    ADD CONSTRAINT project_field_values_int_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_numeric project_field_values_numeric_field_id_project_id_key; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric
    ADD CONSTRAINT project_field_values_numeric_field_id_project_id_key UNIQUE (field_id, project_id);


--
-- Name: project_field_values_numeric_history project_field_values_numeric_history_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric_history
    ADD CONSTRAINT project_field_values_numeric_history_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_numeric project_field_values_numeric_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric
    ADD CONSTRAINT project_field_values_numeric_pk PRIMARY KEY (value_id);


--
-- Name: project_field_values_text project_field_values_text_field_id_project_id_key; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text
    ADD CONSTRAINT project_field_values_text_field_id_project_id_key UNIQUE (field_id, project_id);


--
-- Name: project_field_values_text_history project_field_values_text_history_unique; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text_history
    ADD CONSTRAINT project_field_values_text_history_unique PRIMARY KEY (value_id);


--
-- Name: project_field_values_text project_field_values_text_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text
    ADD CONSTRAINT project_field_values_text_pk PRIMARY KEY (value_id);


--
-- Name: project_fields project_fields_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_fields
    ADD CONSTRAINT project_fields_pk PRIMARY KEY (field_id);


--
-- Name: project_file_uploads project_file_uploads_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_file_uploads
    ADD CONSTRAINT project_file_uploads_pk PRIMARY KEY (id);


--
-- Name: project_journal project_journal_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_journal
    ADD CONSTRAINT project_journal_pk PRIMARY KEY (id);


--
-- Name: project_status project_status_un; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_status
    ADD CONSTRAINT project_status_un UNIQUE (project_status_id);


--
-- Name: projects_history projects_history_pkey; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects_history
    ADD CONSTRAINT projects_history_pkey PRIMARY KEY (history_id);


--
-- Name: projects projects_pk; Type: CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects
    ADD CONSTRAINT projects_pk PRIMARY KEY (project_id);


--
-- Name: pia_blockages network_blockages_blockage_id_unique; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.pia_blockages
    ADD CONSTRAINT network_blockages_blockage_id_unique UNIQUE (blockage_id);


--
-- Name: network_cables_history network_cables_history_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_cables_history
    ADD CONSTRAINT network_cables_history_pk PRIMARY KEY (history_id);


--
-- Name: network_cables network_cables_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_cables
    ADD CONSTRAINT network_cables_pk PRIMARY KEY (cable_id);


--
-- Name: network_duct network_ducts_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_duct
    ADD CONSTRAINT network_ducts_pk PRIMARY KEY (duct_id);


--
-- Name: network_points network_points_point_id_unique; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_points
    ADD CONSTRAINT network_points_point_id_unique UNIQUE (point_id);


--
-- Name: network_structures network_structures_point_id_unique; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_structures
    ADD CONSTRAINT network_structures_point_id_unique UNIQUE (structure_id);


--
-- Name: network_subduct network_subducts_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.network_subduct
    ADD CONSTRAINT network_subducts_pk PRIMARY KEY (subduct_id);


--
-- Name: opportunity_access_log opportunit_access_log_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.opportunity_access_log
    ADD CONSTRAINT opportunit_access_log_pk PRIMARY KEY (id);


--
-- Name: opportunity opportunity_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.opportunity
    ADD CONSTRAINT opportunity_pk PRIMARY KEY (opportunity_id);


--
-- Name: opportunity_project_link opportunity_project_link_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.opportunity_project_link
    ADD CONSTRAINT opportunity_project_link_pk PRIMARY KEY (id);


--
-- Name: opportunity_project_link opportunity_project_link_unique_1; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.opportunity_project_link
    ADD CONSTRAINT opportunity_project_link_unique_1 UNIQUE (opportunity_id, project_id);


--
-- Name: pia_blockages pia_blockages_pk; Type: CONSTRAINT; Schema: prospector; Owner: -
--

ALTER TABLE ONLY prospector.pia_blockages
    ADD CONSTRAINT pia_blockages_pk PRIMARY KEY (blockage_id);


--
-- Name: file_uploads file_uploads_pk; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.file_uploads
    ADD CONSTRAINT file_uploads_pk PRIMARY KEY (id);


--
-- Name: full_ultimate full_ultimate_pk; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.full_ultimate
    ADD CONSTRAINT full_ultimate_pk PRIMARY KEY (sprn);


--
-- Name: geolynx_address_staging geolynx_address_staging_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.geolynx_address_staging
    ADD CONSTRAINT geolynx_address_staging_pkey PRIMARY KEY (id);


--
-- Name: geolynx_identifiers geolynx_identifiers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.geolynx_identifiers
    ADD CONSTRAINT geolynx_identifiers_pkey PRIMARY KEY (id);


--
-- Name: map_layer_page_config map_layer_page_config_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.map_layer_page_config
    ADD CONSTRAINT map_layer_page_config_pkey PRIMARY KEY (layer_id, page_context);


--
-- Name: map_layers map_layers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.map_layers
    ADD CONSTRAINT map_layers_pkey PRIMARY KEY (layer_id);


--
-- Name: users users_pk; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pk PRIMARY KEY (id);


--
-- Name: reports reports_pk; Type: CONSTRAINT; Schema: reports; Owner: -
--

ALTER TABLE ONLY reports.reports
    ADD CONSTRAINT reports_pk PRIMARY KEY (report_id);


--
-- Name: stocklist_access_log stocklist_access_log_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_access_log
    ADD CONSTRAINT stocklist_access_log_pk PRIMARY KEY (id);


--
-- Name: stocklist_field_category stocklist_field_category_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_category
    ADD CONSTRAINT stocklist_field_category_pk PRIMARY KEY (field_category_id);


--
-- Name: stocklist_field_dropdown_options stocklist_field_dropdown_options_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_dropdown_options
    ADD CONSTRAINT stocklist_field_dropdown_options_pk PRIMARY KEY (dropdown_id);


--
-- Name: stocklist_field_sections stocklist_field_sections_unique; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_sections
    ADD CONSTRAINT stocklist_field_sections_unique UNIQUE (field_section_id);


--
-- Name: stocklist_field_sub_category stocklist_field_sub_category_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_sub_category
    ADD CONSTRAINT stocklist_field_sub_category_pk PRIMARY KEY (field_sub_category_id);


--
-- Name: stocklist_field_values_boolean stocklist_field_values_boolean_field_id_stocklist_id_key; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean
    ADD CONSTRAINT stocklist_field_values_boolean_field_id_stocklist_id_key UNIQUE (field_id, stocklist_id);


--
-- Name: stocklist_field_values_boolean_history stocklist_field_values_boolean_history_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean_history
    ADD CONSTRAINT stocklist_field_values_boolean_history_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_boolean stocklist_field_values_boolean_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean
    ADD CONSTRAINT stocklist_field_values_boolean_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_date stocklist_field_values_date_field_id_stocklist_id_key; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date
    ADD CONSTRAINT stocklist_field_values_date_field_id_stocklist_id_key UNIQUE (field_id, stocklist_id);


--
-- Name: stocklist_field_values_date_history stocklist_field_values_date_history_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date_history
    ADD CONSTRAINT stocklist_field_values_date_history_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_date stocklist_field_values_date_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date
    ADD CONSTRAINT stocklist_field_values_date_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_int stocklist_field_values_int_field_id_stocklist_id_key; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int
    ADD CONSTRAINT stocklist_field_values_int_field_id_stocklist_id_key UNIQUE (field_id, stocklist_id);


--
-- Name: stocklist_field_values_int_history stocklist_field_values_int_history_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int_history
    ADD CONSTRAINT stocklist_field_values_int_history_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_int stocklist_field_values_int_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int
    ADD CONSTRAINT stocklist_field_values_int_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_numeric stocklist_field_values_numeric_field_id_stocklist_id_key; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric
    ADD CONSTRAINT stocklist_field_values_numeric_field_id_stocklist_id_key UNIQUE (field_id, stocklist_id);


--
-- Name: stocklist_field_values_numeric_history stocklist_field_values_numeric_history_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric_history
    ADD CONSTRAINT stocklist_field_values_numeric_history_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_numeric stocklist_field_values_numeric_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric
    ADD CONSTRAINT stocklist_field_values_numeric_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_text stocklist_field_values_text_field_id_stocklist_id_key; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text
    ADD CONSTRAINT stocklist_field_values_text_field_id_stocklist_id_key UNIQUE (field_id, stocklist_id);


--
-- Name: stocklist_field_values_text_history stocklist_field_values_text_history_unique; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text_history
    ADD CONSTRAINT stocklist_field_values_text_history_unique PRIMARY KEY (value_id);


--
-- Name: stocklist_field_values_text stocklist_field_values_text_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text
    ADD CONSTRAINT stocklist_field_values_text_pk PRIMARY KEY (value_id);


--
-- Name: stocklist_fields stocklist_fields_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_fields
    ADD CONSTRAINT stocklist_fields_pk PRIMARY KEY (field_id);


--
-- Name: stocklist_import_jobs stocklist_import_jobs_pkey; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_import_jobs
    ADD CONSTRAINT stocklist_import_jobs_pkey PRIMARY KEY (job_id);


--
-- Name: stocklist_journal stocklist_journal_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_journal
    ADD CONSTRAINT stocklist_journal_pk PRIMARY KEY (id);


--
-- Name: stocklist_status stocklist_status_un; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_status
    ADD CONSTRAINT stocklist_status_un UNIQUE (stocklist_status_id);


--
-- Name: stocklists stocklists_pk; Type: CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists
    ADD CONSTRAINT stocklists_pk PRIMARY KEY (stocklist_id);


--
-- Name: distance_analysis_jobs distance_analysis_jobs_pkey; Type: CONSTRAINT; Schema: strategy; Owner: -
--

ALTER TABLE ONLY strategy.distance_analysis_jobs
    ADD CONSTRAINT distance_analysis_jobs_pkey PRIMARY KEY (job_id);


--
-- Name: distance_analysis_tables distance_analysis_tables_pk; Type: CONSTRAINT; Schema: strategy; Owner: -
--

ALTER TABLE ONLY strategy.distance_analysis_tables
    ADD CONSTRAINT distance_analysis_tables_pk PRIMARY KEY (id);


--
-- Name: Misc Misc_pkey; Type: CONSTRAINT; Schema: temp; Owner: -
--

ALTER TABLE ONLY temp."Misc"
    ADD CONSTRAINT "Misc_pkey" PRIMARY KEY (id);


--
-- Name: Points Points_pkey; Type: CONSTRAINT; Schema: temp; Owner: -
--

ALTER TABLE ONLY temp."Points"
    ADD CONSTRAINT "Points_pkey" PRIMARY KEY (id);


--
-- Name: Stages Stages_pkey; Type: CONSTRAINT; Schema: temp; Owner: -
--

ALTER TABLE ONLY temp."Stages"
    ADD CONSTRAINT "Stages_pkey" PRIMARY KEY (id);


--
-- Name: active_sessions active_sessions_pkey; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.active_sessions
    ADD CONSTRAINT active_sessions_pkey PRIMARY KEY (session_record_id);


--
-- Name: active_sessions active_sessions_user_id_key; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.active_sessions
    ADD CONSTRAINT active_sessions_user_id_key UNIQUE (user_id);


--
-- Name: role_permissions role_permissions_pkey; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.role_permissions
    ADD CONSTRAINT role_permissions_pkey PRIMARY KEY (permission_id);


--
-- Name: role_permissions role_permissions_role_id_module_key; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.role_permissions
    ADD CONSTRAINT role_permissions_role_id_module_key UNIQUE (role_id, module);


--
-- Name: roles roles_pk; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.roles
    ADD CONSTRAINT roles_pk PRIMARY KEY (role_id);


--
-- Name: user_item_permissions user_item_permissions_pkey; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_item_permissions
    ADD CONSTRAINT user_item_permissions_pkey PRIMARY KEY (permission_id);


--
-- Name: user_item_permissions user_item_permissions_user_id_item_type_item_id_key; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_item_permissions
    ADD CONSTRAINT user_item_permissions_user_id_item_type_item_id_key UNIQUE (user_id, item_type, item_id);


--
-- Name: user_roles user_roles_pkey; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_roles
    ADD CONSTRAINT user_roles_pkey PRIMARY KEY (user_id, role_id);


--
-- Name: users_login_log users_login_log_pk; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.users_login_log
    ADD CONSTRAINT users_login_log_pk PRIMARY KEY (id);


--
-- Name: users users_pk; Type: CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.users
    ADD CONSTRAINT users_pk PRIMARY KEY (id);


--
-- Name: agreement_access_log agreement_access_log_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_access_log
    ADD CONSTRAINT agreement_access_log_pkey PRIMARY KEY (id);


--
-- Name: agreement_field_category agreement_field_category_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_category
    ADD CONSTRAINT agreement_field_category_pkey PRIMARY KEY (id);


--
-- Name: agreement_field_category agreement_field_category_section_id_category_name_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_category
    ADD CONSTRAINT agreement_field_category_section_id_category_name_key UNIQUE (section_id, category_name);


--
-- Name: agreement_field_dropdown_options agreement_field_dropdown_options_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_dropdown_options
    ADD CONSTRAINT agreement_field_dropdown_options_pkey PRIMARY KEY (id);


--
-- Name: agreement_field_sections agreement_field_sections_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_sections
    ADD CONSTRAINT agreement_field_sections_pkey PRIMARY KEY (id);


--
-- Name: agreement_field_sections agreement_field_sections_section_name_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_sections
    ADD CONSTRAINT agreement_field_sections_section_name_key UNIQUE (section_name);


--
-- Name: agreement_field_sub_category agreement_field_sub_category_category_id_sub_category_name_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_sub_category
    ADD CONSTRAINT agreement_field_sub_category_category_id_sub_category_name_key UNIQUE (category_id, sub_category_name);


--
-- Name: agreement_field_sub_category agreement_field_sub_category_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_sub_category
    ADD CONSTRAINT agreement_field_sub_category_pkey PRIMARY KEY (id);


--
-- Name: agreement_field_values_boolean_history agreement_field_values_boolean_history_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_boolean_history
    ADD CONSTRAINT agreement_field_values_boolean_history_pkey PRIMARY KEY (history_id);


--
-- Name: agreement_field_values_boolean agreement_field_values_boolean_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_boolean
    ADD CONSTRAINT agreement_field_values_boolean_pkey PRIMARY KEY (agreement_id, field_id);


--
-- Name: agreement_field_values_date_history agreement_field_values_date_history_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_date_history
    ADD CONSTRAINT agreement_field_values_date_history_pkey PRIMARY KEY (history_id);


--
-- Name: agreement_field_values_date agreement_field_values_date_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_date
    ADD CONSTRAINT agreement_field_values_date_pkey PRIMARY KEY (agreement_id, field_id);


--
-- Name: agreement_field_values_int_history agreement_field_values_int_history_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_int_history
    ADD CONSTRAINT agreement_field_values_int_history_pkey PRIMARY KEY (history_id);


--
-- Name: agreement_field_values_int agreement_field_values_int_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_int
    ADD CONSTRAINT agreement_field_values_int_pkey PRIMARY KEY (agreement_id, field_id);


--
-- Name: agreement_field_values_numeric_history agreement_field_values_numeric_history_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_numeric_history
    ADD CONSTRAINT agreement_field_values_numeric_history_pkey PRIMARY KEY (history_id);


--
-- Name: agreement_field_values_numeric agreement_field_values_numeric_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_numeric
    ADD CONSTRAINT agreement_field_values_numeric_pkey PRIMARY KEY (agreement_id, field_id);


--
-- Name: agreement_field_values_text_history agreement_field_values_text_history_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_text_history
    ADD CONSTRAINT agreement_field_values_text_history_pkey PRIMARY KEY (history_id);


--
-- Name: agreement_field_values_text agreement_field_values_text_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_text
    ADD CONSTRAINT agreement_field_values_text_pkey PRIMARY KEY (agreement_id, field_id);


--
-- Name: agreement_fields agreement_fields_field_form_id_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_fields
    ADD CONSTRAINT agreement_fields_field_form_id_key UNIQUE (field_form_id);


--
-- Name: agreement_fields agreement_fields_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_fields
    ADD CONSTRAINT agreement_fields_pkey PRIMARY KEY (field_id);


--
-- Name: agreement_journal agreement_journal_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_journal
    ADD CONSTRAINT agreement_journal_pkey PRIMARY KEY (id);


--
-- Name: agreement_landregistry agreement_landregistry_agreement_id_title_number_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_landregistry
    ADD CONSTRAINT agreement_landregistry_agreement_id_title_number_key UNIQUE (agreement_id, title_number);


--
-- Name: agreement_landregistry agreement_landregistry_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_landregistry
    ADD CONSTRAINT agreement_landregistry_pkey PRIMARY KEY (id);


--
-- Name: agreement_polygon_uprns agreement_polygon_uprns_agreement_id_uprn_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_polygon_uprns
    ADD CONSTRAINT agreement_polygon_uprns_agreement_id_uprn_key UNIQUE (agreement_id, uprn);


--
-- Name: agreement_polygon_uprns agreement_polygon_uprns_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_polygon_uprns
    ADD CONSTRAINT agreement_polygon_uprns_pkey PRIMARY KEY (id);


--
-- Name: agreement_polygons agreement_polygons_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_polygons
    ADD CONSTRAINT agreement_polygons_pkey PRIMARY KEY (id);


--
-- Name: agreement_releases agreement_releases_agreement_id_uprn_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_releases
    ADD CONSTRAINT agreement_releases_agreement_id_uprn_key UNIQUE (agreement_id, uprn);


--
-- Name: agreement_releases agreement_releases_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_releases
    ADD CONSTRAINT agreement_releases_pkey PRIMARY KEY (id);


--
-- Name: agreement_status agreement_status_description_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_status
    ADD CONSTRAINT agreement_status_description_key UNIQUE (description);


--
-- Name: agreement_status agreement_status_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_status
    ADD CONSTRAINT agreement_status_pkey PRIMARY KEY (id);


--
-- Name: agreement_stocklists agreement_stocklists_agreement_id_stocklist_id_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_stocklists
    ADD CONSTRAINT agreement_stocklists_agreement_id_stocklist_id_key UNIQUE (agreement_id, stocklist_id);


--
-- Name: agreement_stocklists agreement_stocklists_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_stocklists
    ADD CONSTRAINT agreement_stocklists_pkey PRIMARY KEY (id);


--
-- Name: agreement_uprns agreement_uprns_agreement_id_uprn_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_uprns
    ADD CONSTRAINT agreement_uprns_agreement_id_uprn_key UNIQUE (agreement_id, uprn);


--
-- Name: agreement_uprns agreement_uprns_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_uprns
    ADD CONSTRAINT agreement_uprns_pkey PRIMARY KEY (id);


--
-- Name: agreements_history agreements_history_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreements_history
    ADD CONSTRAINT agreements_history_pkey PRIMARY KEY (history_id);


--
-- Name: agreements agreements_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreements
    ADD CONSTRAINT agreements_pkey PRIMARY KEY (agreement_id);


--
-- Name: teams teams_pkey; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.teams
    ADD CONSTRAINT teams_pkey PRIMARY KEY (id);


--
-- Name: teams teams_team_name_key; Type: CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.teams
    ADD CONSTRAINT teams_team_name_key UNIQUE (team_name);


--
-- Name: accounts_geom_idx; Type: INDEX; Schema: accounts; Owner: -
--

CREATE INDEX accounts_geom_idx ON accounts.accounts USING gist (geom);


--
-- Name: accounts_history_geom_idx; Type: INDEX; Schema: accounts; Owner: -
--

CREATE INDEX accounts_history_geom_idx ON accounts.accounts_history USING gist (geom);


--
-- Name: bduk_fmp_work_may_2026_20260601_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_fmp_work_may_2026_20260601_geom_idx ON adhoc.bduk_fmp_work_may_2026_20260601_geom USING gist (geom);


--
-- Name: bduk_go_list_address_view_geom_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_go_list_address_view_geom_geom_idx ON adhoc.bduk_go_list_address_view_geom USING gist (geom);


--
-- Name: bduk_go_list_fmp_work_20251003_address_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_go_list_fmp_work_20251003_address_geom_idx ON adhoc.bduk_go_list_fmp_work_20251003_address_geom USING gist (geom);


--
-- Name: bduk_go_list_fmp_work_20260217_geom_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_go_list_fmp_work_20260217_geom_geom_idx ON adhoc.bduk_go_list_fmp_work_20260217_geom USING gist (geom);


--
-- Name: bduk_go_list_fmp_work_20260217_geom_uprn_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_go_list_fmp_work_20260217_geom_uprn_idx ON adhoc.bduk_go_list_fmp_work_20260217_geom USING btree (uprn);


--
-- Name: bduk_project_checks_20260527_stg1_uprn_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_project_checks_20260527_stg1_uprn_idx ON adhoc.bduk_project_checks_20260527_stg1 USING btree (uprn);


--
-- Name: bduk_uprn_tracking_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_geom_idx ON adhoc.bduk_uprn_tracking USING gist (geom);


--
-- Name: bduk_uprn_tracking_stg1_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_stg1_idx ON adhoc.bduk_uprn_tracking_stg1 USING btree (uprn);


--
-- Name: bduk_uprn_tracking_stg2_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_stg2_idx ON adhoc.bduk_uprn_tracking_stg2 USING btree (uprn);


--
-- Name: bduk_uprn_tracking_stg3_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_stg3_idx ON adhoc.bduk_uprn_tracking_stg3 USING btree (uprn);


--
-- Name: bduk_uprn_tracking_stg4_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_stg4_idx ON adhoc.bduk_uprn_tracking_stg4 USING btree (uprn);


--
-- Name: bduk_uprn_tracking_stg5_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_stg5_idx ON adhoc.bduk_uprn_tracking_stg5 USING btree (uprn);


--
-- Name: bduk_uprn_tracking_uprn_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_uprn_idx ON adhoc.bduk_uprn_tracking USING btree (uprn);


--
-- Name: bduk_uprn_tracking_v2_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_v2_geom_idx ON adhoc.bduk_uprn_tracking_v2 USING gist (geom);


--
-- Name: bduk_uprn_tracking_v2_uprn_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bduk_uprn_tracking_v2_uprn_idx ON adhoc.bduk_uprn_tracking_v2 USING btree (uprn);


--
-- Name: bsr_high_rise_register_final_20251003_geom_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bsr_high_rise_register_final_20251003_geom_geom_idx ON adhoc.bsr_high_rise_register_final_20251003_geom USING gist (geom);


--
-- Name: bsr_high_rise_register_final_20251003_postcode_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX bsr_high_rise_register_final_20251003_postcode_idx ON adhoc.bsr_high_rise_register_final_20251003 USING btree (postcode);


--
-- Name: idx_bsr_high_rise_register_final_20251003_address_trgm; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX idx_bsr_high_rise_register_final_20251003_address_trgm ON adhoc.bsr_high_rise_register_final_20251003 USING gin (structure_and_address public.gin_trgm_ops);


--
-- Name: idx_bsr_high_rise_register_final_20251003_address_upper_trgm; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX idx_bsr_high_rise_register_final_20251003_address_upper_trgm ON adhoc.bsr_high_rise_register_final_20251003 USING gin (upper((structure_and_address)::text) public.gin_trgm_ops);


--
-- Name: scci_bduk_mdu_geom_20250408_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX scci_bduk_mdu_geom_20250408_geom_idx ON adhoc.scci_bduk_mdu_geom_20250408 USING gist (geom);


--
-- Name: scci_bduk_mdu_geom_20250408_postcode_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX scci_bduk_mdu_geom_20250408_postcode_idx ON adhoc.scci_bduk_mdu_geom_20250408 USING btree (postcode);


--
-- Name: scci_cfl_mdu_pia_distance_with_bduk_geom_20250519_geom_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX scci_cfl_mdu_pia_distance_with_bduk_geom_20250519_geom_idx ON adhoc.scci_cfl_mdu_pia_distance_with_bduk_geom_20250519 USING gist (geom);


--
-- Name: tbl_abp_import_pao_text_trgm_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX tbl_abp_import_pao_text_trgm_idx ON adhoc.tbl_abp_import USING gin (upper((pao_text)::text) public.gin_trgm_ops) WHERE (((row_is_current)::text = 'Y'::text) AND (address_logical_status = 1));


--
-- Name: tbl_abp_import_parent_uprn_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX tbl_abp_import_parent_uprn_idx ON adhoc.tbl_abp_import USING btree (parent_uprn) WHERE ((row_is_current)::text = 'Y'::text);


--
-- Name: tbl_abp_import_postcode_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX tbl_abp_import_postcode_idx ON adhoc.tbl_abp_import USING btree (postcode);


--
-- Name: tbl_abp_import_postcode_pao_num_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX tbl_abp_import_postcode_pao_num_idx ON adhoc.tbl_abp_import USING btree (postcode, pao_start_number) WHERE (((row_is_current)::text = 'Y'::text) AND (address_logical_status = 1));


--
-- Name: tbl_abp_import_postcode_pao_text_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX tbl_abp_import_postcode_pao_text_idx ON adhoc.tbl_abp_import USING btree (postcode, upper((pao_text)::text)) WHERE (((row_is_current)::text = 'Y'::text) AND (address_logical_status = 1));


--
-- Name: tbl_abp_import_street_trgm_idx; Type: INDEX; Schema: adhoc; Owner: -
--

CREATE INDEX tbl_abp_import_street_trgm_idx ON adhoc.tbl_abp_import USING gin (upper((street_description)::text) public.gin_trgm_ops) WHERE (((row_is_current)::text = 'Y'::text) AND (address_logical_status = 1));


--
-- Name: abp_borough_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_borough_idx ON basedata.abp USING btree (borough);


--
-- Name: abp_borough_upper_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_borough_upper_idx ON basedata.abp USING btree (upper((borough)::text));


--
-- Name: abp_geom_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_geom_idx ON basedata.abp USING gist (geom);


--
-- Name: abp_import_removed_address_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_address_idx ON basedata.abp_import_removed USING gin (address public.gin_trgm_ops);


--
-- Name: abp_import_removed_borough_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_borough_idx ON basedata.abp_import_removed USING btree (borough);


--
-- Name: abp_import_removed_geom_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_geom_idx ON basedata.abp_import_removed USING gist (geom);


--
-- Name: abp_import_removed_postcode_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_postcode_idx ON basedata.abp_import_removed USING btree (postcode);


--
-- Name: abp_import_removed_postcode_idx1; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_postcode_idx1 ON basedata.abp_import_removed USING btree (postcode text_pattern_ops);


--
-- Name: abp_import_removed_postcode_sector_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_postcode_sector_idx ON basedata.abp_import_removed USING btree (postcode_sector);


--
-- Name: abp_import_removed_street_name_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_street_name_idx ON basedata.abp_import_removed USING btree (street_name);


--
-- Name: abp_import_removed_to_tsvector_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_to_tsvector_idx ON basedata.abp_import_removed USING gin (to_tsvector('simple'::regconfig, address));


--
-- Name: abp_import_removed_upper_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_upper_idx ON basedata.abp_import_removed USING gin (upper(address) public.gin_trgm_ops);


--
-- Name: abp_import_removed_upper_idx1; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_upper_idx1 ON basedata.abp_import_removed USING btree (upper((borough)::text));


--
-- Name: abp_import_removed_uprn_cross_reference_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_uprn_cross_reference_idx ON basedata.abp_import_removed USING btree (uprn, cross_reference);


--
-- Name: abp_import_removed_uprn_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_uprn_idx ON basedata.abp_import_removed USING btree (uprn);


--
-- Name: abp_import_removed_uprn_postcode_address_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_uprn_postcode_address_idx ON basedata.abp_import_removed USING btree (uprn, postcode, address);


--
-- Name: abp_import_removed_usrn_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_import_removed_usrn_idx ON basedata.abp_import_removed USING btree (usrn);


--
-- Name: abp_postcode_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_postcode_idx ON basedata.abp USING btree (postcode);


--
-- Name: abp_street_name_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_street_name_idx ON basedata.abp USING btree (street_name);


--
-- Name: abp_title_no_index; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_title_no_index ON basedata.abp USING btree (title_no);


--
-- Name: abp_uprn_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_uprn_idx ON basedata.abp USING btree (uprn);


--
-- Name: abp_uprn_postcode_address_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_uprn_postcode_address_idx ON basedata.abp USING btree (uprn, postcode, address);


--
-- Name: abp_uprn_toid_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_uprn_toid_idx ON basedata.abp USING btree (uprn, cross_reference);


--
-- Name: abp_usrn_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX abp_usrn_idx ON basedata.abp USING btree (usrn);


--
-- Name: bduk_uk_geom_geom_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX bduk_uk_geom_geom_idx ON basedata.bduk_uk_geom USING gist (geom);


--
-- Name: idx_abp_address_gin; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX idx_abp_address_gin ON basedata.abp USING gin (to_tsvector('simple'::regconfig, address));


--
-- Name: idx_abp_address_trgm; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX idx_abp_address_trgm ON basedata.abp USING gin (address public.gin_trgm_ops);


--
-- Name: idx_abp_postcode_sector; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX idx_abp_postcode_sector ON basedata.abp USING btree (postcode_sector);


--
-- Name: idx_abp_postcode_text_pattern; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX idx_abp_postcode_text_pattern ON basedata.abp USING btree (postcode text_pattern_ops);


--
-- Name: idx_abp_trgm; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX idx_abp_trgm ON basedata.abp USING gin (upper(address) public.gin_trgm_ops);


--
-- Name: idx_toid_building_type_toid; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX idx_toid_building_type_toid ON basedata.toid_building_type USING btree (toid);


--
-- Name: os_code_point_open_geom_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX os_code_point_open_geom_idx ON basedata.os_code_point_open USING gist (geom);


--
-- Name: os_code_point_open_postcode_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX os_code_point_open_postcode_idx ON basedata.os_code_point_open USING btree (postcode);


--
-- Name: postcode_summary_postcode_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX postcode_summary_postcode_idx ON basedata.postcode_summary USING btree (postcode);


--
-- Name: tbl_uk_postcode_unit_geom_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX tbl_uk_postcode_unit_geom_idx ON basedata.tbl_uk_postcode_unit USING gist (geom);


--
-- Name: toid_building_type_geom_toid_geom_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX toid_building_type_geom_toid_geom_idx ON basedata.toid_building_type_geom USING gist (geom);


--
-- Name: toid_building_type_geom_toid_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX toid_building_type_geom_toid_idx ON basedata.toid_building_type_geom USING btree (toid);


--
-- Name: toid_building_type_toid_idx; Type: INDEX; Schema: basedata; Owner: -
--

CREATE INDEX toid_building_type_toid_idx ON basedata.toid_building_type USING btree (toid);


--
-- Name: community_fibre_pt_postcode_idx; Type: INDEX; Schema: competitor_data; Owner: -
--

CREATE INDEX community_fibre_pt_postcode_idx ON competitor_data.community_fibre_pt USING btree (postcode);


--
-- Name: community_fibre_pt_status_idx; Type: INDEX; Schema: competitor_data; Owner: -
--

CREATE INDEX community_fibre_pt_status_idx ON competitor_data.community_fibre_pt USING btree (status);


--
-- Name: community_fibre_pt_uprn_idx; Type: INDEX; Schema: competitor_data; Owner: -
--

CREATE INDEX community_fibre_pt_uprn_idx ON competitor_data.community_fibre_pt USING btree (uprn);


--
-- Name: competitor_cfl_postcode_geom_idx; Type: INDEX; Schema: competitor_data; Owner: -
--

CREATE INDEX competitor_cfl_postcode_geom_idx ON competitor_data.competitor_cfl_postcode USING gist (geom);


--
-- Name: competitor_summary_postcode_fttp_providers_idx; Type: INDEX; Schema: competitor_data; Owner: -
--

CREATE INDEX competitor_summary_postcode_fttp_providers_idx ON competitor_data.competitor_summary_postcode USING btree (fttp_providers, operators);


--
-- Name: competitor_summary_postcode_geom_idx; Type: INDEX; Schema: competitor_data; Owner: -
--

CREATE INDEX competitor_summary_postcode_geom_idx ON competitor_data.competitor_summary_postcode USING gist (geom);


--
-- Name: openreach_postcode_idx; Type: INDEX; Schema: competitor_data; Owner: -
--

CREATE INDEX openreach_postcode_idx ON competitor_data.openreach USING btree (postcode);


--
-- Name: ccod_address_matches_title_number_tenure_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_address_matches_title_number_tenure_idx ON landregistry.ccod_address_matches USING btree (tenure, title_number);


--
-- Name: ccod_address_matches_toid_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_address_matches_toid_idx ON landregistry.ccod_address_matches USING btree (toid);


--
-- Name: ccod_company_id_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_company_id_idx ON landregistry.ccod USING btree (company_id);


--
-- Name: ccod_company_summary_proprietor_1_address_1_trgm_upper_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_company_summary_proprietor_1_address_1_trgm_upper_idx ON landregistry.ccod_company_summary USING gin (upper(proprietor_1_address_1) public.gin_trgm_ops);


--
-- Name: ccod_company_summary_proprietor_name_1_trgm_upper_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_company_summary_proprietor_name_1_trgm_upper_idx ON landregistry.ccod_company_summary USING gin (upper(proprietor_name_1) public.gin_trgm_ops);


--
-- Name: ccod_district_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_district_idx ON landregistry.ccod USING btree (district);


--
-- Name: ccod_district_upper_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_district_upper_idx ON landregistry.ccod USING btree (upper((district)::text));


--
-- Name: ccod_postcode_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_postcode_idx ON landregistry.ccod USING btree (postcode);


--
-- Name: ccod_property_address_trgm_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_property_address_trgm_idx ON landregistry.ccod USING gin (property_address public.gin_trgm_ops);


--
-- Name: ccod_property_address_trgm_upper_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_property_address_trgm_upper_idx ON landregistry.ccod USING gin (upper(property_address) public.gin_trgm_ops);


--
-- Name: ccod_title_number_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX ccod_title_number_idx ON landregistry.ccod USING btree (title_number);


--
-- Name: idx_ccod_address_words; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX idx_ccod_address_words ON landregistry.ccod USING gin (address_words);


--
-- Name: idx_ccod_postcode_sector; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX idx_ccod_postcode_sector ON landregistry.ccod USING btree (postcode_sector);


--
-- Name: proprietor_1_address_1_trgm_upper_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX proprietor_1_address_1_trgm_upper_idx ON landregistry.ccod USING gin (upper(proprietor_1_address_1) public.gin_trgm_ops);


--
-- Name: proprietor_name_1_trgm_upper_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX proprietor_name_1_trgm_upper_idx ON landregistry.ccod USING gin (upper(proprietor_name_1) public.gin_trgm_ops);


--
-- Name: toid_title_map_freehold_title_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX toid_title_map_freehold_title_idx ON landregistry.toid_title_map USING btree (freehold_title_no, os_topo_toid);


--
-- Name: toid_title_map_os_topo_toid_idx; Type: INDEX; Schema: landregistry; Owner: -
--

CREATE INDEX toid_title_map_os_topo_toid_idx ON landregistry.toid_title_map USING btree (os_topo_toid, freehold_title_no);


--
-- Name: chamber_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX chamber_geom_idx ON openreach.chamber USING gist (geom);


--
-- Name: duct_geom_characteristics_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_geom_characteristics_idx ON openreach.duct USING btree (((((((public.st_srid(shape))::text || ':'::text) || upper(public.geometrytype(shape))) || ':'::text) || public.st_zmflag(shape))));


--
-- Name: duct_import_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_import_id_idx ON openreach.duct USING btree (import_id);


--
-- Name: duct_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_objectid_idx ON openreach.duct USING btree (objectid);


--
-- Name: duct_road_crossing_test_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_road_crossing_test_objectid_idx ON openreach.duct_road_crossing_test USING btree (objectid);


--
-- Name: duct_segment_test_import_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_segment_test_import_id_idx ON openreach.duct_segment_test USING btree (import_id);


--
-- Name: duct_segment_test_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_segment_test_objectid_idx ON openreach.duct_segment_test USING btree (objectid);


--
-- Name: duct_segment_test_source_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_segment_test_source_idx ON openreach.duct_segment_test USING btree (source);


--
-- Name: duct_segment_test_target_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_segment_test_target_idx ON openreach.duct_segment_test USING btree (target);


--
-- Name: duct_segment_test_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_segment_test_the_geom_idx ON openreach.duct_segment_test USING gist (geom);


--
-- Name: duct_segment_test_vertices_pgr_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_segment_test_vertices_pgr_the_geom_idx ON openreach.duct_segment_test_vertices_pgr USING gist (the_geom);


--
-- Name: duct_shape_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_shape_idx ON openreach.duct USING gist (shape);


--
-- Name: duct_source_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_source_idx ON openreach.duct USING btree (source);


--
-- Name: duct_target_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_target_idx ON openreach.duct USING btree (target);


--
-- Name: duct_test_import_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_test_import_id_idx ON openreach.duct_test USING btree (import_id);


--
-- Name: duct_test_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_test_objectid_idx ON openreach.duct_test USING btree (objectid);


--
-- Name: duct_test_shape_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_test_shape_idx ON openreach.duct_test USING gist (shape);


--
-- Name: duct_test_source_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_test_source_idx ON openreach.duct_test USING btree (source);


--
-- Name: duct_test_target_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_test_target_idx ON openreach.duct_test USING btree (target);


--
-- Name: duct_test_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_test_the_geom_idx ON openreach.duct_test USING gist (shape);


--
-- Name: duct_test_vertices_pgr_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_test_vertices_pgr_the_geom_idx ON openreach.duct_test_vertices_pgr USING gist (the_geom);


--
-- Name: duct_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_the_geom_idx ON openreach.duct USING gist (shape);


--
-- Name: duct_ursn_map_test_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_ursn_map_test_objectid_idx ON openreach.duct_ursn_map_test USING btree (objectid);


--
-- Name: duct_ursn_map_test_usrn_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_ursn_map_test_usrn_idx ON openreach.duct_ursn_map_test USING btree (usrn);


--
-- Name: duct_vertice_pgr_ursn_map_test_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_vertice_pgr_ursn_map_test_id_idx ON openreach.duct_vertice_pgr_ursn_map_test USING btree (id);


--
-- Name: duct_vertice_pgr_ursn_map_test_usrn_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_vertice_pgr_ursn_map_test_usrn_idx ON openreach.duct_vertice_pgr_ursn_map_test USING btree (usrn);


--
-- Name: duct_vertices_pgr_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX duct_vertices_pgr_the_geom_idx ON openreach.duct_vertices_pgr USING gist (the_geom);


--
-- Name: exchanges_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX exchanges_geom_idx ON openreach.exchanges USING gist (geom);


--
-- Name: import_duct_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX import_duct_id_idx ON openreach.import_duct USING btree (id);


--
-- Name: import_duct_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX import_duct_objectid_idx ON openreach.import_duct USING btree (objectid);


--
-- Name: import_duct_shape_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX import_duct_shape_idx ON openreach.import_duct USING gist (shape);


--
-- Name: import_structure_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX import_structure_id_idx ON openreach.import_structure USING btree (id);


--
-- Name: import_structure_object_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX import_structure_object_id_idx ON openreach.import_structure USING btree (object_id);


--
-- Name: import_structure_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX import_structure_objectid_idx ON openreach.import_structure USING btree (objectid);


--
-- Name: import_structure_shape_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX import_structure_shape_idx ON openreach.import_structure USING gist (shape);


--
-- Name: live_mdu_equipment_vert_map_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX live_mdu_equipment_vert_map_id_idx ON openreach.live_mdu_equipment_vert_map USING btree (id);


--
-- Name: live_mdu_equipment_vert_map_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX live_mdu_equipment_vert_map_objectid_idx ON openreach.live_mdu_equipment_vert_map USING btree (objectid);


--
-- Name: network_equipment_cab_map_eqip_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX network_equipment_cab_map_eqip_id_idx ON openreach.network_equipment_cab_map USING btree (eqip_id);


--
-- Name: network_equipment_cab_map_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX network_equipment_cab_map_id_idx ON openreach.network_equipment_cab_map USING btree (id);


--
-- Name: openreach_scrape_grid_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX openreach_scrape_grid_geom_idx ON openreach.openreach_scrape_grid USING gist (center_geom);


--
-- Name: openreach_scrape_grid_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX openreach_scrape_grid_id_idx ON openreach.openreach_scrape_grid USING btree (id);


--
-- Name: or_dfx_postcode_ofcom_postcode_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX or_dfx_postcode_ofcom_postcode_idx ON openreach.or_dfx_postcode USING btree (ofcom_postcode);


--
-- Name: pole_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX pole_geom_idx ON openreach.pole USING gist (geom);


--
-- Name: span_coupler_geom_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX span_coupler_geom_geom_idx ON openreach.span_coupler USING gist (geom);


--
-- Name: spans_cost_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_cost_idx ON openreach.spans USING btree (cost);


--
-- Name: spans_geom_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_geom_geom_idx ON openreach.spans USING gist (the_geom);


--
-- Name: spans_shape_length_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_shape_length_idx ON openreach.spans USING btree (shape_length);


--
-- Name: spans_source_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_source_idx ON openreach.spans USING btree (source);


--
-- Name: spans_source_target_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_source_target_idx ON openreach.spans USING btree (source, target);


--
-- Name: spans_target_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_target_idx ON openreach.spans USING btree (target);


--
-- Name: spans_vertices_cab_map_cab_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_vertices_cab_map_cab_id_idx ON openreach.spans_vertices_cab_map USING btree (cab_id);


--
-- Name: spans_vertices_cab_map_map_id_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_vertices_cab_map_map_id_idx ON openreach.spans_vertices_cab_map USING btree (id);


--
-- Name: spans_vertices_pgr_object_type_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_vertices_pgr_object_type_idx ON openreach.spans_vertices_pgr USING btree (object_type);


--
-- Name: spans_vertices_pgr_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_vertices_pgr_objectid_idx ON openreach.spans_vertices_pgr USING btree (objectid);


--
-- Name: spans_vertices_pgr_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX spans_vertices_pgr_the_geom_idx ON openreach.spans_vertices_pgr USING gist (the_geom);


--
-- Name: structure_exchange_1141_code_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX structure_exchange_1141_code_idx ON openreach.structure USING btree (exchange_1141_code);


--
-- Name: structure_object_class_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX structure_object_class_idx ON openreach.structure USING btree (object_class);


--
-- Name: structure_shape_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX structure_shape_idx ON openreach.structure USING gist (shape);


--
-- Name: subset_objectid_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX subset_objectid_idx ON openreach.subset USING btree (objectid);


--
-- Name: subset_shape_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX subset_shape_idx ON openreach.subset USING gist (shape);


--
-- Name: subset_source_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX subset_source_idx ON openreach.subset USING btree (source);


--
-- Name: subset_target_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX subset_target_idx ON openreach.subset USING btree (target);


--
-- Name: subset_vertices_pgr_the_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX subset_vertices_pgr_the_geom_idx ON openreach.subset_vertices_pgr USING gist (the_geom);


--
-- Name: uk_map_grid_geom_idx; Type: INDEX; Schema: openreach; Owner: -
--

CREATE INDEX uk_map_grid_geom_idx ON openreach.uk_map_grid USING gist (geom);


--
-- Name: idx_highways_street_words; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX idx_highways_street_words ON ordnancesurvey.osmm_highways_street USING gin (street_words);


--
-- Name: idx_osmm_highways_street_street_names_designatedname1_authority; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX idx_osmm_highways_street_street_names_designatedname1_authority ON ordnancesurvey.osmm_highways_street_street_names USING gin (designatedname1_authority);


--
-- Name: idx_osmm_highways_street_street_names_street_words; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX idx_osmm_highways_street_street_names_street_words ON ordnancesurvey.osmm_highways_street_street_names USING gin (street_words);


--
-- Name: idx_osmm_highways_street_streetname_trgm; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX idx_osmm_highways_street_streetname_trgm ON ordnancesurvey.osmm_highways_street USING gin (designatedname1 public.gin_trgm_ops);


--
-- Name: idx_osmm_highways_street_streetname_trgm_upper; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX idx_osmm_highways_street_streetname_trgm_upper ON ordnancesurvey.osmm_highways_street USING gin (upper((designatedname1)::text) public.gin_trgm_ops);


--
-- Name: osmm_highways_street_geom_idx; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX osmm_highways_street_geom_idx ON ordnancesurvey.osmm_highways_street USING gist (geom);


--
-- Name: osmm_highways_street_identifier_idx; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX osmm_highways_street_identifier_idx ON ordnancesurvey.osmm_highways_street USING btree (identifier);


--
-- Name: osmm_highways_street_street_names_designatedname1_trgm_idx; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX osmm_highways_street_street_names_designatedname1_trgm_idx ON ordnancesurvey.osmm_highways_street_street_names USING gin (designatedname1 public.gin_trgm_ops);


--
-- Name: uprn_usrn_map_uprn_idx; Type: INDEX; Schema: ordnancesurvey; Owner: -
--

CREATE INDEX uprn_usrn_map_uprn_idx ON ordnancesurvey.uprn_usrn_map USING btree (uprn);


--
-- Name: projects_geom_idx; Type: INDEX; Schema: projects; Owner: -
--

CREATE INDEX projects_geom_idx ON projects.projects USING gist (geom);


--
-- Name: projects_history_geom_idx; Type: INDEX; Schema: projects; Owner: -
--

CREATE INDEX projects_history_geom_idx ON projects.projects_history USING gist (geom);


--
-- Name: projects_history_history_datetime_idx; Type: INDEX; Schema: projects; Owner: -
--

CREATE INDEX projects_history_history_datetime_idx ON projects.projects_history USING btree (history_datetime);


--
-- Name: projects_history_project_id_idx; Type: INDEX; Schema: projects; Owner: -
--

CREATE INDEX projects_history_project_id_idx ON projects.projects_history USING btree (project_id);


--
-- Name: network_blockages_geom_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_blockages_geom_idx ON prospector.pia_blockages USING gist (geom);


--
-- Name: network_cables_geom_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_cables_geom_idx ON prospector.network_cables USING gist (geom);


--
-- Name: network_cables_geom_user_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_cables_geom_user_idx ON prospector.network_cables USING gist (geom_user);


--
-- Name: network_cables_history_cable_id_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_cables_history_cable_id_idx ON prospector.network_cables_history USING btree (cable_id);


--
-- Name: network_duct_geom_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_duct_geom_idx ON prospector.network_duct USING gist (geom);


--
-- Name: network_duct_geom_user_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_duct_geom_user_idx ON prospector.network_duct USING gist (geom_user);


--
-- Name: network_subduct_geom_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_subduct_geom_idx ON prospector.network_subduct USING gist (geom);


--
-- Name: network_subduct_geom_user_idx; Type: INDEX; Schema: prospector; Owner: -
--

CREATE INDEX network_subduct_geom_user_idx ON prospector.network_subduct USING gist (geom_user);


--
-- Name: full_ultimate_postcode_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX full_ultimate_postcode_idx ON public.full_ultimate USING btree (postcode);


--
-- Name: geolynx_address_staging_file_upload_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX geolynx_address_staging_file_upload_idx ON public.geolynx_address_staging USING btree (file_upload_id);


--
-- Name: geolynx_address_staging_stocklist_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX geolynx_address_staging_stocklist_idx ON public.geolynx_address_staging USING btree (stocklist_id);


--
-- Name: idx_file_uploads_agreement_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_file_uploads_agreement_id ON public.file_uploads USING btree (agreement_id) WHERE (((entity)::text = 'wayleave'::text) AND (file_is_deleted = false));


--
-- Name: idx_geolynx_identifiers_batch_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_geolynx_identifiers_batch_id ON public.geolynx_identifiers USING btree (batch_id);


--
-- Name: idx_geolynx_identifiers_stocklist_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_geolynx_identifiers_stocklist_id ON public.geolynx_identifiers USING btree (stocklist_id);


--
-- Name: idx_geolynx_identifiers_toid; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_geolynx_identifiers_toid ON public.geolynx_identifiers USING btree (toid) WHERE (toid IS NOT NULL);


--
-- Name: idx_geolynx_identifiers_uprn; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_geolynx_identifiers_uprn ON public.geolynx_identifiers USING btree (uprn) WHERE (uprn IS NOT NULL);


--
-- Name: idx_map_layers_layer_category; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_map_layers_layer_category ON public.map_layers USING btree (layer_category);


--
-- Name: idx_map_layers_layer_name; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_map_layers_layer_name ON public.map_layers USING btree (layer_name);


--
-- Name: idx_mlpc_page; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_mlpc_page ON public.map_layer_page_config USING btree (page_context);


--
-- Name: idx_stocklist_premises_uprn_stocklist; Type: INDEX; Schema: stocklists; Owner: -
--

CREATE INDEX idx_stocklist_premises_uprn_stocklist ON stocklists.stocklist_premises USING btree (uprn, stocklist_id);


--
-- Name: stocklist_import_jobs_stocklist_idx; Type: INDEX; Schema: stocklists; Owner: -
--

CREATE INDEX stocklist_import_jobs_stocklist_idx ON stocklists.stocklist_import_jobs USING btree (stocklist_id);


--
-- Name: stocklist_premises_uprn_idx; Type: INDEX; Schema: stocklists; Owner: -
--

CREATE INDEX stocklist_premises_uprn_idx ON stocklists.stocklist_premises USING btree (uprn);


--
-- Name: stocklists_geom_idx; Type: INDEX; Schema: stocklists; Owner: -
--

CREATE INDEX stocklists_geom_idx ON stocklists.stocklists USING gist (geom);


--
-- Name: stocklists_history_geom_idx; Type: INDEX; Schema: stocklists; Owner: -
--

CREATE INDEX stocklists_history_geom_idx ON stocklists.stocklists_history USING gist (geom);


--
-- Name: idx_cluster_boundary; Type: INDEX; Schema: temp; Owner: -
--

CREATE INDEX idx_cluster_boundary ON temp.cluster_boundary_points USING btree (exchange_1141_code);


--
-- Name: idx_cluster_boundary_geom; Type: INDEX; Schema: temp; Owner: -
--

CREATE INDEX idx_cluster_boundary_geom ON temp.cluster_boundary_points USING gist (geom);


--
-- Name: pia_structure_clusters_stg0_exchange_1141_code_idx; Type: INDEX; Schema: temp; Owner: -
--

CREATE INDEX pia_structure_clusters_stg0_exchange_1141_code_idx ON temp.pia_structure_clusters_stg0 USING btree (exchange_1141_code);


--
-- Name: pia_structure_clusters_stg0_geom_idx; Type: INDEX; Schema: temp; Owner: -
--

CREATE INDEX pia_structure_clusters_stg0_geom_idx ON temp.pia_structure_clusters_stg0 USING gist (geom);


--
-- Name: pia_structure_clusters_stg1_exchange_1141_code_idx; Type: INDEX; Schema: temp; Owner: -
--

CREATE INDEX pia_structure_clusters_stg1_exchange_1141_code_idx ON temp.pia_structure_clusters_stg1 USING btree (exchange_1141_code);


--
-- Name: pia_structure_clusters_stg1_geom_idx; Type: INDEX; Schema: temp; Owner: -
--

CREATE INDEX pia_structure_clusters_stg1_geom_idx ON temp.pia_structure_clusters_stg1 USING gist (geom);


--
-- Name: idx_active_sessions_session_id; Type: INDEX; Schema: users; Owner: -
--

CREATE INDEX idx_active_sessions_session_id ON users.active_sessions USING btree (session_id);


--
-- Name: idx_role_permissions_role; Type: INDEX; Schema: users; Owner: -
--

CREATE INDEX idx_role_permissions_role ON users.role_permissions USING btree (role_id);


--
-- Name: idx_user_item_permissions_item; Type: INDEX; Schema: users; Owner: -
--

CREATE INDEX idx_user_item_permissions_item ON users.user_item_permissions USING btree (item_type, item_id);


--
-- Name: idx_user_item_permissions_user; Type: INDEX; Schema: users; Owner: -
--

CREATE INDEX idx_user_item_permissions_user ON users.user_item_permissions USING btree (user_id);


--
-- Name: idx_user_roles_user; Type: INDEX; Schema: users; Owner: -
--

CREATE INDEX idx_user_roles_user ON users.user_roles USING btree (user_id);


--
-- Name: idx_users_login_log_session; Type: INDEX; Schema: users; Owner: -
--

CREATE INDEX idx_users_login_log_session ON users.users_login_log USING btree (session_id);


--
-- Name: idx_agr_field_opts; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_field_opts ON wayleave.agreement_field_dropdown_options USING btree (field_id) WHERE (is_active = true);


--
-- Name: idx_agr_fields_form_id; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_fields_form_id ON wayleave.agreement_fields USING btree (field_form_id);


--
-- Name: idx_agr_fvb_hist; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_fvb_hist ON wayleave.agreement_field_values_boolean_history USING btree (agreement_id);


--
-- Name: idx_agr_fvd_hist; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_fvd_hist ON wayleave.agreement_field_values_date_history USING btree (agreement_id);


--
-- Name: idx_agr_fvi_hist; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_fvi_hist ON wayleave.agreement_field_values_int_history USING btree (agreement_id);


--
-- Name: idx_agr_fvn_hist; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_fvn_hist ON wayleave.agreement_field_values_numeric_history USING btree (agreement_id);


--
-- Name: idx_agr_fvt_hist; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_fvt_hist ON wayleave.agreement_field_values_text_history USING btree (agreement_id);


--
-- Name: idx_agr_journal_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_journal_agreement ON wayleave.agreement_journal USING btree (agreement_id, log_datetime DESC);


--
-- Name: idx_agr_lr_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_lr_agreement ON wayleave.agreement_landregistry USING btree (agreement_id) WHERE (is_deleted = false);


--
-- Name: idx_agr_poly_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_poly_agreement ON wayleave.agreement_polygons USING btree (agreement_id) WHERE (is_deleted = false);


--
-- Name: idx_agr_poly_geom; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_poly_geom ON wayleave.agreement_polygons USING gist (geom);


--
-- Name: idx_agr_poly_uprns_active; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_poly_uprns_active ON wayleave.agreement_polygon_uprns USING btree (agreement_id, uprn) WHERE ((is_assigned = true) AND (is_approved = true));


--
-- Name: idx_agr_poly_uprns_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_poly_uprns_agreement ON wayleave.agreement_polygon_uprns USING btree (agreement_id);


--
-- Name: idx_agr_releases_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_releases_agreement ON wayleave.agreement_releases USING btree (agreement_id) WHERE (is_deleted = false);


--
-- Name: idx_agr_stocklists_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_stocklists_agreement ON wayleave.agreement_stocklists USING btree (agreement_id) WHERE (is_deleted = false);


--
-- Name: idx_agr_uprns_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_uprns_agreement ON wayleave.agreement_uprns USING btree (agreement_id) WHERE (is_deleted = false);


--
-- Name: idx_agr_uprns_uprn; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agr_uprns_uprn ON wayleave.agreement_uprns USING btree (uprn) WHERE (is_deleted = false);


--
-- Name: idx_agreement_access_log_agreement; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agreement_access_log_agreement ON wayleave.agreement_access_log USING btree (agreement_id);


--
-- Name: idx_agreement_access_log_user; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agreement_access_log_user ON wayleave.agreement_access_log USING btree (user_id);


--
-- Name: idx_agreements_company; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agreements_company ON wayleave.agreements USING btree (company_id);


--
-- Name: idx_agreements_geom; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agreements_geom ON wayleave.agreements USING gist (geom);


--
-- Name: idx_agreements_history_id; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agreements_history_id ON wayleave.agreements_history USING btree (agreement_id);


--
-- Name: idx_agreements_parent; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agreements_parent ON wayleave.agreements USING btree (parent_agreement_id);


--
-- Name: idx_agreements_status; Type: INDEX; Schema: wayleave; Owner: -
--

CREATE INDEX idx_agreements_status ON wayleave.agreements USING btree (agreement_status_id);


--
-- Name: accounts update_modified_fields_trigger; Type: TRIGGER; Schema: accounts; Owner: -
--

CREATE TRIGGER update_modified_fields_trigger BEFORE UPDATE ON accounts.accounts FOR EACH ROW EXECUTE FUNCTION accounts.accounts_update_modified_fields();


--
-- Name: projects trg_projects_history; Type: TRIGGER; Schema: projects; Owner: -
--

CREATE TRIGGER trg_projects_history AFTER INSERT OR DELETE OR UPDATE ON projects.projects FOR EACH ROW EXECUTE FUNCTION public.fn_projects_history();


--
-- Name: projects update_modified_fields_trigger; Type: TRIGGER; Schema: projects; Owner: -
--

CREATE TRIGGER update_modified_fields_trigger BEFORE UPDATE ON projects.projects FOR EACH ROW EXECUTE FUNCTION projects.projects_update_modified_fields();


--
-- Name: network_cables network_cables_calculate_length_trigger; Type: TRIGGER; Schema: prospector; Owner: -
--

CREATE TRIGGER network_cables_calculate_length_trigger BEFORE INSERT OR UPDATE ON prospector.network_cables FOR EACH ROW EXECUTE FUNCTION prospector.calculate_cable_length();


--
-- Name: network_cables network_cables_history_delete_trigger; Type: TRIGGER; Schema: prospector; Owner: -
--

CREATE TRIGGER network_cables_history_delete_trigger AFTER DELETE ON prospector.network_cables FOR EACH ROW EXECUTE FUNCTION prospector.network_cables_history_trigger();


--
-- Name: network_cables network_cables_history_insert_trigger; Type: TRIGGER; Schema: prospector; Owner: -
--

CREATE TRIGGER network_cables_history_insert_trigger AFTER INSERT ON prospector.network_cables FOR EACH ROW EXECUTE FUNCTION prospector.network_cables_history_trigger();


--
-- Name: network_cables network_cables_history_update_trigger; Type: TRIGGER; Schema: prospector; Owner: -
--

CREATE TRIGGER network_cables_history_update_trigger AFTER UPDATE ON prospector.network_cables FOR EACH ROW EXECUTE FUNCTION prospector.network_cables_history_trigger();


--
-- Name: stocklists update_modified_fields_trigger; Type: TRIGGER; Schema: stocklists; Owner: -
--

CREATE TRIGGER update_modified_fields_trigger BEFORE UPDATE ON stocklists.stocklists FOR EACH ROW EXECUTE FUNCTION stocklists.stocklists_update_modified_fields();


--
-- Name: account_field_category account_field_category_account_field_sections_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_category
    ADD CONSTRAINT account_field_category_account_field_sections_fk FOREIGN KEY (field_section_id) REFERENCES accounts.account_field_sections(field_section_id);


--
-- Name: account_field_dropdown_options account_field_dropdown_options_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_dropdown_options
    ADD CONSTRAINT account_field_dropdown_options_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_boolean account_field_values_boolean_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean
    ADD CONSTRAINT account_field_values_boolean_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_boolean account_field_values_boolean_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean
    ADD CONSTRAINT account_field_values_boolean_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_boolean_history account_field_values_boolean_history_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean_history
    ADD CONSTRAINT account_field_values_boolean_history_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_boolean_history account_field_values_boolean_history_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_boolean_history
    ADD CONSTRAINT account_field_values_boolean_history_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_date account_field_values_date_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date
    ADD CONSTRAINT account_field_values_date_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_date account_field_values_date_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date
    ADD CONSTRAINT account_field_values_date_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_date_history account_field_values_date_history_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date_history
    ADD CONSTRAINT account_field_values_date_history_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_date_history account_field_values_date_history_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_date_history
    ADD CONSTRAINT account_field_values_date_history_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_int account_field_values_int_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int
    ADD CONSTRAINT account_field_values_int_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_int account_field_values_int_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int
    ADD CONSTRAINT account_field_values_int_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_int_history account_field_values_int_history_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int_history
    ADD CONSTRAINT account_field_values_int_history_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_int_history account_field_values_int_history_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_int_history
    ADD CONSTRAINT account_field_values_int_history_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_numeric account_field_values_numeric_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric
    ADD CONSTRAINT account_field_values_numeric_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_numeric account_field_values_numeric_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric
    ADD CONSTRAINT account_field_values_numeric_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_numeric_history account_field_values_numeric_history_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric_history
    ADD CONSTRAINT account_field_values_numeric_history_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_numeric_history account_field_values_numeric_history_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_numeric_history
    ADD CONSTRAINT account_field_values_numeric_history_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_text account_field_values_text_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text
    ADD CONSTRAINT account_field_values_text_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_text account_field_values_text_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text
    ADD CONSTRAINT account_field_values_text_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_text_history account_field_values_text_history_account_fields_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text_history
    ADD CONSTRAINT account_field_values_text_history_account_fields_fk FOREIGN KEY (field_id) REFERENCES accounts.account_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: account_field_values_text_history account_field_values_text_history_accounts_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_field_values_text_history
    ADD CONSTRAINT account_field_values_text_history_accounts_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id) ON UPDATE RESTRICT;


--
-- Name: account_fields account_fields_account_field_category_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_fields
    ADD CONSTRAINT account_fields_account_field_category_fk FOREIGN KEY (field_category) REFERENCES accounts.account_field_category(field_category_id) ON UPDATE RESTRICT;


--
-- Name: account_fields account_fields_account_field_sections_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_fields
    ADD CONSTRAINT account_fields_account_field_sections_fk FOREIGN KEY (field_section) REFERENCES accounts.account_field_sections(field_section_id) ON UPDATE RESTRICT;


--
-- Name: account_fields account_fields_account_field_sub_category_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_fields
    ADD CONSTRAINT account_fields_account_field_sub_category_fk FOREIGN KEY (field_sub_category) REFERENCES accounts.account_field_sub_category(field_sub_category_id) ON UPDATE RESTRICT;


--
-- Name: account_premises account_premises_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.account_premises
    ADD CONSTRAINT account_premises_fk FOREIGN KEY (account_id) REFERENCES accounts.accounts(account_id);


--
-- Name: accounts accounts_account_manager_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts
    ADD CONSTRAINT accounts_account_manager_fk FOREIGN KEY (account_manager) REFERENCES users.users(id);


--
-- Name: accounts accounts_created_user_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts
    ADD CONSTRAINT accounts_created_user_fk FOREIGN KEY (created_user) REFERENCES public.users(id);


--
-- Name: accounts accounts_modified_user_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts
    ADD CONSTRAINT accounts_modified_user_fk FOREIGN KEY (modified_user) REFERENCES public.users(id);


--
-- Name: accounts accounts_parent_account_id_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts
    ADD CONSTRAINT accounts_parent_account_id_fk FOREIGN KEY (parent_account_id) REFERENCES accounts.accounts(account_id);


--
-- Name: accounts accounts_status_fk; Type: FK CONSTRAINT; Schema: accounts; Owner: -
--

ALTER TABLE ONLY accounts.accounts
    ADD CONSTRAINT accounts_status_fk FOREIGN KEY (account_status_id) REFERENCES accounts.account_status(account_status_id);


--
-- Name: project_field_category project_field_category_project_field_sections_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_category
    ADD CONSTRAINT project_field_category_project_field_sections_fk FOREIGN KEY (field_section_id) REFERENCES projects.project_field_sections(field_section_id);


--
-- Name: project_field_dropdown_options project_field_dropdown_options_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_dropdown_options
    ADD CONSTRAINT project_field_dropdown_options_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_boolean_history project_field_values_boolean_history_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean_history
    ADD CONSTRAINT project_field_values_boolean_history_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_boolean_history project_field_values_boolean_history_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean_history
    ADD CONSTRAINT project_field_values_boolean_history_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_boolean project_field_values_boolean_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean
    ADD CONSTRAINT project_field_values_boolean_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_boolean project_field_values_boolean_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_boolean
    ADD CONSTRAINT project_field_values_boolean_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_date_history project_field_values_date_history_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date_history
    ADD CONSTRAINT project_field_values_date_history_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_date_history project_field_values_date_history_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date_history
    ADD CONSTRAINT project_field_values_date_history_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_date project_field_values_date_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date
    ADD CONSTRAINT project_field_values_date_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_date project_field_values_date_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_date
    ADD CONSTRAINT project_field_values_date_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_int_history project_field_values_int_history_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int_history
    ADD CONSTRAINT project_field_values_int_history_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_int_history project_field_values_int_history_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int_history
    ADD CONSTRAINT project_field_values_int_history_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_int project_field_values_int_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int
    ADD CONSTRAINT project_field_values_int_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_int project_field_values_int_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_int
    ADD CONSTRAINT project_field_values_int_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_numeric_history project_field_values_numeric_history_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric_history
    ADD CONSTRAINT project_field_values_numeric_history_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_numeric_history project_field_values_numeric_history_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric_history
    ADD CONSTRAINT project_field_values_numeric_history_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_numeric project_field_values_numeric_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric
    ADD CONSTRAINT project_field_values_numeric_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_numeric project_field_values_numeric_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_numeric
    ADD CONSTRAINT project_field_values_numeric_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_text_history project_field_values_text_history_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text_history
    ADD CONSTRAINT project_field_values_text_history_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_text_history project_field_values_text_history_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text_history
    ADD CONSTRAINT project_field_values_text_history_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_text project_field_values_text_project_fields_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text
    ADD CONSTRAINT project_field_values_text_project_fields_fk FOREIGN KEY (field_id) REFERENCES projects.project_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: project_field_values_text project_field_values_text_projects_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_field_values_text
    ADD CONSTRAINT project_field_values_text_projects_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON UPDATE RESTRICT;


--
-- Name: project_fields project_fields_project_field_category_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_fields
    ADD CONSTRAINT project_fields_project_field_category_fk FOREIGN KEY (field_category) REFERENCES projects.project_field_category(field_category_id) ON UPDATE RESTRICT;


--
-- Name: project_fields project_fields_project_field_sections_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_fields
    ADD CONSTRAINT project_fields_project_field_sections_fk FOREIGN KEY (field_section) REFERENCES projects.project_field_sections(field_section_id) ON UPDATE RESTRICT;


--
-- Name: project_fields project_fields_project_field_sub_category_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_fields
    ADD CONSTRAINT project_fields_project_field_sub_category_fk FOREIGN KEY (field_sub_category) REFERENCES projects.project_field_sub_category(field_sub_category_id) ON UPDATE RESTRICT;


--
-- Name: project_file_uploads project_file_uploads_projects_project_id_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_file_uploads
    ADD CONSTRAINT project_file_uploads_projects_project_id_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id) ON DELETE CASCADE;


--
-- Name: project_premises project_premises_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.project_premises
    ADD CONSTRAINT project_premises_fk FOREIGN KEY (project_id) REFERENCES projects.projects(project_id);


--
-- Name: projects projects_created_user_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects
    ADD CONSTRAINT projects_created_user_fk FOREIGN KEY (created_user) REFERENCES users.users(id);


--
-- Name: projects projects_modified_user_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects
    ADD CONSTRAINT projects_modified_user_fk FOREIGN KEY (modified_user) REFERENCES users.users(id);


--
-- Name: projects projects_parent_project_id_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects
    ADD CONSTRAINT projects_parent_project_id_fk FOREIGN KEY (parent_project_id) REFERENCES projects.projects(project_id);


--
-- Name: projects projects_project_manager_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects
    ADD CONSTRAINT projects_project_manager_fk FOREIGN KEY (project_manager) REFERENCES users.users(id);


--
-- Name: projects projects_status_fk; Type: FK CONSTRAINT; Schema: projects; Owner: -
--

ALTER TABLE ONLY projects.projects
    ADD CONSTRAINT projects_status_fk FOREIGN KEY (project_status_id) REFERENCES projects.project_status(project_status_id);


--
-- Name: map_layer_page_config map_layer_page_config_layer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.map_layer_page_config
    ADD CONSTRAINT map_layer_page_config_layer_id_fkey FOREIGN KEY (layer_id) REFERENCES public.map_layers(layer_id) ON DELETE CASCADE;


--
-- Name: stocklist_field_category stocklist_field_category_stocklist_field_sections_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_category
    ADD CONSTRAINT stocklist_field_category_stocklist_field_sections_fk FOREIGN KEY (field_section_id) REFERENCES stocklists.stocklist_field_sections(field_section_id);


--
-- Name: stocklist_field_dropdown_options stocklist_field_dropdown_options_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_dropdown_options
    ADD CONSTRAINT stocklist_field_dropdown_options_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_boolean_history stocklist_field_values_boolean_history_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean_history
    ADD CONSTRAINT stocklist_field_values_boolean_history_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_boolean_history stocklist_field_values_boolean_history_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean_history
    ADD CONSTRAINT stocklist_field_values_boolean_history_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_boolean stocklist_field_values_boolean_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean
    ADD CONSTRAINT stocklist_field_values_boolean_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_boolean stocklist_field_values_boolean_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_boolean
    ADD CONSTRAINT stocklist_field_values_boolean_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_date_history stocklist_field_values_date_history_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date_history
    ADD CONSTRAINT stocklist_field_values_date_history_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_date_history stocklist_field_values_date_history_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date_history
    ADD CONSTRAINT stocklist_field_values_date_history_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_date stocklist_field_values_date_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date
    ADD CONSTRAINT stocklist_field_values_date_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_date stocklist_field_values_date_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_date
    ADD CONSTRAINT stocklist_field_values_date_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_int_history stocklist_field_values_int_history_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int_history
    ADD CONSTRAINT stocklist_field_values_int_history_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_int_history stocklist_field_values_int_history_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int_history
    ADD CONSTRAINT stocklist_field_values_int_history_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_int stocklist_field_values_int_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int
    ADD CONSTRAINT stocklist_field_values_int_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_int stocklist_field_values_int_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_int
    ADD CONSTRAINT stocklist_field_values_int_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_numeric_history stocklist_field_values_numeric_history_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric_history
    ADD CONSTRAINT stocklist_field_values_numeric_history_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_numeric_history stocklist_field_values_numeric_history_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric_history
    ADD CONSTRAINT stocklist_field_values_numeric_history_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_numeric stocklist_field_values_numeric_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric
    ADD CONSTRAINT stocklist_field_values_numeric_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_numeric stocklist_field_values_numeric_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_numeric
    ADD CONSTRAINT stocklist_field_values_numeric_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_text_history stocklist_field_values_text_history_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text_history
    ADD CONSTRAINT stocklist_field_values_text_history_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_text_history stocklist_field_values_text_history_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text_history
    ADD CONSTRAINT stocklist_field_values_text_history_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_text stocklist_field_values_text_stocklist_fields_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text
    ADD CONSTRAINT stocklist_field_values_text_stocklist_fields_fk FOREIGN KEY (field_id) REFERENCES stocklists.stocklist_fields(field_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_field_values_text stocklist_field_values_text_stocklists_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_field_values_text
    ADD CONSTRAINT stocklist_field_values_text_stocklists_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_fields stocklist_fields_stocklist_field_category_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_fields
    ADD CONSTRAINT stocklist_fields_stocklist_field_category_fk FOREIGN KEY (field_category) REFERENCES stocklists.stocklist_field_category(field_category_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_fields stocklist_fields_stocklist_field_sections_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_fields
    ADD CONSTRAINT stocklist_fields_stocklist_field_sections_fk FOREIGN KEY (field_section) REFERENCES stocklists.stocklist_field_sections(field_section_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_fields stocklist_fields_stocklist_field_sub_category_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_fields
    ADD CONSTRAINT stocklist_fields_stocklist_field_sub_category_fk FOREIGN KEY (field_sub_category) REFERENCES stocklists.stocklist_field_sub_category(field_sub_category_id) ON UPDATE RESTRICT;


--
-- Name: stocklist_premises stocklist_premises_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklist_premises
    ADD CONSTRAINT stocklist_premises_fk FOREIGN KEY (stocklist_id) REFERENCES stocklists.stocklists(stocklist_id);


--
-- Name: stocklists stocklists_created_user_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists
    ADD CONSTRAINT stocklists_created_user_fk FOREIGN KEY (created_user) REFERENCES users.users(id);


--
-- Name: stocklists stocklists_modified_user_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists
    ADD CONSTRAINT stocklists_modified_user_fk FOREIGN KEY (modified_user) REFERENCES users.users(id);


--
-- Name: stocklists stocklists_parent_stocklist_id_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists
    ADD CONSTRAINT stocklists_parent_stocklist_id_fk FOREIGN KEY (parent_stocklist_id) REFERENCES stocklists.stocklists(stocklist_id);


--
-- Name: stocklists stocklists_status_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists
    ADD CONSTRAINT stocklists_status_fk FOREIGN KEY (stocklist_status_id) REFERENCES stocklists.stocklist_status(stocklist_status_id);


--
-- Name: stocklists stocklists_stocklist_manager_fk; Type: FK CONSTRAINT; Schema: stocklists; Owner: -
--

ALTER TABLE ONLY stocklists.stocklists
    ADD CONSTRAINT stocklists_stocklist_manager_fk FOREIGN KEY (stocklist_manager) REFERENCES users.users(id);


--
-- Name: active_sessions active_sessions_login_log_id_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.active_sessions
    ADD CONSTRAINT active_sessions_login_log_id_fkey FOREIGN KEY (login_log_id) REFERENCES users.users_login_log(id) ON DELETE SET NULL;


--
-- Name: active_sessions active_sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.active_sessions
    ADD CONSTRAINT active_sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;


--
-- Name: role_permissions role_permissions_role_id_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.role_permissions
    ADD CONSTRAINT role_permissions_role_id_fkey FOREIGN KEY (role_id) REFERENCES users.roles(role_id) ON DELETE CASCADE;


--
-- Name: user_item_permissions user_item_permissions_granted_by_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_item_permissions
    ADD CONSTRAINT user_item_permissions_granted_by_fkey FOREIGN KEY (granted_by) REFERENCES users.users(id);


--
-- Name: user_item_permissions user_item_permissions_user_id_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_item_permissions
    ADD CONSTRAINT user_item_permissions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;


--
-- Name: user_roles user_roles_granted_by_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_roles
    ADD CONSTRAINT user_roles_granted_by_fkey FOREIGN KEY (granted_by) REFERENCES users.users(id);


--
-- Name: user_roles user_roles_role_id_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_roles
    ADD CONSTRAINT user_roles_role_id_fkey FOREIGN KEY (role_id) REFERENCES users.roles(role_id) ON DELETE CASCADE;


--
-- Name: user_roles user_roles_user_id_fkey; Type: FK CONSTRAINT; Schema: users; Owner: -
--

ALTER TABLE ONLY users.user_roles
    ADD CONSTRAINT user_roles_user_id_fkey FOREIGN KEY (user_id) REFERENCES users.users(id) ON DELETE CASCADE;


--
-- Name: agreement_access_log agreement_access_log_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_access_log
    ADD CONSTRAINT agreement_access_log_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id);


--
-- Name: agreement_field_category agreement_field_category_section_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_category
    ADD CONSTRAINT agreement_field_category_section_id_fkey FOREIGN KEY (section_id) REFERENCES wayleave.agreement_field_sections(id);


--
-- Name: agreement_field_dropdown_options agreement_field_dropdown_options_field_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_dropdown_options
    ADD CONSTRAINT agreement_field_dropdown_options_field_id_fkey FOREIGN KEY (field_id) REFERENCES wayleave.agreement_fields(field_id) ON DELETE CASCADE;


--
-- Name: agreement_field_sub_category agreement_field_sub_category_category_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_sub_category
    ADD CONSTRAINT agreement_field_sub_category_category_id_fkey FOREIGN KEY (category_id) REFERENCES wayleave.agreement_field_category(id);


--
-- Name: agreement_field_values_boolean agreement_field_values_boolean_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_boolean
    ADD CONSTRAINT agreement_field_values_boolean_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_boolean agreement_field_values_boolean_field_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_boolean
    ADD CONSTRAINT agreement_field_values_boolean_field_id_fkey FOREIGN KEY (field_id) REFERENCES wayleave.agreement_fields(field_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_date agreement_field_values_date_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_date
    ADD CONSTRAINT agreement_field_values_date_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_date agreement_field_values_date_field_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_date
    ADD CONSTRAINT agreement_field_values_date_field_id_fkey FOREIGN KEY (field_id) REFERENCES wayleave.agreement_fields(field_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_int agreement_field_values_int_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_int
    ADD CONSTRAINT agreement_field_values_int_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_int agreement_field_values_int_field_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_int
    ADD CONSTRAINT agreement_field_values_int_field_id_fkey FOREIGN KEY (field_id) REFERENCES wayleave.agreement_fields(field_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_numeric agreement_field_values_numeric_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_numeric
    ADD CONSTRAINT agreement_field_values_numeric_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_numeric agreement_field_values_numeric_field_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_numeric
    ADD CONSTRAINT agreement_field_values_numeric_field_id_fkey FOREIGN KEY (field_id) REFERENCES wayleave.agreement_fields(field_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_text agreement_field_values_text_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_text
    ADD CONSTRAINT agreement_field_values_text_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_field_values_text agreement_field_values_text_field_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_field_values_text
    ADD CONSTRAINT agreement_field_values_text_field_id_fkey FOREIGN KEY (field_id) REFERENCES wayleave.agreement_fields(field_id) ON DELETE CASCADE;


--
-- Name: agreement_fields agreement_fields_field_category_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_fields
    ADD CONSTRAINT agreement_fields_field_category_fkey FOREIGN KEY (field_category) REFERENCES wayleave.agreement_field_category(id);


--
-- Name: agreement_fields agreement_fields_field_section_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_fields
    ADD CONSTRAINT agreement_fields_field_section_fkey FOREIGN KEY (field_section) REFERENCES wayleave.agreement_field_sections(id);


--
-- Name: agreement_fields agreement_fields_field_sub_category_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_fields
    ADD CONSTRAINT agreement_fields_field_sub_category_fkey FOREIGN KEY (field_sub_category) REFERENCES wayleave.agreement_field_sub_category(id);


--
-- Name: agreement_journal agreement_journal_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_journal
    ADD CONSTRAINT agreement_journal_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_landregistry agreement_landregistry_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_landregistry
    ADD CONSTRAINT agreement_landregistry_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_polygon_uprns agreement_polygon_uprns_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_polygon_uprns
    ADD CONSTRAINT agreement_polygon_uprns_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_polygons agreement_polygons_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_polygons
    ADD CONSTRAINT agreement_polygons_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_releases agreement_releases_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_releases
    ADD CONSTRAINT agreement_releases_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_stocklists agreement_stocklists_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_stocklists
    ADD CONSTRAINT agreement_stocklists_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreement_uprns agreement_uprns_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreement_uprns
    ADD CONSTRAINT agreement_uprns_agreement_id_fkey FOREIGN KEY (agreement_id) REFERENCES wayleave.agreements(agreement_id) ON DELETE CASCADE;


--
-- Name: agreements agreements_agreement_status_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreements
    ADD CONSTRAINT agreements_agreement_status_id_fkey FOREIGN KEY (agreement_status_id) REFERENCES wayleave.agreement_status(id);


--
-- Name: agreements agreements_parent_agreement_id_fkey; Type: FK CONSTRAINT; Schema: wayleave; Owner: -
--

ALTER TABLE ONLY wayleave.agreements
    ADD CONSTRAINT agreements_parent_agreement_id_fkey FOREIGN KEY (parent_agreement_id) REFERENCES wayleave.agreements(agreement_id);


--
--

