[or-cvs] [metrics-db/master 2/2] Clean up the auto-generated tordir.sql a bit.

karsten at torproject.org karsten at torproject.org
Sat Sep 4 08:37:57 UTC 2010


Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Sat, 4 Sep 2010 10:28:04 +0200
Subject: Clean up the auto-generated tordir.sql a bit.
Commit: 9e4de43417c81faa9980d41627adc70acfcfdbbd

Remove PostgreSQL's settings which initially came from the schema export.
We should only change a default if there's a good reason to so. If we
find such a reason, we should put them back and add a comment why we think
we need them.

Put SQL keywords in all caps and remove auto-generated comments.

Remove auto-generated GRANT and REVOKE statements as well as indexes which
are generated from the primary key constraints anyway.
---
 db/tordir.sql |  127 +++++++++++++--------------------------------------------
 1 files changed, 28 insertions(+), 99 deletions(-)

diff --git a/db/tordir.sql b/db/tordir.sql
index c9522ed..97c12d8 100644
--- a/db/tordir.sql
+++ b/db/tordir.sql
@@ -1,105 +1,34 @@
---
--- PostgreSQL database dump
---
-
-SET client_encoding = 'UTF8';
-SET standard_conforming_strings = off;
-SET check_function_bodies = false;
-SET client_min_messages = warning;
-SET escape_string_warning = off;
-
-SET search_path = public, pg_catalog;
-
-SET default_tablespace = '';
-
-SET default_with_oids = false;
-
---
--- Name: descriptor; Type: TABLE; Schema: public; Owner: ernie; Tablespace: 
---
-
 CREATE TABLE descriptor (
-    descriptor character(40) NOT NULL,
-    address character varying(15) NOT NULL,
-    orport integer NOT NULL,
-    dirport integer NOT NULL,
-    bandwidthavg bigint NOT NULL,
-    bandwidthburst bigint NOT NULL,
-    bandwidthobserved bigint NOT NULL,
-    platform character varying(256),
-    published timestamp without time zone NOT NULL,
-    uptime bigint
+    descriptor CHARACTER(40) NOT NULL,
+    address CHARACTER VARYING(15) NOT NULL,
+    orport INTEGER NOT NULL,
+    dirport INTEGER NOT NULL,
+    bandwidthavg BIGINT NOT NULL,
+    bandwidthburst BIGINT NOT NULL,
+    bandwidthobserved BIGINT NOT NULL,
+    platform CHARACTER VARYING(256),
+    published TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+    uptime BIGINT,
+    CONSTRAINT descriptor_pkey PRIMARY KEY (descriptor)
 );
 
-
-ALTER TABLE public.descriptor OWNER TO ernie;
-
---
--- Name: statusentry; Type: TABLE; Schema: public; Owner: ernie; Tablespace: 
---
-
 CREATE TABLE statusentry (
-    validafter timestamp without time zone NOT NULL,
-    descriptor character(40) NOT NULL,
-    isauthority boolean DEFAULT false NOT NULL,
-    isbadexit boolean DEFAULT false NOT NULL,
-    isbaddirectory boolean DEFAULT false NOT NULL,
-    isexit boolean DEFAULT false NOT NULL,
-    isfast boolean DEFAULT false NOT NULL,
-    isguard boolean DEFAULT false NOT NULL,
-    ishsdir boolean DEFAULT false NOT NULL,
-    isnamed boolean DEFAULT false NOT NULL,
-    isstable boolean DEFAULT false NOT NULL,
-    isrunning boolean DEFAULT false NOT NULL,
-    isunnamed boolean DEFAULT false NOT NULL,
-    isvalid boolean DEFAULT false NOT NULL,
-    isv2dir boolean DEFAULT false NOT NULL,
-    isv3dir boolean DEFAULT false NOT NULL
+    validafter TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+    descriptor CHARACTER(40) NOT NULL,
+    isauthority BOOLEAN DEFAULT FALSE NOT NULL,
+    isbadexit BOOLEAN DEFAULT FALSE NOT NULL,
+    isbaddirectory BOOLEAN DEFAULT FALSE NOT NULL,
+    isexit BOOLEAN DEFAULT FALSE NOT NULL,
+    isfast BOOLEAN DEFAULT FALSE NOT NULL,
+    isguard BOOLEAN DEFAULT FALSE NOT NULL,
+    ishsdir BOOLEAN DEFAULT FALSE NOT NULL,
+    isnamed BOOLEAN DEFAULT FALSE NOT NULL,
+    isstable BOOLEAN DEFAULT FALSE NOT NULL,
+    isrunning BOOLEAN DEFAULT FALSE NOT NULL,
+    isunnamed BOOLEAN DEFAULT FALSE NOT NULL,
+    isvalid BOOLEAN DEFAULT FALSE NOT NULL,
+    isv2dir BOOLEAN DEFAULT FALSE NOT NULL,
+    isv3dir BOOLEAN DEFAULT FALSE NOT NULL,
+    CONSTRAINT statusentry_pkey PRIMARY KEY (validafter, descriptor)
 );
 
-
-ALTER TABLE public.statusentry OWNER TO ernie;
-
---
--- Name: descriptor_pkey; Type: CONSTRAINT; Schema: public; Owner: ernie; Tablespace: 
---
-
-ALTER TABLE ONLY descriptor
-    ADD CONSTRAINT descriptor_pkey PRIMARY KEY (descriptor);
-
-
---
--- Name: statusentry_pkey; Type: CONSTRAINT; Schema: public; Owner: ernie; Tablespace: 
---
-
-ALTER TABLE ONLY statusentry
-    ADD CONSTRAINT statusentry_pkey PRIMARY KEY (validafter, descriptor);
-
-
---
--- Name: descriptorid; Type: INDEX; Schema: public; Owner: ernie; Tablespace: 
---
-
-CREATE INDEX descriptorid ON descriptor USING btree (descriptor);
-
-
---
--- Name: statusvalidafter; Type: INDEX; Schema: public; Owner: ernie; Tablespace: 
---
-
-CREATE INDEX statusvalidafter ON statusentry USING btree (validafter);
-
-
---
--- Name: public; Type: ACL; Schema: -; Owner: postgres
---
-
-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;
-
-
---
--- PostgreSQL database dump complete
---
\ No newline at end of file
-- 
1.7.1



More information about the tor-commits mailing list