schema.sql 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. begin transaction;
  2. --
  3. -- PostgreSQL database dump
  4. --
  5. SET statement_timeout = 0;
  6. SET client_encoding = 'UTF8';
  7. SET standard_conforming_strings = on;
  8. SET check_function_bodies = false;
  9. SET client_min_messages = warning;
  10. --
  11. -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
  12. --
  13. --CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
  14. --
  15. -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
  16. --
  17. --COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
  18. --
  19. -- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
  20. --
  21. --CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
  22. --
  23. -- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
  24. --
  25. --COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
  26. SET search_path = public, pg_catalog;
  27. SET default_tablespace = '';
  28. SET default_with_oids = false;
  29. --
  30. -- Name: channel; Type: TABLE; Schema: public; Owner: -; Tablespace:
  31. --
  32. CREATE TABLE channel (
  33. id integer NOT NULL,
  34. title character varying(28) NOT NULL
  35. );
  36. --
  37. -- Name: channel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  38. --
  39. CREATE SEQUENCE channel_id_seq
  40. START WITH 1
  41. INCREMENT BY 1
  42. NO MINVALUE
  43. NO MAXVALUE
  44. CACHE 1;
  45. --
  46. -- Name: channel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  47. --
  48. ALTER SEQUENCE channel_id_seq OWNED BY channel.id;
  49. --
  50. -- Name: hint; Type: TABLE; Schema: public; Owner: -; Tablespace:
  51. --
  52. CREATE TABLE hint (
  53. id integer NOT NULL,
  54. paste bigint,
  55. type text NOT NULL,
  56. content text NOT NULL
  57. );
  58. --
  59. -- Name: hint_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  60. --
  61. CREATE SEQUENCE hint_id_seq
  62. START WITH 1
  63. INCREMENT BY 1
  64. NO MINVALUE
  65. NO MAXVALUE
  66. CACHE 1;
  67. --
  68. -- Name: hint_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  69. --
  70. ALTER SEQUENCE hint_id_seq OWNED BY hint.id;
  71. --
  72. -- Name: language; Type: TABLE; Schema: public; Owner: -; Tablespace:
  73. --
  74. CREATE TABLE language (
  75. id integer NOT NULL,
  76. name character varying(32) NOT NULL,
  77. title character varying(64) NOT NULL,
  78. ordinal integer DEFAULT 0 NOT NULL,
  79. visible boolean DEFAULT false NOT NULL
  80. );
  81. --
  82. -- Name: language_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  83. --
  84. CREATE SEQUENCE language_id_seq
  85. START WITH 1
  86. INCREMENT BY 1
  87. NO MINVALUE
  88. NO MAXVALUE
  89. CACHE 1;
  90. --
  91. -- Name: language_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  92. --
  93. ALTER SEQUENCE language_id_seq OWNED BY language.id;
  94. --
  95. -- Name: paste; Type: TABLE; Schema: public; Owner: -; Tablespace:
  96. --
  97. CREATE TABLE paste (
  98. id bigint NOT NULL,
  99. title character varying(512) NOT NULL,
  100. content text NOT NULL,
  101. tags text,
  102. author character varying(128) NOT NULL,
  103. created timestamp with time zone DEFAULT now() NOT NULL,
  104. views integer DEFAULT 0 NOT NULL,
  105. language integer,
  106. channel integer,
  107. annotation_of bigint,
  108. expire timestamp with time zone,
  109. output text,
  110. public boolean DEFAULT true,
  111. revision_of bigint,
  112. spamrating integer DEFAULT 0
  113. );
  114. --
  115. -- Name: paste_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  116. --
  117. CREATE SEQUENCE paste_id_seq
  118. START WITH 1
  119. INCREMENT BY 1
  120. NO MINVALUE
  121. NO MAXVALUE
  122. CACHE 1;
  123. --
  124. -- Name: paste_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  125. --
  126. ALTER SEQUENCE paste_id_seq OWNED BY paste.id;
  127. --
  128. -- Name: report; Type: TABLE; Schema: public; Owner: -; Tablespace:
  129. --
  130. CREATE TABLE report (
  131. id bigint NOT NULL,
  132. paste bigint NOT NULL,
  133. comments text NOT NULL,
  134. created timestamp with time zone DEFAULT now() NOT NULL
  135. );
  136. --
  137. -- Name: private_paste; Type: VIEW; Schema: public; Owner: -
  138. --
  139. CREATE VIEW private_paste AS
  140. SELECT paste.id, paste.title, paste.content, paste.author, paste.created, paste.views, paste.language, paste.channel, paste.annotation_of, paste.revision_of FROM paste WHERE (paste.id IN (SELECT report.paste FROM report));
  141. --
  142. -- Name: public_paste; Type: VIEW; Schema: public; Owner: -
  143. --
  144. CREATE VIEW public_paste AS
  145. SELECT paste.id, paste.title, paste.content, paste.author, paste.created, paste.views, paste.language, paste.channel, paste.annotation_of, paste.revision_of, paste.spamrating, paste.public FROM paste WHERE (NOT (paste.id IN (SELECT report.paste FROM report)));
  146. --
  147. -- Name: public_toplevel_paste; Type: VIEW; Schema: public; Owner: -
  148. --
  149. CREATE VIEW public_toplevel_paste AS
  150. SELECT public_paste.id, public_paste.title, public_paste.content, public_paste.author, public_paste.created, public_paste.views, public_paste.language, public_paste.channel, public_paste.annotation_of, public_paste.revision_of, public_paste.spamrating FROM public_paste WHERE (((public_paste.annotation_of IS NULL) AND (public_paste.revision_of IS NULL)) AND public_paste.public);
  151. --
  152. -- Name: report_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  153. --
  154. CREATE SEQUENCE report_id_seq
  155. START WITH 1
  156. INCREMENT BY 1
  157. NO MINVALUE
  158. NO MAXVALUE
  159. CACHE 1;
  160. --
  161. -- Name: report_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  162. --
  163. ALTER SEQUENCE report_id_seq OWNED BY report.id;
  164. --
  165. -- Name: step; Type: TABLE; Schema: public; Owner: -; Tablespace:
  166. --
  167. CREATE TABLE step (
  168. paste integer NOT NULL,
  169. step integer NOT NULL,
  170. content text NOT NULL
  171. );
  172. --
  173. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  174. --
  175. ALTER TABLE ONLY channel ALTER COLUMN id SET DEFAULT nextval('channel_id_seq'::regclass);
  176. --
  177. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  178. --
  179. ALTER TABLE ONLY hint ALTER COLUMN id SET DEFAULT nextval('hint_id_seq'::regclass);
  180. --
  181. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  182. --
  183. ALTER TABLE ONLY language ALTER COLUMN id SET DEFAULT nextval('language_id_seq'::regclass);
  184. --
  185. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  186. --
  187. ALTER TABLE ONLY paste ALTER COLUMN id SET DEFAULT nextval('paste_id_seq'::regclass);
  188. --
  189. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  190. --
  191. ALTER TABLE ONLY report ALTER COLUMN id SET DEFAULT nextval('report_id_seq'::regclass);
  192. --
  193. -- Name: channel_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  194. --
  195. ALTER TABLE ONLY channel
  196. ADD CONSTRAINT channel_pkey PRIMARY KEY (id);
  197. --
  198. -- Name: hint_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  199. --
  200. ALTER TABLE ONLY hint
  201. ADD CONSTRAINT hint_pkey PRIMARY KEY (id);
  202. --
  203. -- Name: language_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  204. --
  205. ALTER TABLE ONLY language
  206. ADD CONSTRAINT language_pkey PRIMARY KEY (id);
  207. --
  208. -- Name: paste_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  209. --
  210. ALTER TABLE ONLY paste
  211. ADD CONSTRAINT paste_pkey PRIMARY KEY (id);
  212. --
  213. -- Name: report_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  214. --
  215. ALTER TABLE ONLY report
  216. ADD CONSTRAINT report_pkey PRIMARY KEY (id);
  217. --
  218. -- Name: paste_author_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
  219. --
  220. CREATE INDEX paste_author_index ON paste USING btree (author);
  221. --
  222. -- Name: paste_date_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
  223. --
  224. CREATE INDEX paste_date_index ON paste USING btree (created);
  225. --
  226. -- Name: paste_title_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
  227. --
  228. CREATE INDEX paste_title_index ON paste USING btree (title);
  229. --
  230. -- Name: hint_paste_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
  231. --
  232. ALTER TABLE ONLY hint
  233. ADD CONSTRAINT hint_paste_fkey FOREIGN KEY (paste) REFERENCES paste(id) ON UPDATE CASCADE ON DELETE CASCADE;
  234. --
  235. -- Name: paste_channel_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
  236. --
  237. ALTER TABLE ONLY paste
  238. ADD CONSTRAINT paste_channel_fkey FOREIGN KEY (channel) REFERENCES channel(id);
  239. --
  240. -- Name: paste_language_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
  241. --
  242. ALTER TABLE ONLY paste
  243. ADD CONSTRAINT paste_language_fkey FOREIGN KEY (language) REFERENCES language(id);
  244. --
  245. -- Name: paste_revision_of_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
  246. --
  247. ALTER TABLE ONLY paste
  248. ADD CONSTRAINT paste_revision_of_fkey FOREIGN KEY (revision_of) REFERENCES paste(id) ON DELETE CASCADE;
  249. --
  250. -- Name: report_paste_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
  251. --
  252. ALTER TABLE ONLY report
  253. ADD CONSTRAINT report_paste_fkey FOREIGN KEY (paste) REFERENCES paste(id) ON UPDATE CASCADE ON DELETE CASCADE;
  254. --
  255. -- Name: step_paste_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
  256. --
  257. ALTER TABLE ONLY step
  258. ADD CONSTRAINT step_paste_fkey FOREIGN KEY (paste) REFERENCES paste(id);
  259. --
  260. -- Name: public; Type: ACL; Schema: -; Owner: -
  261. --
  262. --REVOKE ALL ON SCHEMA public FROM PUBLIC;
  263. --REVOKE ALL ON SCHEMA public FROM postgres;
  264. --GRANT ALL ON SCHEMA public TO postgres;
  265. --GRANT ALL ON SCHEMA public TO PUBLIC;
  266. --
  267. -- PostgreSQL database dump complete
  268. --
  269. commit;