diff --git a/data/database.sql b/data/database.sql new file mode 100644 index 00000000..baa98ca9 --- /dev/null +++ b/data/database.sql @@ -0,0 +1,1021 @@ +-- +-- You must install dblink first +-- cmd: psql -d dbname -f `locate dblink.sql` +-- and postgis support has been removed. +-- + +SET default_with_oids = false; + +CREATE TABLE aspnet_membership ( + "UserId" uuid NOT NULL, + "Password" character varying(128), + "PasswordFormat" integer, + "PasswordSalt" character varying(128), + "Email" character varying(256), + "CreateDate" timestamp without time zone, + "LastLoginDate" timestamp without time zone +); +ALTER TABLE public.aspnet_membership OWNER TO gis; + +CREATE TABLE aspnet_profile ( + "UserId" uuid NOT NULL, + "PropertyNames" text, + "PropertyValuesString" text, + "LastUpdatedDate" timestamp without time zone +); +ALTER TABLE public.aspnet_profile OWNER TO gis; + +CREATE TABLE aspnet_users ( + "UserId" uuid NOT NULL, + "UserName" character varying(256) NOT NULL, + "LastActivityDate" timestamp without time zone +); +ALTER TABLE public.aspnet_users OWNER TO gis; + +CREATE VIEW aspnet AS + SELECT m."Password" AS password, m."PasswordSalt" AS salt, m."Email" AS email, m."CreateDate" AS ts_created, m."LastLoginDate" AS ts_last_login, u."UserName" AS username, p."PropertyNames" AS property, p."PropertyValuesString" AS propertystring FROM aspnet_membership m, aspnet_users u, aspnet_profile p WHERE ((m."UserId" = u."UserId") AND (m."UserId" = p."UserId")); +ALTER TABLE public.aspnet OWNER TO gis; + +-- +-- metadata tables +-- + +CREATE TABLE metadata +( + uuid uuid NOT NULL, + title character varying(100) NOT NULL, + description text, + west real, + east real, + south real, + north real, + timebegin timestamp without time zone, + timeend timestamp without time zone, + id serial NOT NULL, + filesize real DEFAULT 0, + datatype integer NOT NULL DEFAULT 0, + citation text, + ts_created timestamp without time zone DEFAULT now(), + fileformat character varying(250), + projection character varying(200), + author character varying(250), + title_en character varying, + suppinfo text, + source character varying DEFAULT ''::character varying, + doi character varying NOT NULL DEFAULT ''::character varying, + CONSTRAINT metadata_pkey PRIMARY KEY (id), + CONSTRAINT metadata_uuid_key UNIQUE (uuid) +) +WITH ( + OIDS=FALSE +); +ALTER TABLE metadata OWNER TO gis; + +CREATE TABLE category ( + id integer NOT NULL, + code integer NOT NULL +); +ALTER TABLE public.category OWNER TO gis; + + +CREATE TABLE dataseries ( + id integer NOT NULL, + sid integer NOT NULL +); +ALTER TABLE public.dataseries OWNER TO gis; + +CREATE TABLE keyword ( + id integer NOT NULL, + keyword character varying(100) NOT NULL, + keytype character varying(100), + ts_created timestamp without time zone DEFAULT now() +); +ALTER TABLE public.keyword OWNER TO gis; + +CREATE TABLE onlineresource ( + id integer NOT NULL, + uuid uuid NOT NULL, + linkage character varying(500), + protocol character varying(200), + description character varying(250), + name character varying(200) +); +ALTER TABLE public.onlineresource OWNER TO gis; +CREATE SEQUENCE onlinesource_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.onlinesource_id_seq OWNER TO gis; +ALTER SEQUENCE onlinesource_id_seq OWNED BY onlineresource.id; + +-- +-- system tables +-- + +CREATE TABLE datafeature ( + id integer NOT NULL, + title character varying(200) NOT NULL, + description text NOT NULL, + detailurl character varying(200) NOT NULL, + imgtext character varying(200), + imgurl character varying(200) NOT NULL, + ts_created timestamp without time zone DEFAULT now() NOT NULL +); +ALTER TABLE public.datafeature OWNER TO gis; +CREATE SEQUENCE datafeature_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.datafeature_id_seq OWNER TO gis; +ALTER SEQUENCE datafeature_id_seq OWNED BY datafeature.id; + +CREATE TABLE datasetcd ( + id integer NOT NULL, + title character varying(500) NOT NULL, + size real, + url character varying(1000), + img character varying(300) NOT NULL, + document character varying(500) NOT NULL, + descript text, + ts_created timestamp without time zone DEFAULT now(), + uuid uuid +); +ALTER TABLE public.datasetcd OWNER TO gis; +CREATE SEQUENCE datasetcd_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.datasetcd_id_seq OWNER TO gis; +ALTER SEQUENCE datasetcd_id_seq OWNED BY datasetcd.id; + +-- +-- metadata supplement +-- + +CREATE TABLE categorycode ( + code integer NOT NULL, + name character varying(100) NOT NULL, + definition character varying(300), + name_zh character varying(100) +); +ALTER TABLE public.categorycode OWNER TO gis; + +CREATE TABLE datafile ( + id integer NOT NULL, + dsid integer NOT NULL, + filename character varying NOT NULL, + filesize double precision DEFAULT 0 NOT NULL, + ts_created timestamp without time zone DEFAULT now() NOT NULL, + isdir integer DEFAULT 0 NOT NULL, + depth integer DEFAULT 0 NOT NULL +); +ALTER TABLE public.datafile OWNER TO gis; +CREATE SEQUENCE datafile_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.datafile_id_seq OWNER TO gis; +ALTER SEQUENCE datafile_id_seq OWNED BY datafile.id; + +CREATE TABLE dataset ( + id integer NOT NULL, + uuid uuid NOT NULL, + host character varying(50) DEFAULT 'ftp1.westgis.ac.cn'::character varying NOT NULL, + path character varying NOT NULL, + ts_created timestamp without time zone DEFAULT now() NOT NULL +); +ALTER TABLE public.dataset OWNER TO gis; +CREATE SEQUENCE dataset_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.dataset_id_seq OWNER TO gis; +ALTER SEQUENCE dataset_id_seq OWNED BY dataset.id; + +-- +-- metadata extended +-- + +CREATE TABLE comments ( + id integer NOT NULL, + author character varying(200) NOT NULL, + email character varying(100) DEFAULT ''::character varying NOT NULL, + url character varying(200), + ip character varying(100), + ts_created timestamp without time zone DEFAULT now() NOT NULL, + content text NOT NULL, + agent character varying(255), + subscribe boolean DEFAULT true NOT NULL, + type character varying(20), + uuid uuid NOT NULL, + userid integer DEFAULT 0 NOT NULL +); +ALTER TABLE public.comments OWNER TO gis; +CREATE SEQUENCE comments_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.comments_id_seq OWNER TO gis; +ALTER SEQUENCE comments_id_seq OWNED BY comments.id; + +CREATE TABLE dataorder ( + ts_created timestamp without time zone DEFAULT now() NOT NULL, + userid integer NOT NULL, + status integer DEFAULT 0 NOT NULL, + ts_approved timestamp without time zone, + id integer NOT NULL, + uuid uuid, + offlineappid integer DEFAULT (-1) NOT NULL, + onlineappid integer DEFAULT (-1) NOT NULL +); +ALTER TABLE public.dataorder OWNER TO gis; + + +-- +-- TOC entry 216 (class 1259 OID 87960) +-- Dependencies: 2900 6 +-- Name: emailtext; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE emailtext ( + id integer NOT NULL, + subject character varying(200), + body text NOT NULL, + template character varying(100) NOT NULL, + ts_created timestamp without time zone DEFAULT now() NOT NULL, + ts_changed timestamp without time zone +); +ALTER TABLE public.emailtext OWNER TO gis; +CREATE SEQUENCE emailtext_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.emailtext_id_seq OWNER TO gis; +ALTER SEQUENCE emailtext_id_seq OWNED BY emailtext.id; + +CREATE TABLE ftpuser ( + userid integer NOT NULL, + pwd character varying(50), + ts_created timestamp without time zone, + ts_invalid timestamp without time zone, + datacount integer DEFAULT 0 NOT NULL +); +ALTER TABLE public.ftpuser OWNER TO gis; + +CREATE VIEW g6ftpusers AS + SELECT t1.domainid, t1.id, t1.name FROM dblink('hostaddr=210.77.68.240 port=5432 dbname=gene6ftp user=wlx password=gisgis'::text, 'select * from users'::text) t1(domainid integer, id integer, name character varying(64)); +ALTER TABLE public.g6ftpusers OWNER TO gis; + +CREATE VIEW g6ftpusersettings AS + SELECT t1.userid, t1.configname, t1.configvalue FROM dblink('hostaddr=210.77.68.240 port=5432 dbname=gene6ftp user=wlx password=gisgis'::text, 'select * from users_settings'::text) t1(userid integer, configname text, configvalue text); +ALTER TABLE public.g6ftpusersettings OWNER TO gis; + +CREATE VIEW geonetworkmetadata AS + SELECT t1.id, t1.uuid, t1.schemaid, t1.data, t1.source FROM dblink('host=localhost dbname=geonetwork user=gis password=gispassword'::text, 'select id,uuid,schemaid,data,source from metadata where istemplate=''n'''::text) t1(id integer, uuid uuid, schemaid text, data text, source text); +ALTER TABLE public.geonetworkmetadata OWNER TO gis; + +CREATE VIEW geonetworkusers AS + SELECT t1.id, t1.username, t1.password, t1.email FROM dblink('dbname=geonetwork user=gis password=gispassword'::text, 'select id,username,password,email from geonetworkusers'::text) t1(id integer, username text, password text, email text); +ALTER TABLE public.geonetworkusers OWNER TO gis; + +-- +-- knowledge lib system +-- +CREATE TABLE knl_article ( + id integer NOT NULL, + title text DEFAULT ''::text NOT NULL, + authors character varying(100)[], + publisher character varying(500), + ts_created timestamp without time zone DEFAULT now() NOT NULL, + item_id integer DEFAULT 0 NOT NULL, + url character varying(100), + keywords text[], + ts_issued character varying(100) +); +ALTER TABLE public.knl_article OWNER TO gis; +CREATE SEQUENCE knl_article_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.knl_article_id_seq OWNER TO gis; +ALTER SEQUENCE knl_article_id_seq OWNED BY knl_article.id; + +CREATE TABLE knl_author ( + id integer NOT NULL, + author text, + item_id integer, + place integer +); +ALTER TABLE public.knl_author OWNER TO gis; +CREATE SEQUENCE knl_author_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.knl_author_id_seq OWNER TO gis; +ALTER SEQUENCE knl_author_id_seq OWNED BY knl_author.id; + +CREATE VIEW knl_dcvalue AS + SELECT t1.dc_value_id, t1.item_id, t1.dc_type_id, t1.text_value, t1.text_lang, t1.place, t1.source_id FROM dblink('hostaddr=210.77.64.197 port=5432 dbname=seekspace user=seekspace password=seekspace90-='::text, 'select * from dcvalue'::text) t1(dc_value_id integer, item_id integer, dc_type_id integer, text_value text, text_lang character varying(24), place integer, source_id integer); +ALTER TABLE public.knl_dcvalue OWNER TO gis; + +CREATE TABLE knl_keyword ( + keyword text, + item_id integer, + place integer, + id integer NOT NULL +); +ALTER TABLE public.knl_keyword OWNER TO gis; + +CREATE SEQUENCE knl_keyword_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.knl_keyword_id_seq OWNER TO gis; +ALTER SEQUENCE knl_keyword_id_seq OWNED BY knl_keyword.id; + +-- +-- TOC entry 217 (class 1259 OID 87972) +-- Dependencies: 2901 6 +-- Name: mdexperts; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE mdexperts ( + id integer NOT NULL, + speciality text, + ts_created timestamp without time zone DEFAULT now() NOT NULL, + ts_modified timestamp without time zone +); +ALTER TABLE public.mdexperts OWNER TO gis; + +-- +-- TOC entry 175 (class 1259 OID 25458) +-- Dependencies: 6 +-- Name: mdlimit; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE mdlimit ( + id integer NOT NULL, + uuid uuid NOT NULL, + lid integer NOT NULL +); +ALTER TABLE public.mdlimit OWNER TO gis; +CREATE SEQUENCE mdlimit_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.mdlimit_id_seq OWNER TO gis; +ALTER SEQUENCE mdlimit_id_seq OWNED BY mdlimit.id; + +CREATE TABLE mdref ( + id integer NOT NULL, + uuid uuid NOT NULL, + refid integer NOT NULL +); +ALTER TABLE public.mdref OWNER TO gis; +CREATE SEQUENCE mdref_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.mdref_id_seq OWNER TO gis; +ALTER SEQUENCE mdref_id_seq OWNED BY mdref.id; + +CREATE TABLE mdstat ( + id integer NOT NULL, + uuid uuid NOT NULL, + viewed integer DEFAULT 0 NOT NULL, + downloaded integer DEFAULT 0 NOT NULL +); +ALTER TABLE public.mdstat OWNER TO gis; +CREATE SEQUENCE mdstat_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.mdstat_id_seq OWNER TO gis; +ALTER SEQUENCE mdstat_id_seq OWNED BY mdstat.id; + + +-- +-- metadata review system +-- + +CREATE TABLE mdstatus ( + id integer NOT NULL, + uuid uuid NOT NULL, + status integer DEFAULT 0 NOT NULL, + ts_created timestamp without time zone DEFAULT now() NOT NULL, + ts_accepted timestamp without time zone, + ts_finished timestamp without time zone, + userid integer NOT NULL, + ts_scheduled timestamp without time zone +); +ALTER TABLE public.mdstatus OWNER TO gis; +CREATE SEQUENCE mdstatus_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.mdstatus_id_seq OWNER TO gis; +ALTER SEQUENCE mdstatus_id_seq OWNED BY mdstatus.id; + +CREATE TABLE offlineapp ( + id integer NOT NULL, + userid integer, + username character varying(250), + unit character varying(500), + phone character varying(100), + address character varying(500), + postcode character varying(10), + project text, + pdflink character varying(200), + datalist text, + ts_created timestamp without time zone DEFAULT now() NOT NULL, + ts_approved timestamp without time zone, + email character varying(150), + status integer DEFAULT 0 NOT NULL +); +ALTER TABLE public.offlineapp OWNER TO gis; +CREATE SEQUENCE offlineapp_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.offlineapp_id_seq OWNER TO gis; +ALTER SEQUENCE offlineapp_id_seq OWNED BY offlineapp.id; + +CREATE TABLE onlineapp ( + id integer NOT NULL, + userid integer, + username character varying(250), + unit character varying(500), + phone character varying(100), + address character varying(500), + postcode character varying(10), + project text, + uuid uuid, + ts_created timestamp without time zone DEFAULT now() NOT NULL, + email character varying(150) +); +ALTER TABLE public.onlineapp OWNER TO gis; +CREATE SEQUENCE onlineapp_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.onlineapp_id_seq OWNER TO gis; +ALTER SEQUENCE onlineapp_id_seq OWNED BY onlineapp.id; + + +-- +-- TOC entry 187 (class 1259 OID 25509) +-- Dependencies: 6 156 +-- Name: order_id_seq; Type: SEQUENCE; Schema: public; Owner: gis +-- + +CREATE SEQUENCE order_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.order_id_seq OWNER TO gis; +ALTER SEQUENCE order_id_seq OWNED BY dataorder.id; + +CREATE VIEW proftpusers AS + SELECT t1.pkid, t1.userid, t1.passwd, t1.uid, t1.gid, t1.homedir FROM dblink('hostaddr=210.77.68.240 port=5432 dbname=ftp user=wlx password=gisgis'::text, 'select pkid,userid,passwd,uid,gid,homedir from ftp.users'::text) t1(pkid integer, userid character varying(64), passwd character varying(64), uid integer, gid integer, homedir character varying(64)); +ALTER TABLE public.proftpusers OWNER TO gis; + +CREATE TABLE reference ( + id integer NOT NULL, + reference text NOT NULL, + link text +); +ALTER TABLE public.reference OWNER TO gis; +CREATE SEQUENCE reference_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.reference_id_seq OWNER TO gis; +ALTER SEQUENCE reference_id_seq OWNED BY reference.id; + +CREATE TABLE responsible ( + id integer NOT NULL, + individual character varying(50), + organisation character varying(200), + "position" character varying(100), + delivery text, + email character varying(100), + postal character varying(20), + city character varying(100), + administrative character varying(100), + country character varying(100), + phone character varying(50) +); +ALTER TABLE public.responsible OWNER TO gis; +CREATE SEQUENCE responsible_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.responsible_id_seq OWNER TO gis; +ALTER SEQUENCE responsible_id_seq OWNED BY responsible.id; + +CREATE TABLE role ( + id integer NOT NULL, + uuid uuid NOT NULL, + resid integer NOT NULL, + role character varying(50) NOT NULL +); +ALTER TABLE public.role OWNER TO gis; +CREATE SEQUENCE role_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.role_id_seq OWNER TO gis; +ALTER SEQUENCE role_id_seq OWNED BY role.id; + +CREATE TABLE series ( + id integer NOT NULL, + name character varying(100) NOT NULL, + description text +); +ALTER TABLE public.series OWNER TO gis; +CREATE SEQUENCE series_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.series_id_seq OWNER TO gis; +ALTER SEQUENCE series_id_seq OWNED BY series.id; + +-- +-- TOC entry 141 (class 1259 OID 24828) +-- Dependencies: 6 +-- Name: spatial_ref_sys; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE spatial_ref_sys ( + srid integer NOT NULL, + auth_name character varying(256), + auth_srid integer, + srtext character varying(2048), + proj4text character varying(2048) +); + + +ALTER TABLE public.spatial_ref_sys OWNER TO gis; + +-- +-- TOC entry 197 (class 1259 OID 25544) +-- Dependencies: 6 +-- Name: thumbnail; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE thumbnail ( + id integer NOT NULL, + data text, + filetype character varying(100), + filename character varying(100), + filedesc character varying(200) +); +ALTER TABLE public.thumbnail OWNER TO gis; + +CREATE TABLE uselimit ( + id integer NOT NULL, + uselimit text NOT NULL +); +ALTER TABLE public.uselimit OWNER TO gis; +CREATE SEQUENCE uselimit_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.uselimit_id_seq OWNER TO gis; +ALTER SEQUENCE uselimit_id_seq OWNED BY uselimit.id; + + +-- +-- TOC entry 200 (class 1259 OID 25558) +-- Dependencies: 2890 2892 6 +-- Name: users; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE users ( + id integer NOT NULL, + username character varying(100) NOT NULL, + password character(32) NOT NULL, + usertype character varying(100) DEFAULT 'member'::character varying, + ts_created timestamp without time zone DEFAULT now() NOT NULL, + ts_last_login timestamp without time zone, + email character varying(100) NOT NULL, + realname character varying(100), + unit character varying(200), + address character varying(250), + project character varying(500), + phone character varying(100), + salt character varying(128), + activation character varying(30) +); +ALTER TABLE public.users OWNER TO gis; +CREATE SEQUENCE users_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.users_id_seq OWNER TO gis; +ALTER SEQUENCE users_id_seq OWNED BY users.id; + + +-- +-- + +CREATE VIEW watergn AS + SELECT t1.id, t1.uuid, t1.schemaid, t1.data, t1.source FROM dblink('host=210.77.68.252 dbname=new_geonetwork user=wlx password=gisgis'::text, 'select id,uuid,schemaid,data,source from metadata where istemplate=''n'''::text) t1(id integer, uuid uuid, schemaid text, data text, source text); +ALTER TABLE public.watergn OWNER TO gis; + +-- +-- + +CREATE TABLE westdc_dlstat ( + who character varying(128) NOT NULL, + uuid uuid, + "time" timestamp without time zone +); + +ALTER TABLE public.westdc_dlstat OWNER TO gis; + +CREATE TABLE westdc_fileinfo ( + id integer NOT NULL, + file_id character varying, + file_name character varying, + file_path character varying, + host character varying, + url character varying, + file_size double precision, + format character varying, + description character varying, + meta_title character varying, + create_date date, + modify_date date, + url_test boolean, + online boolean, + uuid_del character varying, + meta_uuid uuid NOT NULL, + depth integer NOT NULL, + isdir integer DEFAULT 0 NOT NULL +); +ALTER TABLE public.westdc_fileinfo OWNER TO gis; +CREATE SEQUENCE westdc_fileinfo_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.westdc_fileinfo_id_seq OWNER TO gis; +ALTER SEQUENCE westdc_fileinfo_id_seq OWNED BY westdc_fileinfo.id; + + +-- +-- TOC entry 206 (class 1259 OID 25583) +-- Dependencies: 6 +-- Name: westdc_offlineapp; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE westdc_offlineapp ( + id integer NOT NULL, + applicant character varying(50), + affliation character varying(500), + tel character varying(50), + email character varying(100), + "dataRequired" text, + "dateCreated" timestamp without time zone, + "docLink" character varying(1000), + addr character varying(500), + "projectName" character varying(800), + "appDate" timestamp without time zone +); + + +ALTER TABLE public.westdc_offlineapp OWNER TO gis; + +CREATE TABLE westdc_publishid ( + uuid uuid, + publishid uuid +); + + +ALTER TABLE public.westdc_publishid OWNER TO gis; + +-- +-- TOC entry 208 (class 1259 OID 25592) +-- Dependencies: 6 +-- Name: westee; Type: TABLE; Schema: public; Owner: gis; Tablespace: +-- + +CREATE TABLE westee ( + id integer NOT NULL, + title character varying(100) NOT NULL, + sponsor character varying(20) NOT NULL, + institute character varying(100) NOT NULL, + fund integer NOT NULL, + start timestamp without time zone NOT NULL, + "end" timestamp without time zone NOT NULL, + approveno character varying(10) NOT NULL, + applycode character varying(10) NOT NULL +); +ALTER TABLE public.westee OWNER TO gis; +CREATE SEQUENCE westee_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.westee_id_seq OWNER TO gis; +ALTER SEQUENCE westee_id_seq OWNED BY westee.id; + +CREATE TABLE westeemd ( + id integer NOT NULL, + uuid uuid NOT NULL, + eeid integer NOT NULL +); +ALTER TABLE public.westeemd OWNER TO gis; +CREATE SEQUENCE westeemd_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; +ALTER TABLE public.westeemd_id_seq OWNER TO gis; +ALTER SEQUENCE westeemd_id_seq OWNED BY westeemd.id; + +CREATE TABLE xml ( + id integer NOT NULL, + data pg_catalog.xml NOT NULL +); +ALTER TABLE public.xml OWNER TO gis; + +ALTER TABLE comments ALTER COLUMN id SET DEFAULT nextval('comments_id_seq'::regclass); +ALTER TABLE datafeature ALTER COLUMN id SET DEFAULT nextval('datafeature_id_seq'::regclass); +ALTER TABLE datafile ALTER COLUMN id SET DEFAULT nextval('datafile_id_seq'::regclass); +ALTER TABLE dataorder ALTER COLUMN id SET DEFAULT nextval('order_id_seq'::regclass); +ALTER TABLE dataset ALTER COLUMN id SET DEFAULT nextval('dataset_id_seq'::regclass); +ALTER TABLE datasetcd ALTER COLUMN id SET DEFAULT nextval('datasetcd_id_seq'::regclass); +ALTER TABLE emailtext ALTER COLUMN id SET DEFAULT nextval('emailtext_id_seq'::regclass); +ALTER TABLE knl_article ALTER COLUMN id SET DEFAULT nextval('knl_article_id_seq'::regclass); +ALTER TABLE knl_author ALTER COLUMN id SET DEFAULT nextval('knl_author_id_seq'::regclass); +ALTER TABLE knl_keyword ALTER COLUMN id SET DEFAULT nextval('knl_keyword_id_seq'::regclass); +ALTER TABLE mdlimit ALTER COLUMN id SET DEFAULT nextval('mdlimit_id_seq'::regclass); +ALTER TABLE mdref ALTER COLUMN id SET DEFAULT nextval('mdref_id_seq'::regclass); +ALTER TABLE mdstat ALTER COLUMN id SET DEFAULT nextval('mdstat_id_seq'::regclass); +ALTER TABLE mdstatus ALTER COLUMN id SET DEFAULT nextval('mdstatus_id_seq'::regclass); +ALTER TABLE metadata ALTER COLUMN id SET DEFAULT nextval('metadata_id_seq'::regclass); +ALTER TABLE offlineapp ALTER COLUMN id SET DEFAULT nextval('offlineapp_id_seq'::regclass); +ALTER TABLE onlineapp ALTER COLUMN id SET DEFAULT nextval('onlineapp_id_seq'::regclass); +ALTER TABLE onlineresource ALTER COLUMN id SET DEFAULT nextval('onlinesource_id_seq'::regclass); +ALTER TABLE reference ALTER COLUMN id SET DEFAULT nextval('reference_id_seq'::regclass); +ALTER TABLE responsible ALTER COLUMN id SET DEFAULT nextval('responsible_id_seq'::regclass); +ALTER TABLE role ALTER COLUMN id SET DEFAULT nextval('role_id_seq'::regclass); +ALTER TABLE series ALTER COLUMN id SET DEFAULT nextval('series_id_seq'::regclass); +ALTER TABLE uselimit ALTER COLUMN id SET DEFAULT nextval('uselimit_id_seq'::regclass); +ALTER TABLE users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass); +ALTER TABLE westdc_fileinfo ALTER COLUMN id SET DEFAULT nextval('westdc_fileinfo_id_seq'::regclass); +ALTER TABLE westee ALTER COLUMN id SET DEFAULT nextval('westee_id_seq'::regclass); +ALTER TABLE westeemd ALTER COLUMN id SET DEFAULT nextval('westeemd_id_seq'::regclass); + +ALTER TABLE ONLY aspnet_membership + ADD CONSTRAINT aspnet_membership_pkey PRIMARY KEY ("UserId"); +ALTER TABLE ONLY aspnet_profile + ADD CONSTRAINT aspnet_profile_pkey PRIMARY KEY ("UserId"); +ALTER TABLE ONLY aspnet_users + ADD CONSTRAINT aspnet_users_pkey PRIMARY KEY ("UserId"); +ALTER TABLE ONLY category + ADD CONSTRAINT category_code_key UNIQUE (code, id); +ALTER TABLE ONLY category + ADD CONSTRAINT category_pkey PRIMARY KEY (id, code); +ALTER TABLE ONLY categorycode + ADD CONSTRAINT categorycode_pkey PRIMARY KEY (code); +ALTER TABLE ONLY comments + ADD CONSTRAINT comments_pkey PRIMARY KEY (id); +ALTER TABLE ONLY comments + ADD CONSTRAINT comments_userid_key UNIQUE (userid, uuid, content); +ALTER TABLE ONLY datafeature + ADD CONSTRAINT datafeature_pkey PRIMARY KEY (id); +ALTER TABLE ONLY datafeature + ADD CONSTRAINT datafeature_title_key UNIQUE (title); +ALTER TABLE ONLY datafile + ADD CONSTRAINT datafile_pkey PRIMARY KEY (id); +ALTER TABLE ONLY dataseries + ADD CONSTRAINT dataseries_id_key UNIQUE (id, sid); +ALTER TABLE ONLY dataseries + ADD CONSTRAINT dataseries_pkey PRIMARY KEY (id, sid); +ALTER TABLE ONLY dataset + ADD CONSTRAINT dataset_pkey PRIMARY KEY (id); +ALTER TABLE ONLY dataset + ADD CONSTRAINT dataset_uuid_key UNIQUE (uuid); +ALTER TABLE ONLY datasetcd + ADD CONSTRAINT datasetcd_pkey PRIMARY KEY (id); +ALTER TABLE ONLY datasetcd + ADD CONSTRAINT datasetcd_title_key UNIQUE (title); +ALTER TABLE ONLY emailtext + ADD CONSTRAINT emailtext_pkey PRIMARY KEY (id); +ALTER TABLE ONLY emailtext + ADD CONSTRAINT emailtext_template_key UNIQUE (template); +ALTER TABLE ONLY ftpuser + ADD CONSTRAINT ftpuser_pkey PRIMARY KEY (userid); +ALTER TABLE ONLY geometry_columns + ADD CONSTRAINT geometry_columns_pk PRIMARY KEY (f_table_catalog, f_table_schema, f_table_name, f_geometry_column); +ALTER TABLE ONLY keyword + ADD CONSTRAINT keyword_id_key UNIQUE (id, keyword); +ALTER TABLE ONLY keyword + ADD CONSTRAINT keyword_pkey PRIMARY KEY (id, keyword); +ALTER TABLE ONLY knl_article + ADD CONSTRAINT knl_article_pkey PRIMARY KEY (id); +ALTER TABLE ONLY knl_author + ADD CONSTRAINT knl_author_pkey PRIMARY KEY (id); +ALTER TABLE ONLY knl_keyword + ADD CONSTRAINT knl_keyword_pkey PRIMARY KEY (id); +ALTER TABLE ONLY mdexperts + ADD CONSTRAINT mdexperts_pkey PRIMARY KEY (id); +ALTER TABLE ONLY mdlimit + ADD CONSTRAINT mdlimit_pkey PRIMARY KEY (id); +ALTER TABLE ONLY mdlimit + ADD CONSTRAINT mdlimit_uuid_key UNIQUE (uuid, lid); +ALTER TABLE ONLY mdref + ADD CONSTRAINT mdref_pkey PRIMARY KEY (id); +ALTER TABLE ONLY mdref + ADD CONSTRAINT mdref_uuid_key UNIQUE (uuid, refid); +ALTER TABLE ONLY mdstat + ADD CONSTRAINT mdstat_pkey PRIMARY KEY (id); +ALTER TABLE ONLY mdstat + ADD CONSTRAINT mdstat_uuid_key UNIQUE (uuid); +ALTER TABLE ONLY mdstatus + ADD CONSTRAINT mdstatus_pkey PRIMARY KEY (id); +ALTER TABLE ONLY mdstatus + ADD CONSTRAINT mdstatus_uuid_key UNIQUE (uuid); +ALTER TABLE ONLY metadata + ADD CONSTRAINT metadata_pkey PRIMARY KEY (id); +ALTER TABLE ONLY metadata + ADD CONSTRAINT metadata_uuid_key UNIQUE (uuid); +ALTER TABLE ONLY offlineapp + ADD CONSTRAINT offlineapp_pkey PRIMARY KEY (id); +ALTER TABLE ONLY onlineapp + ADD CONSTRAINT onlineapp_pkey PRIMARY KEY (id); +ALTER TABLE ONLY onlineresource + ADD CONSTRAINT onlinesource_pkey PRIMARY KEY (id); +ALTER TABLE ONLY dataorder + ADD CONSTRAINT order_pkey PRIMARY KEY (id); +ALTER TABLE ONLY reference + ADD CONSTRAINT reference_pkey PRIMARY KEY (id); +ALTER TABLE ONLY reference + ADD CONSTRAINT reference_reference_key UNIQUE (reference); +ALTER TABLE ONLY responsible + ADD CONSTRAINT responsible_individual_key UNIQUE (individual, organisation); +ALTER TABLE ONLY responsible + ADD CONSTRAINT responsible_pkey PRIMARY KEY (id); +ALTER TABLE ONLY role + ADD CONSTRAINT role_pkey PRIMARY KEY (id); +ALTER TABLE ONLY role + ADD CONSTRAINT role_uuid_key UNIQUE (uuid, resid, role); +ALTER TABLE ONLY series + ADD CONSTRAINT series_name_key UNIQUE (name); +ALTER TABLE ONLY series + ADD CONSTRAINT series_pkey PRIMARY KEY (id); +ALTER TABLE ONLY spatial_ref_sys + ADD CONSTRAINT spatial_ref_sys_pkey PRIMARY KEY (srid); +ALTER TABLE ONLY thumbnail + ADD CONSTRAINT thumbnail_id_key UNIQUE (id); +ALTER TABLE ONLY thumbnail + ADD CONSTRAINT thumbnail_pkey PRIMARY KEY (id); +ALTER TABLE ONLY uselimit + ADD CONSTRAINT uselimit_limit_key UNIQUE (uselimit); +ALTER TABLE ONLY uselimit + ADD CONSTRAINT uselimit_pkey PRIMARY KEY (id); +ALTER TABLE ONLY users + ADD CONSTRAINT users_email_key UNIQUE (email); +ALTER TABLE ONLY users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); +ALTER TABLE ONLY users + ADD CONSTRAINT users_username_key UNIQUE (username); +ALTER TABLE ONLY westdc_dlstat + ADD CONSTRAINT westdc_dlstat_who_key UNIQUE (who, uuid, "time"); +ALTER TABLE ONLY westdc_fileinfo + ADD CONSTRAINT westdc_fileinfo_id_key UNIQUE (id); +ALTER TABLE ONLY westdc_fileinfo + ADD CONSTRAINT westdc_fileinfo_pkey PRIMARY KEY (id); +ALTER TABLE ONLY westdc_offlineapp + ADD CONSTRAINT westdc_offlineapp_pkey PRIMARY KEY (id); +ALTER TABLE ONLY westee + ADD CONSTRAINT westee_pkey PRIMARY KEY (id); +ALTER TABLE ONLY westeemd + ADD CONSTRAINT westeemd_pkey PRIMARY KEY (id); +ALTER TABLE ONLY westeemd + ADD CONSTRAINT westeemd_uuid_key UNIQUE (uuid, eeid); +ALTER TABLE ONLY xml + ADD CONSTRAINT xml_id_key UNIQUE (id); +ALTER TABLE ONLY xml + ADD CONSTRAINT xml_pkey PRIMARY KEY (id); + +CREATE RULE insert_ftpusersettings AS ON INSERT TO g6ftpusersettings DO INSTEAD SELECT dblink_exec('hostaddr=210.77.68.240 dbname=gene6ftp user=wlx password=gisgis'::text, dblink_current_query()) AS dblink_exec; +CREATE RULE insert_g6ftpusers AS ON INSERT TO g6ftpusers DO INSTEAD SELECT dblink_exec('hostaddr=210.77.68.240 dbname=gene6ftp user=wlx password=gisgis'::text, dblink_current_query()) AS dblink_exec; +CREATE RULE insert_gnusers AS ON INSERT TO geonetworkusers DO INSTEAD SELECT dblink_exec('dbname=geonetwork user=gis password=gispassword'::text, dblink_current_query()) AS dblink_exec; +CREATE RULE insert_offlineapp_users AS ON INSERT TO offlineapp WHERE (new.userid > 0) DO UPDATE users SET realname = new.username, unit = new.unit, address = new.address, project = new.project, phone = new.phone, email = new.email WHERE (users.id = new.userid); +CREATE RULE insert_onlineapp_users AS ON INSERT TO onlineapp WHERE (new.userid > 0) DO UPDATE users SET realname = new.username, unit = new.unit, address = new.address, project = new.project, phone = new.phone, email = new.email WHERE (users.id = new.userid); +CREATE RULE insert_proftpusers AS ON INSERT TO proftpusers DO INSTEAD SELECT dblink_exec('hostaddr=210.77.68.240 dbname=ftp user=wlx password=gisgis'::text, dblink_current_query()) AS dblink_exec; + +CREATE RULE update_ftpusersettings AS ON UPDATE TO g6ftpusersettings DO INSTEAD SELECT dblink_exec('hostaddr=210.77.68.240 dbname=gene6ftp user=wlx password=gisgis'::text, dblink_current_query()) AS dblink_exec; +CREATE RULE update_gnusers AS ON UPDATE TO geonetworkusers DO INSTEAD SELECT dblink_exec('dbname=geonetwork user=gis password=gispassword'::text, dblink_current_query()) AS dblink_exec; +CREATE RULE update_offlineapp_users AS ON UPDATE TO offlineapp WHERE (old.userid > 0) DO UPDATE users SET realname = new.username, unit = new.unit, address = new.address, project = new.project, phone = new.phone, email = new.email WHERE (users.id = old.userid); +CREATE RULE update_onlineapp_users AS ON UPDATE TO onlineapp WHERE (old.userid > 0) DO UPDATE users SET realname = new.username, unit = new.unit, address = new.address, project = new.project, phone = new.phone, email = new.email WHERE (users.id = old.userid); +CREATE RULE update_proftpusers AS ON UPDATE TO proftpusers DO INSTEAD SELECT dblink_exec('hostaddr=210.77.68.240 dbname=ftp user=wlx password=gisgis'::text, dblink_current_query()) AS dblink_exec; +CREATE RULE update_watergn AS ON UPDATE TO watergn DO INSTEAD SELECT dblink_exec('hostaddr=210.77.68.252 dbname=new_geonetwork user=wlx password=gisgis'::text, dblink_current_query()) AS dblink_exec; + +ALTER TABLE ONLY category + ADD CONSTRAINT category_code_fkey FOREIGN KEY (code) REFERENCES categorycode(code); +ALTER TABLE ONLY category + ADD CONSTRAINT category_id_fkey FOREIGN KEY (id) REFERENCES metadata(id) ON DELETE CASCADE; +ALTER TABLE ONLY datafile + ADD CONSTRAINT datafile_dsid_fkey FOREIGN KEY (dsid) REFERENCES dataset(id) ON DELETE CASCADE; +ALTER TABLE ONLY dataorder + ADD CONSTRAINT dataorder_userid_fkey FOREIGN KEY (userid) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY dataseries + ADD CONSTRAINT dataseries_id_fkey FOREIGN KEY (id) REFERENCES metadata(id) ON DELETE CASCADE; +ALTER TABLE ONLY dataseries + ADD CONSTRAINT dataseries_sid_fkey FOREIGN KEY (sid) REFERENCES series(id) ON DELETE CASCADE; +ALTER TABLE ONLY ftpuser + ADD CONSTRAINT ftpuser_userid_fkey FOREIGN KEY (userid) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY keyword + ADD CONSTRAINT keyword_id_fkey FOREIGN KEY (id) REFERENCES metadata(id) ON DELETE CASCADE; +ALTER TABLE ONLY mdexperts + ADD CONSTRAINT mdexperts_id_fkey FOREIGN KEY (id) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY mdlimit + ADD CONSTRAINT mdlimit_uuid_fkey FOREIGN KEY (uuid) REFERENCES metadata(uuid) ON DELETE CASCADE; +ALTER TABLE ONLY mdref + ADD CONSTRAINT mdref_refid_fkey FOREIGN KEY (refid) REFERENCES reference(id) ON DELETE CASCADE; +ALTER TABLE ONLY mdstatus + ADD CONSTRAINT mdstatus_userid_fkey FOREIGN KEY (userid) REFERENCES users(id) ON DELETE CASCADE; +ALTER TABLE ONLY onlineresource + ADD CONSTRAINT onlinesource_uuid_fkey FOREIGN KEY (uuid) REFERENCES metadata(uuid) ON DELETE CASCADE; +ALTER TABLE ONLY role + ADD CONSTRAINT role_resid_fkey FOREIGN KEY (resid) REFERENCES responsible(id) ON DELETE CASCADE; +ALTER TABLE ONLY role + ADD CONSTRAINT role_uuid_fkey FOREIGN KEY (uuid) REFERENCES metadata(uuid) ON DELETE CASCADE; +ALTER TABLE ONLY thumbnail + ADD CONSTRAINT thumbnail_id_fkey FOREIGN KEY (id) REFERENCES metadata(id) ON DELETE CASCADE; +ALTER TABLE ONLY westeemd + ADD CONSTRAINT westeemd_eeid_fkey FOREIGN KEY (eeid) REFERENCES westee(id) ON DELETE CASCADE; +ALTER TABLE ONLY xml + ADD CONSTRAINT xml_id_fkey FOREIGN KEY (id) REFERENCES metadata(id) ON DELETE CASCADE; + +REVOKE ALL ON SCHEMA public FROM PUBLIC; +REVOKE ALL ON SCHEMA public FROM postgres; +GRANT ALL ON SCHEMA public TO postgres; +GRANT ALL ON SCHEMA public TO PUBLIC; + +REVOKE ALL ON TABLE geonetworkusers FROM PUBLIC; +REVOKE ALL ON TABLE geonetworkusers FROM gis; +GRANT ALL ON TABLE geonetworkusers TO gis; +GRANT ALL ON TABLE geonetworkusers TO PUBLIC; + +REVOKE ALL ON TABLE spatial_ref_sys FROM PUBLIC; +REVOKE ALL ON TABLE spatial_ref_sys FROM gis; +GRANT ALL ON TABLE spatial_ref_sys TO gis; +GRANT ALL ON TABLE spatial_ref_sys TO postgres; +GRANT ALL ON TABLE spatial_ref_sys TO PUBLIC; + +-- Completed on 2011-10-23 11:37:59 CST