--
--


SET transaction_timeout = 0;
SELECT pg_catalog.set_config('search_path', '', false);

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
--

-- *not* creating schema, since initdb creates it


ALTER SCHEMA public OWNER TO postgres;

--
-- Name: postgis; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;


--
-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions';


--
-- Name: usp_update_geom_event(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.usp_update_geom_event() RETURNS trigger
    LANGUAGE plpgsql
    AS $$

  BEGIN  

	-- as this is an after trigger, NEW contains all the information we need even for INSERT

	UPDATE treedetailsentered SET 

	geom = ST_SetSRID(ST_MakePoint(cast(NEW.longitude as double precision), cast(NEW.latitude as double precision)), 4326) WHERE tree_details_id=NEW.tree_details_id;



	RAISE NOTICE 'UPDATING geo data for %, [%,%]' , NEW.tree_details_id, NEW.latitude, NEW.longitude;	

    RETURN NULL; -- result is ignored since this is an AFTER trigger

  END;

$$;


ALTER FUNCTION public.usp_update_geom_event() OWNER TO postgres;

--
-- Name: usp_update_geom_event_new(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.usp_update_geom_event_new() RETURNS trigger
    LANGUAGE plpgsql
    AS $$

  BEGIN  

	-- as this is an after trigger, NEW contains all the information we need even for INSERT

	UPDATE treedetailsentered_new SET 

	geom = ST_SetSRID(ST_MakePoint(cast(NEW.longitude as double precision), cast(NEW.latitude as double precision)), 4326) WHERE tree_details_id_new=NEW.tree_details_id_new;



	RAISE NOTICE 'UPDATING geo data for %, [%,%]' , NEW.tree_details_id_new, NEW.latitude, NEW.longitude;	

    RETURN NULL; -- result is ignored since this is an AFTER trigger

  END;

$$;


ALTER FUNCTION public.usp_update_geom_event_new() OWNER TO postgres;



--
-- Name: active_user; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.active_user (
    id bigint NOT NULL,
    user_id integer,
    date date,
    "time" time without time zone,
    latitude character varying(20),
    longitude character varying(20)
);


ALTER TABLE public.active_user OWNER TO postgres;

--
-- Name: active_user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.active_user_id_seq OWNER TO postgres;

--
-- Name: active_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.active_user_id_seq OWNED BY public.active_user.id;


--
-- Name: amc_cantoment_zone; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.amc_cantoment_zone (
    gid integer NOT NULL,
    objectid_1 bigint,
    objectid_2 bigint,
    name character varying(50),
    details character varying(50),
    unique_id double precision,
    zone_amc character varying(20),
    new_ward_n character varying(50),
    shape_leng numeric,
    new_48 character varying(50),
    area_in_ha character varying(50),
    shape_le_1 numeric,
    shape_area numeric,
    geom public.geometry(MultiPolygon,32643)
);


ALTER TABLE public.amc_cantoment_zone OWNER TO postgres;

--
-- Name: amc_cantoment_zone_gid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.amc_cantoment_zone_gid_seq OWNER TO postgres;

--
-- Name: amc_cantoment_zone_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.amc_cantoment_zone_gid_seq OWNED BY public.amc_cantoment_zone.gid;


--
-- Name: amc_grid1; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.amc_grid1 (
    gid integer NOT NULL,
    grid character varying(50),
    geom public.geometry(MultiPolygon,4326)
);


ALTER TABLE public.amc_grid1 OWNER TO postgres;

--
-- Name: amc_grid1_gid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.amc_grid1_gid_seq OWNER TO postgres;

--
-- Name: amc_grid1_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.amc_grid1_gid_seq OWNED BY public.amc_grid1.gid;


--
-- Name: amc_grid2; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.amc_grid2 (
    gid integer NOT NULL,
    grid character varying(50),
    geom public.geometry(MultiPolygon,4326)
);


ALTER TABLE public.amc_grid2 OWNER TO postgres;

--
-- Name: amc_grid2_gid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.amc_grid2_gid_seq OWNER TO postgres;

--
-- Name: amc_grid2_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.amc_grid2_gid_seq OWNED BY public.amc_grid2.gid;


--
-- Name: amc_grid3; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.amc_grid3 (
    gid integer NOT NULL,
    ward_no bigint,
    grid character varying(50),
    geom public.geometry(MultiPolygon,4326)
);


ALTER TABLE public.amc_grid3 OWNER TO postgres;

--
-- Name: amc_grid3_gid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.amc_grid3_gid_seq OWNER TO postgres;

--
-- Name: amc_grid3_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.amc_grid3_gid_seq OWNED BY public.amc_grid3.gid;


--
-- Name: amc_ward_boundry; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.amc_ward_boundry (
    gid integer NOT NULL,
    ward_name character varying(100),
    zone_name character varying(100),
    ward_no integer,
    zone_no integer,
    area_sq_km numeric,
    area_ha numeric,
    ward character varying(100),
    shape_leng numeric,
    shape_area numeric,
    geom public.geometry(MultiPolygon,32643)
);


ALTER TABLE public.amc_ward_boundry OWNER TO postgres;

--
-- Name: amc_ward_boundry_gid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.amc_ward_boundry_gid_seq OWNER TO postgres;

--
-- Name: amc_ward_boundry_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.amc_ward_boundry_gid_seq OWNED BY public.amc_ward_boundry.gid;


--
-- Name: api_log; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.api_log (
    id bigint NOT NULL,
    uid integer,
    imei character varying(100),
    tag character varying(50),
    function_name character varying(50),
    message character varying(2400),
    log_date date,
    log_time time without time zone,
    email character varying(50)
);


ALTER TABLE public.api_log OWNER TO postgres;

--
-- Name: api_log_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.api_log_id_seq OWNER TO postgres;

--
-- Name: api_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.api_log_id_seq OWNED BY public.api_log.id;


--
-- Name: bird_nest; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.bird_nest (
    bird_nest_id integer NOT NULL,
    nest_value character varying(100)
);


ALTER TABLE public.bird_nest OWNER TO postgres;

--
-- Name: condition; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.condition (
    id integer NOT NULL,
    condition_name character varying(200)
);


ALTER TABLE public.condition OWNER TO postgres;

--
-- Name: growth_factor; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.growth_factor (
    id integer NOT NULL,
    tree_id integer,
    growth double precision
);


ALTER TABLE public.growth_factor OWNER TO postgres;

--
-- Name: growth_factor_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.growth_factor_id_seq OWNER TO postgres;

--
-- Name: growth_factor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.growth_factor_id_seq OWNED BY public.growth_factor.id;


--
-- Name: login_attempts; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.login_attempts (
    user_id bigint NOT NULL,
    "time" character varying
);


ALTER TABLE public.login_attempts OWNER TO postgres;

--
-- Name: login_attempts_user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.login_attempts_user_id_seq OWNER TO postgres;

--
-- Name: login_attempts_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.login_attempts_user_id_seq OWNED BY public.login_attempts.user_id;


--
-- Name: login_log_officer; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.login_log_officer (
    id bigint NOT NULL,
    email character varying(50),
    log_date date,
    log_time time without time zone,
    log_ip character varying(50)
);


ALTER TABLE public.login_log_officer OWNER TO postgres;

--
-- Name: login_log_officer_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.login_log_officer_id_seq OWNER TO postgres;

--
-- Name: login_log_officer_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.login_log_officer_id_seq OWNED BY public.login_log_officer.id;


--
-- Name: members; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.members (
    id bigint NOT NULL,
    username character varying(30),
    email character varying(50),
    password character varying(128),
    salt character varying(128),
    roleid integer DEFAULT 5,
    permissionid integer DEFAULT 0,
    contactno bigint
);


ALTER TABLE public.members OWNER TO postgres;

--
-- Name: members_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.members_id_seq OWNER TO postgres;

--
-- Name: members_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.members_id_seq OWNED BY public.members.id;


--
-- Name: no_permission; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.no_permission (
    id bigint NOT NULL,
    uid character varying(50),
    entered_date date,
    entered_time time without time zone,
    lat1 character varying(100),
    lon1 character varying(100),
    lat2 character varying(100),
    lon2 character varying(100),
    lat3 character varying(100),
    lon3 character varying(100),
    lat4 character varying(100),
    lon4 character varying(100),
    lat5 character varying(100),
    lon5 character varying(100),
    name character varying(100),
    reason character varying(200),
    email character varying(100),
    geom public.geometry(Polygon,4326),
    approxnooftreesinpremise character varying(100)
);


ALTER TABLE public.no_permission OWNER TO postgres;

--
-- Name: no_permission_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.no_permission_id_seq OWNER TO postgres;

--
-- Name: no_permission_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.no_permission_id_seq OWNED BY public.no_permission.id;


--
-- Name: operations; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.operations (
    operation_id integer NOT NULL,
    operation_name character varying(200)
);


ALTER TABLE public.operations OWNER TO postgres;

--
-- Name: ownership; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ownership (
    id integer NOT NULL,
    ownership_name character varying(200)
);


ALTER TABLE public.ownership OWNER TO postgres;

--
-- Name: path_details; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.path_details (
    id bigint NOT NULL,
    user_id integer,
    latitude character varying(20),
    longitude character varying(20),
    date date,
    "time" time without time zone
);


ALTER TABLE public.path_details OWNER TO postgres;

--
-- Name: path_details_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.path_details_id_seq OWNER TO postgres;

--
-- Name: path_details_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.path_details_id_seq OWNED BY public.path_details.id;


--
-- Name: qualitycheck_status; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.qualitycheck_status (
    id integer,
    status character varying(20),
    status_code character(3) NOT NULL,
    status_desc character varying(100)
);


ALTER TABLE public.qualitycheck_status OWNER TO postgres;

--
-- Name: random_count; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.random_count (
    id bigint NOT NULL,
    dates date,
    random_count integer
);


ALTER TABLE public.random_count OWNER TO postgres;

--
-- Name: random_count_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.random_count_id_seq OWNER TO postgres;

--
-- Name: random_count_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.random_count_id_seq OWNED BY public.random_count.id;


--
-- Name: remarks; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.remarks (
    id integer NOT NULL,
    remark_name character varying(200)
);


ALTER TABLE public.remarks OWNER TO postgres;

--
-- Name: remarks_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.remarks_id_seq OWNER TO postgres;

--
-- Name: remarks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.remarks_id_seq OWNED BY public.remarks.id;


--
-- Name: scope_of_plantation; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.scope_of_plantation (
    id bigint NOT NULL,
    latitude double precision,
    longitude double precision,
    entered_date date,
    entered_time time without time zone,
    google_address text,
    user_id integer
);


ALTER TABLE public.scope_of_plantation OWNER TO postgres;

--
-- Name: scope_of_plantation_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.scope_of_plantation_id_seq OWNER TO postgres;

--
-- Name: scope_of_plantation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.scope_of_plantation_id_seq OWNED BY public.scope_of_plantation.id;


--
-- Name: site_log; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.site_log (
    id bigint NOT NULL,
    client_ip inet,
    request_time timestamp with time zone DEFAULT now(),
    request text,
    session text,
    script text
);


ALTER TABLE public.site_log OWNER TO postgres;

--
-- Name: site_log_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.site_log_id_seq OWNER TO postgres;

--
-- Name: site_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.site_log_id_seq OWNED BY public.site_log.id;


--
-- Name: spacial_comment; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.spacial_comment (
    special_comment_id integer NOT NULL,
    special_comment character varying(100)
);


ALTER TABLE public.spacial_comment OWNER TO postgres;

--
-- Name: sub_operation; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sub_operation (
    sub_operation_id integer NOT NULL,
    sub_operation_name character varying(200)
);


ALTER TABLE public.sub_operation OWNER TO postgres;

--
-- Name: task_assignment; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.task_assignment (
    id bigint NOT NULL,
    task_id integer,
    assign_to_enum integer,
    assign_toenum_by integer,
    assign_to_enum_date date,
    assign_to_enum_time time without time zone,
    assign_to_qc integer,
    assign_to_qc_by integer,
    assign_to_qc_date date,
    assign_to_qc_time time without time zone,
    complete_status integer DEFAULT 0
);


ALTER TABLE public.task_assignment OWNER TO postgres;

--
-- Name: task_assignment_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.task_assignment_id_seq OWNER TO postgres;

--
-- Name: task_assignment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.task_assignment_id_seq OWNED BY public.task_assignment.id;


--
-- Name: task_status; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.task_status (
    task_status_id integer NOT NULL,
    task_status_value character varying(200)
);


ALTER TABLE public.task_status OWNER TO postgres;

--
-- Name: tasks; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tasks (
    task_id bigint NOT NULL,
    operation_id integer,
    creation_date date,
    creation_time time without time zone,
    society_name character varying(200),
    road_name character varying(200),
    landmark character varying(200),
    ward_name character varying(200),
    remarks character varying(500),
    latitude double precision,
    longitude double precision,
    google_address character varying(300),
    created_by_officer integer,
    assigned_to_enum integer DEFAULT 1,
    assigned_to_enum_by integer,
    assigned_to_enum_date date,
    assigned_to_enum_time time without time zone,
    assigned_to_qc integer DEFAULT 1,
    assigned_to_qc_by integer,
    assigned_to_qc_date date,
    assigned_to_qc_time time without time zone,
    task_status_id integer DEFAULT 1,
    enum_completed_date date,
    qc_completed_date date,
    final_submit_date date,
    final_submitted_by integer
);


ALTER TABLE public.tasks OWNER TO postgres;

--
-- Name: tasks_task_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.tasks_task_id_seq OWNER TO postgres;

--
-- Name: tasks_task_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.tasks_task_id_seq OWNED BY public.tasks.task_id;


--
-- Name: tree_backup_with_treelist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tree_backup_with_treelist (
    user_id integer,
    tree_id integer,
    latitude double precision,
    longitude double precision,
    grith_cm double precision,
    height_mtr integer,
    condition_id integer,
    ownership_id integer,
    societyname character varying(200),
    roadname character varying(200),
    entered_date date,
    entered_time time without time zone,
    tree_details_id bigint,
    googleaddress character varying(400),
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer,
    qc_status character(3),
    qc_final_submitted integer,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50),
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    un_submit_date date,
    un_submit_time time without time zone,
    un_updated_by bigint,
    comment_un text,
    bo_qc_submit_date date,
    bo_qc_submit_time time without time zone,
    bo_qc_done_by integer,
    comment_bo_qc text,
    bo_rare_qc_date date,
    bo_rare_qc_time time without time zone,
    bo_rare_qc_doneby integer,
    bo_rare_qc_comment text,
    dist_from_prev_tree integer,
    special_comment_id integer,
    bird_nest integer,
    nest_value character varying(100),
    special_comment character varying(100),
    email character varying(50),
    condition_name character varying(200),
    ownership_name character varying(200),
    remark_name character varying(200),
    tree_name character varying(30),
    isbalance character varying(50),
    task_id bigint,
    operation_name character varying,
    sub_operation_name character varying,
    tree_basin character varying,
    tree_trimming character varying,
    comman_name character varying(50),
    family character varying(30),
    phenology character varying(100),
    economic character varying(20),
    flowering character varying(20),
    color character varying(20),
    botanical character varying(200),
    is_rare integer
);


ALTER TABLE public.tree_backup_with_treelist OWNER TO postgres;

--
-- Name: tree_basin; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tree_basin (
    tree_basin_id integer NOT NULL,
    tree_basin_value character varying(100)
);


ALTER TABLE public.tree_basin OWNER TO postgres;

--
-- Name: tree_list_bkp_1_no_use_developer_can_delete; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tree_list_bkp_1_no_use_developer_can_delete (
    tree_name character varying(30),
    comman_name character varying(50),
    family character varying(30),
    phenology character varying(100),
    economic character varying(20),
    flowering character varying(20),
    color character varying(20),
    botanical character varying(200),
    tree_id integer,
    is_rare integer,
    priority integer,
    wood_density character varying(200),
    growth_factor double precision,
    gujarati_name character varying(200)
);


ALTER TABLE public.tree_list_bkp_1_no_use_developer_can_delete OWNER TO postgres;

--
-- Name: tree_survey; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tree_survey (
    gid integer NOT NULL,
    objectid bigint,
    botanical_ character varying(254),
    local_name character varying(254),
    common_nam character varying(254),
    girth_cm bigint,
    height_m bigint,
    canopy_dia bigint,
    canopy_typ character varying(254),
    condition character varying(254),
    remarks character varying(254),
    special_co character varying(254),
    family character varying(254),
    phenology character varying(254),
    economic_i character varying(254),
    flowering character varying(254),
    colour_of character varying(254),
    latitude numeric,
    longitude numeric,
    location character varying(254),
    bal_imbal character varying(254),
    society_na character varying(254),
    road_name character varying(254),
    ward_name character varying(254),
    rare_trees character varying(254),
    genus character varying(254),
    origin character varying(254),
    uid bigint,
    age character varying(50),
    geom public.geometry(Point,32643)
);


ALTER TABLE public.tree_survey OWNER TO postgres;

--
-- Name: tree_survey_gid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.tree_survey_gid_seq OWNER TO postgres;

--
-- Name: tree_survey_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.tree_survey_gid_seq OWNED BY public.tree_survey.gid;


--
-- Name: tree_trimming; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tree_trimming (
    tree_trimming_id integer NOT NULL,
    tree_trimming_value character varying(100)
);


ALTER TABLE public.tree_trimming OWNER TO postgres;

--
-- Name: treebal_imbalance; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treebal_imbalance (
    balance_id integer NOT NULL,
    isbalance character varying(50) NOT NULL
);


ALTER TABLE public.treebal_imbalance OWNER TO postgres;

--
-- Name: treecanopytype; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treecanopytype (
    canopytype_id integer NOT NULL,
    canopytype character varying(200)
);


ALTER TABLE public.treecanopytype OWNER TO postgres;

--
-- Name: treedata; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treedata (
    user_id integer,
    tree_id integer,
    latitude double precision,
    longitude double precision,
    grith_cm double precision,
    height_mtr integer,
    condition_id integer,
    ownership_id integer,
    societyname character varying(200),
    roadname character varying(200),
    entered_date date,
    entered_time time without time zone,
    tree_details_id bigint,
    googleaddress character varying(400),
    updated_date date,
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer,
    qc_status character(3),
    qc_final_submitted integer,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50),
    allocated_ward character varying(10),
    within_boundary character varying(10),
    new_or_old character varying(20),
    grid character varying(50),
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    dist_from_prev_tree integer,
    special_comment_id integer,
    bird_nest integer,
    resurvey_done integer,
    email character varying(50),
    condition_name character varying(200),
    ownership_name character varying(200),
    remark_name character varying(200),
    tree_name character varying(30),
    isbalance character varying(50),
    special_comment character varying(100),
    nest_value character varying(100)
);


ALTER TABLE public.treedata OWNER TO postgres;

--
-- Name: treedetailsentered; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treedetailsentered (
    user_id integer NOT NULL,
    tree_id integer NOT NULL,
    latitude double precision,
    longitude double precision,
    grith_cm double precision NOT NULL,
    height_mtr integer NOT NULL,
    condition_id integer NOT NULL,
    ownership_id integer NOT NULL,
    societyname character varying(200) NOT NULL,
    roadname character varying(200) NOT NULL,
    entered_date date,
    entered_time time without time zone,
    tree_details_id bigint NOT NULL,
    googleaddress character varying(400) NOT NULL,
    updated_date date,
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer DEFAULT 0,
    qc_status character(3),
    qc_final_submitted integer DEFAULT 0,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50) DEFAULT '0'::character varying,
    allocated_ward character varying(10) DEFAULT '0'::character varying,
    within_boundary character varying(10) DEFAULT '0'::character varying,
    new_or_old character varying(20) DEFAULT 'old'::character varying,
    grid character varying(50) DEFAULT 'na'::character varying,
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    dist_from_prev_tree integer,
    special_comment_id integer,
    bird_nest integer,
    resurvey_done integer DEFAULT 0,
    un_submit_date date,
    un_submit_time time without time zone,
    un_updated_by bigint,
    comment_un text,
    bo_qc_submit_date date,
    bo_qc_submit_time time without time zone,
    bo_qc_done_by integer,
    comment_bo_qc text,
    bo_rare_qc_date date,
    bo_rare_qc_time time without time zone,
    bo_rare_qc_doneby integer,
    bo_rare_qc_comment text,
    age double precision,
    date_of_plantation character varying(10),
    client_name text,
    contractor_name text,
    treename character varying(100),
    ownership_name character varying,
    ownership_contact_no character varying,
    manual_tree_details_id bigint DEFAULT 0
);


ALTER TABLE public.treedetailsentered OWNER TO postgres;

--
-- Name: treelist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treelist (
    tree_name character varying(30),
    comman_name character varying(50),
    family character varying(30),
    phenology character varying(100),
    economic character varying(20),
    flowering character varying(20),
    color character varying(20),
    botanical character varying(200),
    tree_id integer NOT NULL,
    is_rare integer DEFAULT 0,
    priority integer,
    wood_density character varying(200),
    growth_factor double precision,
    gujarati_name character varying(200)
);


ALTER TABLE public.treelist OWNER TO postgres;

--
-- Name: treeusers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treeusers (
    password character varying(100) NOT NULL,
    first_name character varying(50) NOT NULL,
    last_name character varying(50) NOT NULL,
    email character varying(50) NOT NULL,
    mobile_no character varying(50) NOT NULL,
    uid integer NOT NULL,
    user_type character varying(20),
    sqid integer DEFAULT 0 NOT NULL,
    syncid integer DEFAULT 0 NOT NULL,
    imei1 character varying(200) DEFAULT 0 NOT NULL,
    imei2 character varying(200) DEFAULT 0 NOT NULL,
    address character varying(256),
    city character varying(256),
    state character varying(256),
    pincode character varying(20),
    creation_date date DEFAULT ('now'::text)::date,
    enabled integer DEFAULT 1,
    map_type character varying(50),
    icon_type character varying(50),
    unique_id character varying(1000),
    encrypted_password character varying(1000),
    salt character varying(100),
    isadminrole character varying(100),
    isenabled character varying(100),
    created_at character varying(100),
    allocated_ward integer DEFAULT 0
);


ALTER TABLE public.treeusers OWNER TO postgres;

--
-- Name: treedata_disp; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.treedata_disp AS
 SELECT td.user_id,
    td.tree_id,
    td.latitude,
    td.longitude,
    td.grith_cm,
    td.height_mtr,
    td.condition_id,
    td.ownership_id,
    td.societyname,
    td.roadname,
    td.entered_date,
    td.entered_time,
    td.tree_details_id,
    td.googleaddress,
    td.qc_updated_time,
    td.updated_by,
    td.qc_done,
    td.qc_status,
    td.qc_final_submitted,
    td.qc_updated_date,
    td.geom,
    td.version2,
    td.user_seq_id,
    td.old_latitude,
    td.old_longitude,
    td.drag_distance,
    td.qc_old_latitude,
    td.qc_old_longitude,
    td.qc_drag_distance,
    td.lat2,
    td.lon2,
    td.geom_line,
    td.geom2,
    td.dist,
    td.other_name,
    td.bla_imbal_id,
    td.canopy_diameter,
    td.other_remarks,
    td.remarks_id,
    td.un_submit_date,
    td.un_submit_time,
    td.un_updated_by,
    td.comment_un,
    td.bo_qc_submit_date,
    td.bo_qc_submit_time,
    td.bo_qc_done_by,
    td.comment_bo_qc,
    td.bo_rare_qc_date,
    td.bo_rare_qc_time,
    td.bo_rare_qc_doneby,
    td.bo_rare_qc_comment,
    td.dist_from_prev_tree,
    td.special_comment_id,
    td.bird_nest,
    td.age,
    bn.nest_value,
    sc.special_comment,
    tu.email,
    co.condition_name,
    ow.ownership_name,
    rm.remark_name,
    tl.tree_name,
    bi.isbalance
   FROM public.treedetailsentered td,
    public.treeusers tu,
    public.condition co,
    public.ownership ow,
    public.remarks rm,
    public.treelist tl,
    public.spacial_comment sc,
    public.bird_nest bn,
    public.treebal_imbalance bi
  WHERE ((td.user_id = tu.uid) AND (td.condition_id = co.id) AND (td.ownership_id = ow.id) AND (td.remarks_id = rm.id) AND (td.bla_imbal_id = bi.balance_id) AND (td.tree_id = tl.tree_id) AND (td.special_comment_id = sc.special_comment_id) AND (td.bird_nest = bn.bird_nest_id));


ALTER VIEW public.treedata_disp OWNER TO postgres;

--
-- Name: treedetailsentered_bkp02012025; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treedetailsentered_bkp02012025 (
    user_id integer,
    tree_id integer,
    latitude double precision,
    longitude double precision,
    grith_cm double precision,
    height_mtr integer,
    condition_id integer,
    ownership_id integer,
    societyname character varying(200),
    roadname character varying(200),
    entered_date date,
    entered_time time without time zone,
    tree_details_id bigint,
    googleaddress character varying(400),
    updated_date date,
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer,
    qc_status character(3),
    qc_final_submitted integer,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50),
    allocated_ward character varying(10),
    within_boundary character varying(10),
    new_or_old character varying(20),
    grid character varying(50),
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    dist_from_prev_tree integer,
    special_comment_id integer,
    bird_nest integer,
    resurvey_done integer,
    un_submit_date date,
    un_submit_time time without time zone,
    un_updated_by bigint,
    comment_un text,
    bo_qc_submit_date date,
    bo_qc_submit_time time without time zone,
    bo_qc_done_by integer,
    comment_bo_qc text,
    bo_rare_qc_date date,
    bo_rare_qc_time time without time zone,
    bo_rare_qc_doneby integer,
    bo_rare_qc_comment text,
    age double precision,
    date_of_plantation character varying(10),
    client_name text,
    contractor_name text
);


ALTER TABLE public.treedetailsentered_bkp02012025 OWNER TO postgres;

--
-- Name: treedetailsentered_bkp15022025; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treedetailsentered_bkp15022025 (
    user_id integer,
    tree_id integer,
    latitude double precision,
    longitude double precision,
    grith_cm double precision,
    height_mtr integer,
    condition_id integer,
    ownership_id integer,
    societyname character varying(200),
    roadname character varying(200),
    entered_date date,
    entered_time time without time zone,
    tree_details_id bigint,
    googleaddress character varying(400),
    updated_date date,
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer,
    qc_status character(3),
    qc_final_submitted integer,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50),
    allocated_ward character varying(10),
    within_boundary character varying(10),
    new_or_old character varying(20),
    grid character varying(50),
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    dist_from_prev_tree integer,
    special_comment_id integer,
    bird_nest integer,
    resurvey_done integer,
    un_submit_date date,
    un_submit_time time without time zone,
    un_updated_by bigint,
    comment_un text,
    bo_qc_submit_date date,
    bo_qc_submit_time time without time zone,
    bo_qc_done_by integer,
    comment_bo_qc text,
    bo_rare_qc_date date,
    bo_rare_qc_time time without time zone,
    bo_rare_qc_doneby integer,
    bo_rare_qc_comment text,
    age double precision,
    date_of_plantation character varying(10),
    client_name text,
    contractor_name text,
    treename character varying(100)
);


ALTER TABLE public.treedetailsentered_bkp15022025 OWNER TO postgres;

--
-- Name: treedetailsentered_bkp_28042025; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treedetailsentered_bkp_28042025 (
    user_id integer,
    tree_id integer,
    latitude double precision,
    longitude double precision,
    grith_cm double precision,
    height_mtr integer,
    condition_id integer,
    ownership_id integer,
    societyname character varying(200),
    roadname character varying(200),
    entered_date date,
    entered_time time without time zone,
    tree_details_id bigint,
    googleaddress character varying(400),
    updated_date date,
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer,
    qc_status character(3),
    qc_final_submitted integer,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50),
    allocated_ward character varying(10),
    within_boundary character varying(10),
    new_or_old character varying(20),
    grid character varying(50),
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    dist_from_prev_tree integer,
    special_comment_id integer,
    bird_nest integer,
    resurvey_done integer,
    un_submit_date date,
    un_submit_time time without time zone,
    un_updated_by bigint,
    comment_un text,
    bo_qc_submit_date date,
    bo_qc_submit_time time without time zone,
    bo_qc_done_by integer,
    comment_bo_qc text,
    bo_rare_qc_date date,
    bo_rare_qc_time time without time zone,
    bo_rare_qc_doneby integer,
    bo_rare_qc_comment text,
    age double precision,
    date_of_plantation character varying(10),
    client_name text,
    contractor_name text,
    treename character varying(100),
    ownership_name character varying,
    ownership_contact_no character varying
);


ALTER TABLE public.treedetailsentered_bkp_28042025 OWNER TO postgres;

--
-- Name: treedetailsentered_new; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treedetailsentered_new (
    user_id integer NOT NULL,
    tree_id integer NOT NULL,
    latitude double precision,
    longitude double precision,
    grith_cm double precision NOT NULL,
    height_mtr integer NOT NULL,
    condition_id integer NOT NULL,
    ownership_id integer NOT NULL,
    societyname character varying(200) NOT NULL,
    roadname character varying(200) NOT NULL,
    entered_date date,
    entered_time time without time zone,
    tree_details_id_new bigint NOT NULL,
    tree_details_id_old bigint,
    googleaddress character varying(400) NOT NULL,
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer DEFAULT 0,
    qc_status character(3),
    qc_final_submitted integer DEFAULT 0,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50) DEFAULT '0'::character varying,
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    dist_from_prev_tree integer,
    spacial_comment_id integer,
    bird_nest integer,
    task_id integer,
    plantation_date date,
    cause_of_plantation character varying(500),
    file_track_no character varying(100),
    cause_of_cut character varying(300),
    cut_date date,
    fallen_date date,
    cause_of_fall character varying(300),
    transplant_date date,
    cause_of_transplant character varying(300),
    authority_approval_no character varying(200),
    transplanted_latitude double precision,
    transplanted_longitude double precision,
    sub_operation_id integer DEFAULT 0,
    tree_basin_id integer DEFAULT 0,
    tree_trimming_id integer DEFAULT 0,
    un_submit_date date,
    un_submit_time time without time zone,
    un_updated_by bigint,
    comment_un text,
    bo_qc_submit_date date,
    bo_qc_submit_time time without time zone,
    bo_qc_done_by integer,
    comment_bo_qc text,
    bo_rare_qc_date date,
    bo_rare_qc_time time without time zone,
    bo_rare_qc_doneby integer,
    bo_rare_qc_comment text
);


ALTER TABLE public.treedetailsentered_new OWNER TO postgres;

--
-- Name: treedetailsentered_new_tree_details_id_new_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.treedetailsentered_new_tree_details_id_new_seq OWNER TO postgres;

--
-- Name: treedetailsentered_new_tree_details_id_new_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.treedetailsentered_new_tree_details_id_new_seq OWNED BY public.treedetailsentered_new.tree_details_id_new;


--
-- Name: treedetailsentered_tree_details_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.treedetailsentered_tree_details_id_seq OWNER TO postgres;

--
-- Name: treedetailsentered_tree_details_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.treedetailsentered_tree_details_id_seq OWNED BY public.treedetailsentered.tree_details_id;


--
-- Name: treelist_bkp15022025; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treelist_bkp15022025 (
    tree_name character varying(30),
    comman_name character varying(50),
    family character varying(30),
    phenology character varying(100),
    economic character varying(20),
    flowering character varying(20),
    color character varying(20),
    botanical character varying(200),
    tree_id integer,
    is_rare integer,
    priority integer,
    wood_density character varying(200),
    growth_factor double precision,
    gujarati_name character varying(200)
);


ALTER TABLE public.treelist_bkp15022025 OWNER TO postgres;

--
-- Name: treelist_bkp_24072025; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treelist_bkp_24072025 (
    tree_name character varying(30),
    comman_name character varying(50),
    family character varying(30),
    phenology character varying(100),
    economic character varying(20),
    flowering character varying(20),
    color character varying(20),
    botanical character varying(200),
    tree_id integer,
    is_rare integer,
    priority integer,
    wood_density character varying(200),
    growth_factor double precision,
    gujarati_name character varying(200)
);


ALTER TABLE public.treelist_bkp_24072025 OWNER TO postgres;

--
-- Name: treelist_tree_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.treelist_tree_id_seq OWNER TO postgres;

--
-- Name: treelist_tree_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.treelist_tree_id_seq OWNED BY public.treelist.tree_id;


--
-- Name: treelist_update; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.treelist_update (
    tree_name character varying(30),
    comman_name character varying(50),
    family character varying(30),
    phenology character varying(100),
    economic character varying(20),
    flowering character varying(20),
    color character varying(20),
    botanical character varying(200),
    tree_id integer,
    is_rare integer,
    priority integer,
    wood_density character varying(200),
    growth_factor double precision,
    gujarati_name character varying(200)
);


ALTER TABLE public.treelist_update OWNER TO postgres;

--
-- Name: trees; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.trees (
    id bigint NOT NULL,
    geom public.geometry(Point,32643),
    oid integer,
    sr_no text,
    gps_no text,
    user_name text,
    local_name text,
    other_name text,
    girth_cm numeric(15,5),
    height_m numeric(15,5),
    canopy_dia_m numeric(15,5),
    condition text,
    other_remarks text,
    dist_frm_p numeric(15,5),
    ownership text,
    society_name text,
    road_name text,
    existing_t text,
    bird_nest boolean,
    date_time timestamp without time zone,
    feat_name text,
    datafile text,
    data_dictionary text,
    gnss_height double precision,
    northing double precision,
    easting double precision,
    point_id integer,
    balanced boolean,
    remarks text,
    special_collar text,
    ward_name text,
    ward_id integer,
    qc_comment text,
    client_comment text,
    qc_2 text,
    botanical_name text,
    common_name text,
    saar_uid text,
    phenology text,
    economic_i text,
    family_g text,
    colour_of text,
    flowering text,
    canopy_typ text,
    carbon_seq text,
    is_rare boolean DEFAULT false,
    age double precision,
    is_heritage integer DEFAULT 0,
    entered_date text,
    entered_time text,
    is_plantation integer DEFAULT 0
);


ALTER TABLE public.trees OWNER TO postgres;

--
-- Name: trees_backup; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.trees_backup (
    user_id integer,
    tree_id integer,
    latitude double precision,
    longitude double precision,
    grith_cm double precision,
    height_mtr integer,
    condition_id integer,
    ownership_id integer,
    societyname character varying(200),
    roadname character varying(200),
    entered_date date,
    entered_time time without time zone,
    tree_details_id bigint,
    googleaddress character varying(400),
    updated_date date,
    qc_updated_time time without time zone,
    updated_by integer,
    qc_done integer,
    qc_status character varying(50),
    qc_final_submitted integer,
    qc_updated_date date,
    geom public.geometry(Point,4326),
    version2 character varying(20),
    user_seq_id character varying(20),
    old_latitude double precision,
    old_longitude double precision,
    drag_distance character varying(50),
    qc_old_latitude double precision,
    qc_old_longitude double precision,
    qc_drag_distance character varying(50),
    allocated_ward character varying(10),
    within_boundary character varying(10),
    new_or_old character varying(20),
    grid character varying(50),
    lat2 double precision,
    lon2 double precision,
    geom_line public.geometry(LineString,4326),
    geom2 public.geometry(Point,4326),
    dist double precision,
    other_name character varying(200),
    bla_imbal_id integer,
    canopy_diameter double precision,
    other_remarks character varying(200),
    remarks_id integer,
    dist_from_prev_tree integer,
    special_comment_id integer,
    bird_nest integer,
    resurvey_done integer,
    email character varying(50),
    condition_name character varying(200),
    ownership_name character varying(200),
    remark_name character varying(200),
    tree_name character varying(30),
    isbalance character varying(50),
    special_comment character varying(100),
    nest_value character varying(100)
);


ALTER TABLE public.trees_backup OWNER TO postgres;

--
-- Name: trees_history; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.trees_history (
    id integer,
    geom public.geometry(Point,32643),
    oid integer,
    sr_no text,
    gps_no text,
    user_name text,
    local_name text,
    other_name text,
    girth_cm numeric(15,5),
    height_m numeric(15,5),
    canopy_dia_m numeric(15,5),
    condition text,
    other_remarks text,
    dist_frm_p numeric(15,5),
    ownership text,
    society_name text,
    road_name text,
    existing_t text,
    bird_nest boolean,
    date_time timestamp without time zone,
    feat_name text,
    datafile text,
    data_dictionary text,
    gnss_height double precision,
    northing double precision,
    easting double precision,
    point_id integer,
    balanced boolean,
    remarks text,
    special_collar text,
    ward_name text,
    ward_id integer,
    qc_comment text,
    client_comment text,
    qc_2 text,
    botanical_name text,
    common_name text,
    saar_uid text,
    phenology text,
    economic_i text,
    family_g text,
    colour_of text,
    flowering text,
    canopy_typ text,
    carbon_seq text,
    is_rare boolean DEFAULT false,
    age double precision,
    is_heritage integer DEFAULT 0,
    entered_time text,
    entered_date text,
    del_stamp timestamp without time zone,
    deleted_by integer,
    delete_remarks character varying(200),
    is_plantation integer DEFAULT 0
);


ALTER TABLE public.trees_history OWNER TO postgres;

--
-- Name: trees_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.trees_id_seq OWNER TO postgres;

--
-- Name: trees_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.trees_id_seq OWNED BY public.trees.id;


--
-- Name: treeusers_uid_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.treeusers_uid_seq OWNER TO postgres;

--
-- Name: treeusers_uid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.treeusers_uid_seq OWNED BY public.treeusers.uid;


--
-- Name: user_roles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.user_roles (
    role_type character varying(20) NOT NULL,
    user_role character varying(50)
);


ALTER TABLE public.user_roles OWNER TO postgres;

--
-- Name: wards; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.wards (
    id bigint NOT NULL,
    geom public.geometry(MultiPolygon,32643),
    objectid integer DEFAULT 0,
    name text,
    name_mr text,
    remarks text,
    zones integer DEFAULT 0,
    status character varying(50)
);


ALTER TABLE public.wards OWNER TO postgres;

--
-- Name: zones; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.zones (
    id bigint NOT NULL,
    name character varying,
    name_mr character varying
);


ALTER TABLE public.zones OWNER TO postgres;

--
-- Name: view_trees; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_trees AS
 SELECT trees.id,
    (public.st_transform(trees.geom, 3857))::public.geometry(Point,3857) AS geom,
    trees.oid,
    trees.sr_no,
    trees.gps_no,
    trees.user_name,
    trees.local_name,
    trees.other_name,
    trees.girth_cm,
    trees.height_m,
    trees.canopy_dia_m,
    trees.condition,
    trees.other_remarks,
    trees.dist_frm_p,
    trees.ownership,
    trees.society_name,
    trees.road_name,
    trees.existing_t,
    trees.bird_nest,
    trees.date_time,
    trees.feat_name,
    trees.datafile,
    trees.data_dictionary,
    trees.gnss_height,
    trees.northing,
    trees.easting,
    trees.point_id,
    trees.balanced,
    trees.remarks,
    trees.special_collar,
    trees.ward_name,
    trees.ward_id,
    trees.qc_comment,
    trees.client_comment,
    trees.qc_2,
    trees.botanical_name,
    trees.common_name,
    trees.saar_uid,
    trees.phenology,
    trees.economic_i,
    trees.family_g,
    trees.colour_of,
    trees.flowering,
    trees.canopy_typ,
    trees.carbon_seq,
    trees.is_rare,
    trees.is_heritage,
    trees.is_plantation,
    trees.age,
    trees.entered_date,
    trees.entered_time,
    NULL::timestamp without time zone AS del_stamp,
    0 AS deleted_by,
    ''::character varying AS delete_remarks,
    wards.name AS ward,
    zones.name AS zone_name,
    false AS is_deleted
   FROM public.trees,
    public.wards,
    public.zones
  WHERE ((trees.ward_id = wards.id) AND (wards.zones = zones.id))
UNION ALL
 SELECT trees_history.id,
    (public.st_transform(trees_history.geom, 3857))::public.geometry(Point,3857) AS geom,
    trees_history.oid,
    trees_history.sr_no,
    trees_history.gps_no,
    trees_history.user_name,
    trees_history.local_name,
    trees_history.other_name,
    trees_history.girth_cm,
    trees_history.height_m,
    trees_history.canopy_dia_m,
    trees_history.condition,
    trees_history.other_remarks,
    trees_history.dist_frm_p,
    trees_history.ownership,
    trees_history.society_name,
    trees_history.road_name,
    trees_history.existing_t,
    trees_history.bird_nest,
    trees_history.date_time,
    trees_history.feat_name,
    trees_history.datafile,
    trees_history.data_dictionary,
    trees_history.gnss_height,
    trees_history.northing,
    trees_history.easting,
    trees_history.point_id,
    trees_history.balanced,
    trees_history.remarks,
    trees_history.special_collar,
    trees_history.ward_name,
    trees_history.ward_id,
    trees_history.qc_comment,
    trees_history.client_comment,
    trees_history.qc_2,
    trees_history.botanical_name,
    trees_history.common_name,
    trees_history.saar_uid,
    trees_history.phenology,
    trees_history.economic_i,
    trees_history.family_g,
    trees_history.colour_of,
    trees_history.flowering,
    trees_history.canopy_typ,
    trees_history.carbon_seq,
    trees_history.is_rare,
    trees_history.is_heritage,
    trees_history.is_plantation,
    trees_history.age,
    trees_history.entered_date,
    trees_history.entered_time,
    trees_history.del_stamp,
    trees_history.deleted_by,
    trees_history.delete_remarks,
    wards.name AS ward,
    zones.name AS zone_name,
    true AS is_deleted
   FROM public.trees_history,
    public.wards,
    public.zones
  WHERE ((trees_history.ward_id = wards.id) AND (wards.zones = zones.id));


ALTER VIEW public.view_trees OWNER TO postgres;

--
-- Name: ward_bkps; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.ward_bkps (
    id bigint,
    geom public.geometry(MultiPolygon,32643),
    objectid integer,
    name text,
    name_mr text,
    remarks text,
    zones integer,
    status character varying(50)
);


ALTER TABLE public.ward_bkps OWNER TO postgres;

--
-- Name: wards_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.wards_id_seq OWNER TO postgres;

--
-- Name: wards_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.wards_id_seq OWNED BY public.wards.id;


--
-- Name: zones_bkps; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.zones_bkps (
    id bigint,
    name character varying,
    name_mr character varying
);


ALTER TABLE public.zones_bkps OWNER TO postgres;

--
-- Name: zones_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.zones_id_seq OWNER TO postgres;

--
-- Name: zones_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.zones_id_seq OWNED BY public.zones.id;


--
-- Name: active_user id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: amc_cantoment_zone gid; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_cantoment_zone ALTER COLUMN gid SET DEFAULT nextval('public.amc_cantoment_zone_gid_seq'::regclass);


--
-- Name: amc_grid1 gid; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_grid1 ALTER COLUMN gid SET DEFAULT nextval('public.amc_grid1_gid_seq'::regclass);


--
-- Name: amc_grid2 gid; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_grid2 ALTER COLUMN gid SET DEFAULT nextval('public.amc_grid2_gid_seq'::regclass);


--
-- Name: amc_grid3 gid; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_grid3 ALTER COLUMN gid SET DEFAULT nextval('public.amc_grid3_gid_seq'::regclass);


--
-- Name: amc_ward_boundry gid; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_ward_boundry ALTER COLUMN gid SET DEFAULT nextval('public.amc_ward_boundry_gid_seq'::regclass);


--
-- Name: api_log id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: growth_factor id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: login_attempts user_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.login_attempts ALTER COLUMN user_id SET DEFAULT nextval('public.login_attempts_user_id_seq'::regclass);


--
-- Name: login_log_officer id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: members id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: no_permission id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: path_details id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: random_count id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: remarks id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: scope_of_plantation id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: site_log id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: task_assignment id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: tasks task_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tasks ALTER COLUMN task_id SET DEFAULT nextval('public.tasks_task_id_seq'::regclass);


--
-- Name: tree_survey gid; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tree_survey ALTER COLUMN gid SET DEFAULT nextval('public.tree_survey_gid_seq'::regclass);


--
-- Name: treedetailsentered tree_details_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered ALTER COLUMN tree_details_id SET DEFAULT nextval('public.treedetailsentered_tree_details_id_seq'::regclass);


--
-- Name: treedetailsentered_new tree_details_id_new; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered_new ALTER COLUMN tree_details_id_new SET DEFAULT nextval('public.treedetailsentered_new_tree_details_id_new_seq'::regclass);


--
-- Name: treelist tree_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treelist ALTER COLUMN tree_id SET DEFAULT nextval('public.treelist_tree_id_seq'::regclass);


--
-- Name: trees id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: treeusers uid; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treeusers ALTER COLUMN uid SET DEFAULT nextval('public.treeusers_uid_seq'::regclass);


--
-- Name: wards id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: zones id; Type: DEFAULT; Schema: public; Owner: postgres
--

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


--
-- Name: active_user active_user_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.active_user
    ADD CONSTRAINT active_user_pkey PRIMARY KEY (id);


--
-- Name: amc_cantoment_zone amc_cantoment_zone_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_cantoment_zone
    ADD CONSTRAINT amc_cantoment_zone_pkey PRIMARY KEY (gid);


--
-- Name: amc_grid1 amc_grid1_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_grid1
    ADD CONSTRAINT amc_grid1_pkey PRIMARY KEY (gid);


--
-- Name: amc_grid2 amc_grid2_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_grid2
    ADD CONSTRAINT amc_grid2_pkey PRIMARY KEY (gid);


--
-- Name: amc_grid3 amc_grid3_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_grid3
    ADD CONSTRAINT amc_grid3_pkey PRIMARY KEY (gid);


--
-- Name: amc_ward_boundry amc_ward_boundry_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.amc_ward_boundry
    ADD CONSTRAINT amc_ward_boundry_pkey PRIMARY KEY (gid);


--
-- Name: api_log api_log_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.api_log
    ADD CONSTRAINT api_log_pkey PRIMARY KEY (id);


--
-- Name: bird_nest bird_nest_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.bird_nest
    ADD CONSTRAINT bird_nest_pkey PRIMARY KEY (bird_nest_id);


--
-- Name: treecanopytype canopyType_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treecanopytype
    ADD CONSTRAINT "canopyType_id" PRIMARY KEY (canopytype_id);


--
-- Name: condition condition_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.condition
    ADD CONSTRAINT condition_pkey PRIMARY KEY (id);


--
-- Name: login_log_officer login_log_officer_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.login_log_officer
    ADD CONSTRAINT login_log_officer_pkey PRIMARY KEY (id);


--
-- Name: members members_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.members
    ADD CONSTRAINT members_pkey PRIMARY KEY (id);


--
-- Name: no_permission no_permission_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.no_permission
    ADD CONSTRAINT no_permission_pkey PRIMARY KEY (id);


--
-- Name: operations operations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.operations
    ADD CONSTRAINT operations_pkey PRIMARY KEY (operation_id);


--
-- Name: ownership ownership_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.ownership
    ADD CONSTRAINT ownership_pkey PRIMARY KEY (id);


--
-- Name: path_details path_details_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.path_details
    ADD CONSTRAINT path_details_pkey PRIMARY KEY (id);


--
-- Name: qualitycheck_status qualitycheck_status_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.qualitycheck_status
    ADD CONSTRAINT qualitycheck_status_pkey PRIMARY KEY (status_code);


--
-- Name: random_count random_count_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.random_count
    ADD CONSTRAINT random_count_pkey PRIMARY KEY (id);


--
-- Name: remarks remarks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.remarks
    ADD CONSTRAINT remarks_pkey PRIMARY KEY (id);


--
-- Name: scope_of_plantation scope_of_plantation_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.scope_of_plantation
    ADD CONSTRAINT scope_of_plantation_pkey PRIMARY KEY (id);


--
-- Name: site_log site_log_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.site_log
    ADD CONSTRAINT site_log_pkey PRIMARY KEY (id);


--
-- Name: spacial_comment spacial_comment_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.spacial_comment
    ADD CONSTRAINT spacial_comment_pkey PRIMARY KEY (special_comment_id);


--
-- Name: sub_operation sub_operation_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.sub_operation
    ADD CONSTRAINT sub_operation_pkey PRIMARY KEY (sub_operation_id);


--
-- Name: task_status task_status_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.task_status
    ADD CONSTRAINT task_status_pkey PRIMARY KEY (task_status_id);


--
-- Name: tasks tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tasks
    ADD CONSTRAINT tasks_pkey PRIMARY KEY (task_id);


--
-- Name: tree_basin tree_basin_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tree_basin
    ADD CONSTRAINT tree_basin_pkey PRIMARY KEY (tree_basin_id);


--
-- Name: tree_survey tree_survey_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tree_survey
    ADD CONSTRAINT tree_survey_pkey PRIMARY KEY (gid);


--
-- Name: tree_trimming tree_trimming_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tree_trimming
    ADD CONSTRAINT tree_trimming_pkey PRIMARY KEY (tree_trimming_id);


--
-- Name: treedetailsentered treedetailsentered_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered
    ADD CONSTRAINT treedetailsentered_pkey PRIMARY KEY (tree_details_id);


--
-- Name: treedetailsentered_new treedetailsentered_pkey_new; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered_new
    ADD CONSTRAINT treedetailsentered_pkey_new PRIMARY KEY (tree_details_id_new);


--
-- Name: treelist treelist_pkey1; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treelist
    ADD CONSTRAINT treelist_pkey1 PRIMARY KEY (tree_id);


--
-- Name: trees trees_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.trees
    ADD CONSTRAINT trees_pkey PRIMARY KEY (id);


--
-- Name: treeusers treeusers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treeusers
    ADD CONSTRAINT treeusers_pkey PRIMARY KEY (uid);


--
-- Name: user_roles user_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.user_roles
    ADD CONSTRAINT user_roles_pkey PRIMARY KEY (role_type);


--
-- Name: wards wards_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.wards
    ADD CONSTRAINT wards_pkey PRIMARY KEY (id);


--
-- Name: zones zones_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.zones
    ADD CONSTRAINT zones_pkey PRIMARY KEY (id);


--
-- Name: amc_cantoment_zone_geom_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX amc_cantoment_zone_geom_idx ON public.amc_cantoment_zone USING gist (geom);


--
-- Name: amc_grid1_geom_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX amc_grid1_geom_idx ON public.amc_grid1 USING gist (geom);


--
-- Name: amc_grid2_geom_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX amc_grid2_geom_idx ON public.amc_grid2 USING gist (geom);


--
-- Name: amc_grid3_geom_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX amc_grid3_geom_idx ON public.amc_grid3 USING gist (geom);


--
-- Name: amc_ward_boundry_geom_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX amc_ward_boundry_geom_idx ON public.amc_ward_boundry USING gist (geom);


--
-- Name: idx_treedetails_geom; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_treedetails_geom ON public.treedetailsentered USING gist (geom);


--
-- Name: idx_treedetailsentered_geom; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_treedetailsentered_geom ON public.treedetailsentered USING gist (geom);


--
-- Name: idx_trees_geom; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX idx_trees_geom ON public.trees USING gist (geom);


--
-- Name: ind_entered_date; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ind_entered_date ON public.treedetailsentered USING btree (entered_date);


--
-- Name: ind_latitude; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ind_latitude ON public.treedetailsentered USING btree (latitude);


--
-- Name: ind_longitude; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ind_longitude ON public.treedetailsentered USING btree (longitude);


--
-- Name: ind_user_id; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX ind_user_id ON public.treedetailsentered USING btree (user_id);


--
-- Name: site_log_request_time_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX site_log_request_time_idx ON public.site_log USING btree (request_time);

ALTER TABLE public.site_log CLUSTER ON site_log_request_time_idx;


--
-- Name: tree_survey_geom_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX tree_survey_geom_idx ON public.tree_survey USING gist (geom);


--
-- Name: treedetailsentered tree_table_geo_updated; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER tree_table_geo_updated AFTER UPDATE OF latitude, longitude ON public.treedetailsentered FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event();


--
-- Name: treedetailsentered_new tree_table_geo_updated_new; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER tree_table_geo_updated_new AFTER UPDATE OF latitude, longitude ON public.treedetailsentered_new FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event_new();


--
-- Name: treedetailsentered tree_table_inserted; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER tree_table_inserted AFTER INSERT ON public.treedetailsentered FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event();


--
-- Name: treedetailsentered_new tree_table_inserted_new; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER tree_table_inserted_new AFTER INSERT ON public.treedetailsentered_new FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event_new();


--
-- Name: treedetailsentered usp_trig_geom_insert; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER usp_trig_geom_insert AFTER INSERT ON public.treedetailsentered FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event();


--
-- Name: treedetailsentered_new usp_trig_geom_insert_new; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER usp_trig_geom_insert_new AFTER INSERT ON public.treedetailsentered_new FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event_new();


--
-- Name: treedetailsentered usp_trig_geom_updated; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER usp_trig_geom_updated AFTER UPDATE OF latitude, longitude ON public.treedetailsentered FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event();


--
-- Name: treedetailsentered_new usp_trig_geom_updated_new; Type: TRIGGER; Schema: public; Owner: postgres
--

CREATE TRIGGER usp_trig_geom_updated_new AFTER UPDATE OF latitude, longitude ON public.treedetailsentered_new FOR EACH ROW EXECUTE FUNCTION public.usp_update_geom_event_new();


--
-- Name: treedetailsentered_new treedetailsentered_qc_status_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered_new
    ADD CONSTRAINT treedetailsentered_qc_status_fkey FOREIGN KEY (qc_status) REFERENCES public.qualitycheck_status(status_code);


--
-- Name: treedetailsentered treedetailsentered_qc_status_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered
    ADD CONSTRAINT treedetailsentered_qc_status_fkey FOREIGN KEY (qc_status) REFERENCES public.qualitycheck_status(status_code);


--
-- Name: treedetailsentered_new treedetailsentered_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered_new
    ADD CONSTRAINT treedetailsentered_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.treeusers(uid);


--
-- Name: treedetailsentered treedetailsentered_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.treedetailsentered
    ADD CONSTRAINT treedetailsentered_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.treeusers(uid);


--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE USAGE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
--

