pod-schema-2013.11.15-15.54.45.sql 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. --
  2. -- PostgreSQL database dump
  3. --
  4. SET statement_timeout = 0;
  5. SET client_encoding = 'UTF8';
  6. SET standard_conforming_strings = on;
  7. SET check_function_bodies = false;
  8. SET client_min_messages = warning;
  9. CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
  10. COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
  11. SET search_path = public, pg_catalog;
  12. CREATE FUNCTION set_created_at() RETURNS trigger
  13. LANGUAGE plpgsql
  14. AS $$
  15. BEGIN
  16. NEW.created_at = CURRENT_TIMESTAMP;
  17. NEW.updated_at = CURRENT_TIMESTAMP;
  18. RETURN NEW;
  19. END;
  20. $$;
  21. ALTER FUNCTION public.set_created_at() OWNER TO pod_master;
  22. CREATE FUNCTION set_updated_at() RETURNS trigger
  23. LANGUAGE plpgsql
  24. AS $$
  25. BEGIN
  26. NEW.updated_at = CURRENT_TIMESTAMP;
  27. RETURN NEW;
  28. END;
  29. $$;
  30. ALTER FUNCTION public.set_updated_at() OWNER TO pod_master;
  31. SET default_tablespace = '';
  32. SET default_with_oids = false;
  33. CREATE TABLE migrate_version (
  34. version_num character varying(32) NOT NULL
  35. );
  36. ALTER TABLE public.migrate_version OWNER TO pod_master;
  37. CREATE TABLE pod_node_status (
  38. status_type character varying(16) NOT NULL,
  39. status_id character varying(16) NOT NULL,
  40. status_label character varying(256),
  41. hexa_color_foreground character(7),
  42. hexa_color_background character(7)
  43. );
  44. ALTER TABLE public.pod_node_status OWNER TO pod_master;
  45. CREATE TABLE pod_nodes (
  46. node_id integer NOT NULL,
  47. parent_id integer,
  48. node_order integer DEFAULT 1,
  49. node_type character varying(16) DEFAULT 'data'::character varying NOT NULL,
  50. created_at timestamp without time zone,
  51. updated_at timestamp without time zone,
  52. data_label character varying(1024),
  53. data_content text DEFAULT ''::text NOT NULL,
  54. data_datetime timestamp without time zone,
  55. node_status character varying(16) DEFAULT 'new'::character varying,
  56. data_reminder_datetime timestamp without time zone,
  57. data_file_name character varying(255),
  58. data_file_content bytea,
  59. data_file_mime_type character varying(255),
  60. parent_tree_path character varying(255),
  61. node_depth integer DEFAULT 0 NOT NULL,
  62. owner_id integer
  63. );
  64. ALTER TABLE public.pod_nodes OWNER TO pod_master;
  65. CREATE SEQUENCE pod_nodes__node_id__sequence
  66. START WITH 1
  67. INCREMENT BY 1
  68. NO MINVALUE
  69. NO MAXVALUE
  70. CACHE 1;
  71. ALTER TABLE public.pod_nodes__node_id__sequence OWNER TO pod_master;
  72. ALTER SEQUENCE pod_nodes__node_id__sequence OWNED BY pod_nodes.node_id;
  73. CREATE TABLE pod_group (
  74. group_id integer NOT NULL,
  75. group_name character varying(16) NOT NULL,
  76. display_name character varying(255),
  77. created timestamp without time zone
  78. );
  79. ALTER TABLE public.pod_group OWNER TO pod_master;
  80. CREATE SEQUENCE pod_group_group_id_seq
  81. START WITH 1
  82. INCREMENT BY 1
  83. NO MINVALUE
  84. NO MAXVALUE
  85. CACHE 1;
  86. ALTER TABLE public.pod_group_group_id_seq OWNER TO pod_master;
  87. ALTER SEQUENCE pod_group_group_id_seq OWNED BY pod_group.group_id;
  88. CREATE TABLE pod_group_permission (
  89. group_id integer NOT NULL,
  90. permission_id integer NOT NULL
  91. );
  92. ALTER TABLE public.pod_group_permission OWNER TO pod_master;
  93. CREATE TABLE pod_permission (
  94. permission_id integer NOT NULL,
  95. permission_name character varying(63) NOT NULL,
  96. description character varying(255)
  97. );
  98. ALTER TABLE public.pod_permission OWNER TO pod_master;
  99. CREATE SEQUENCE pod_permission_permission_id_seq
  100. START WITH 1
  101. INCREMENT BY 1
  102. NO MINVALUE
  103. NO MAXVALUE
  104. CACHE 1;
  105. ALTER TABLE public.pod_permission_permission_id_seq OWNER TO pod_master;
  106. ALTER SEQUENCE pod_permission_permission_id_seq OWNED BY pod_permission.permission_id;
  107. CREATE TABLE pod_user (
  108. user_id integer NOT NULL,
  109. email_address character varying(255) NOT NULL,
  110. display_name character varying(255),
  111. password character varying(128),
  112. created timestamp without time zone
  113. );
  114. ALTER TABLE public.pod_user OWNER TO pod_master;
  115. CREATE TABLE pod_user_group (
  116. user_id integer NOT NULL,
  117. group_id integer NOT NULL
  118. );
  119. ALTER TABLE public.pod_user_group OWNER TO pod_master;
  120. CREATE SEQUENCE pod_user_user_id_seq
  121. START WITH 1
  122. INCREMENT BY 1
  123. NO MINVALUE
  124. NO MAXVALUE
  125. CACHE 1;
  126. ALTER TABLE public.pod_user_user_id_seq OWNER TO pod_master;
  127. ALTER SEQUENCE pod_user_user_id_seq OWNED BY pod_user.user_id;
  128. ALTER TABLE ONLY pod_nodes ALTER COLUMN node_id SET DEFAULT nextval('pod_nodes__node_id__sequence'::regclass);
  129. ALTER TABLE ONLY pod_group ALTER COLUMN group_id SET DEFAULT nextval('pod_group_group_id_seq'::regclass);
  130. ALTER TABLE ONLY pod_permission ALTER COLUMN permission_id SET DEFAULT nextval('pod_permission_permission_id_seq'::regclass);
  131. ALTER TABLE ONLY pod_user ALTER COLUMN user_id SET DEFAULT nextval('pod_user_user_id_seq'::regclass);
  132. ALTER TABLE ONLY pod_node_status
  133. ADD CONSTRAINT pod_node_status__pk PRIMARY KEY (status_id);
  134. ALTER TABLE ONLY pod_nodes
  135. ADD CONSTRAINT pod_nodes_pk PRIMARY KEY (node_id);
  136. ALTER TABLE ONLY pod_group
  137. ADD CONSTRAINT pod_group_group_name_key UNIQUE (group_name);
  138. ALTER TABLE ONLY pod_group_permission
  139. ADD CONSTRAINT pod_group_permission_pkey PRIMARY KEY (group_id, permission_id);
  140. ALTER TABLE ONLY pod_group
  141. ADD CONSTRAINT pod_group_pkey PRIMARY KEY (group_id);
  142. ALTER TABLE ONLY pod_permission
  143. ADD CONSTRAINT pod_permission_permission_name_key UNIQUE (permission_name);
  144. ALTER TABLE ONLY pod_permission
  145. ADD CONSTRAINT pod_permission_pkey PRIMARY KEY (permission_id);
  146. ALTER TABLE ONLY pod_user
  147. ADD CONSTRAINT pod_user_email_address_key UNIQUE (email_address);
  148. ALTER TABLE ONLY pod_user_group
  149. ADD CONSTRAINT pod_user_group_pkey PRIMARY KEY (user_id, group_id);
  150. ALTER TABLE ONLY pod_user
  151. ADD CONSTRAINT pod_user_pkey PRIMARY KEY (user_id);
  152. CREATE INDEX fki_pod_nodes__owner_id_fk ON pod_nodes USING btree (owner_id);
  153. CREATE INDEX fki_pod_nodes__parent_id_fk ON pod_nodes USING btree (parent_id);
  154. CREATE INDEX idx_pod_nodes__parent_tree_path ON pod_nodes USING btree (parent_tree_path);
  155. CREATE TRIGGER pod_nodes__on_insert_set_created_at BEFORE INSERT ON pod_nodes FOR EACH ROW EXECUTE PROCEDURE set_created_at();
  156. CREATE TRIGGER pod_nodes__on_update_set_updated_at BEFORE UPDATE ON pod_nodes FOR EACH ROW EXECUTE PROCEDURE set_updated_at();
  157. ALTER TABLE ONLY pod_nodes
  158. ADD CONSTRAINT pod_nodes__owner_id_fk FOREIGN KEY (owner_id) REFERENCES pod_user(user_id);
  159. ALTER TABLE ONLY pod_nodes
  160. ADD CONSTRAINT pod_nodes__parent_id_fk FOREIGN KEY (parent_id) REFERENCES pod_nodes(node_id);
  161. ALTER TABLE ONLY pod_group_permission
  162. ADD CONSTRAINT pod_group_permission_group_id_fkey FOREIGN KEY (group_id) REFERENCES pod_group(group_id) ON UPDATE CASCADE ON DELETE CASCADE;
  163. ALTER TABLE ONLY pod_group_permission
  164. ADD CONSTRAINT pod_group_permission_permission_id_fkey FOREIGN KEY (permission_id) REFERENCES pod_permission(permission_id) ON UPDATE CASCADE ON DELETE CASCADE;
  165. ALTER TABLE ONLY pod_user_group
  166. ADD CONSTRAINT pod_user_group_group_id_fkey FOREIGN KEY (group_id) REFERENCES pod_group(group_id) ON UPDATE CASCADE ON DELETE CASCADE;
  167. ALTER TABLE ONLY pod_user_group
  168. ADD CONSTRAINT pod_user_group_user_id_fkey FOREIGN KEY (user_id) REFERENCES pod_user(user_id) ON UPDATE CASCADE ON DELETE CASCADE;
  169. REVOKE ALL ON SCHEMA public FROM PUBLIC;
  170. REVOKE ALL ON SCHEMA public FROM postgres;
  171. GRANT ALL ON SCHEMA public TO postgres;
  172. GRANT ALL ON SCHEMA public TO PUBLIC;