Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

dump.sql 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. --
  2. -- PostgreSQL database dump
  3. --
  4. SET statement_timeout = 0;
  5. SET lock_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. SET search_path = public, pg_catalog;
  19. --
  20. -- Name: sp_lu_get_user_permission(integer, character varying); Type: FUNCTION; Schema: public; Owner: dev
  21. --
  22. CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
  23. LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
  24. AS $$
  25. DECLARE
  26. groups int[];
  27. g INT;
  28. BEGIN
  29. SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
  30. IF val is null THEN
  31. SELECT array_agg("group_id") INTO groups FROM luticate_users_groups WHERE "user_id" = _user_id;
  32. IF groups is not null then
  33. FOREACH g in ARRAY groups LOOP
  34. SELECT "value" INTO val FROM luticate_permissions_groups WHERE "group_id" = g AND "name" = _permisson_name;
  35. IF val = FALSE THEN
  36. EXIT;
  37. END IF;
  38. END LOOP;
  39. END if;
  40. IF val is null then
  41. SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
  42. IF val is null then
  43. val := FALSE;
  44. end if;
  45. end if;
  46. END IF;
  47. END;
  48. $$;
  49. ALTER FUNCTION public.sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) OWNER TO dev;
  50. --
  51. -- Name: luticate_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
  52. --
  53. CREATE SEQUENCE luticate_groups_id_seq
  54. START WITH 1
  55. INCREMENT BY 1
  56. NO MINVALUE
  57. NO MAXVALUE
  58. CACHE 1;
  59. ALTER TABLE public.luticate_groups_id_seq OWNER TO dev;
  60. SET default_tablespace = '';
  61. SET default_with_oids = false;
  62. --
  63. -- Name: luticate_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
  64. --
  65. CREATE TABLE luticate_groups (
  66. id integer DEFAULT nextval('luticate_groups_id_seq'::regclass) NOT NULL,
  67. name character varying NOT NULL
  68. );
  69. ALTER TABLE public.luticate_groups OWNER TO dev;
  70. --
  71. -- Name: luticate_permissions; Type: TABLE; Schema: public; Owner: dev; Tablespace:
  72. --
  73. CREATE TABLE luticate_permissions (
  74. name character varying(128) NOT NULL,
  75. value boolean NOT NULL
  76. );
  77. ALTER TABLE public.luticate_permissions OWNER TO dev;
  78. --
  79. -- Name: luticate_permissions_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
  80. --
  81. CREATE TABLE luticate_permissions_groups (
  82. name character varying(128) NOT NULL,
  83. value boolean NOT NULL,
  84. group_id integer NOT NULL
  85. );
  86. ALTER TABLE public.luticate_permissions_groups OWNER TO dev;
  87. --
  88. -- Name: luticate_permissions_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
  89. --
  90. CREATE TABLE luticate_permissions_users (
  91. name character varying(128) NOT NULL,
  92. value boolean,
  93. user_id integer
  94. );
  95. ALTER TABLE public.luticate_permissions_users OWNER TO dev;
  96. --
  97. -- Name: luticate_users_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
  98. --
  99. CREATE SEQUENCE luticate_users_id_seq
  100. START WITH 1
  101. INCREMENT BY 1
  102. NO MINVALUE
  103. NO MAXVALUE
  104. CACHE 1;
  105. ALTER TABLE public.luticate_users_id_seq OWNER TO dev;
  106. --
  107. -- Name: luticate_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
  108. --
  109. CREATE TABLE luticate_users (
  110. id integer DEFAULT nextval('luticate_users_id_seq'::regclass) NOT NULL,
  111. username character varying(255) NOT NULL,
  112. email character varying(255) NOT NULL,
  113. password character varying(255) NOT NULL,
  114. salt character varying(10) NOT NULL
  115. );
  116. ALTER TABLE public.luticate_users OWNER TO dev;
  117. --
  118. -- Name: luticate_users_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
  119. --
  120. CREATE TABLE luticate_users_groups (
  121. user_id integer NOT NULL,
  122. group_id integer NOT NULL
  123. );
  124. ALTER TABLE public.luticate_users_groups OWNER TO dev;
  125. --
  126. -- Name: luticate_groups_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  127. --
  128. ALTER TABLE ONLY luticate_groups
  129. ADD CONSTRAINT luticate_groups_name_key UNIQUE (name);
  130. --
  131. -- Name: luticate_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  132. --
  133. ALTER TABLE ONLY luticate_groups
  134. ADD CONSTRAINT luticate_groups_pkey PRIMARY KEY (id);
  135. --
  136. -- Name: luticate_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  137. --
  138. ALTER TABLE ONLY luticate_permissions
  139. ADD CONSTRAINT luticate_permissions_pkey PRIMARY KEY (name);
  140. --
  141. -- Name: luticate_users_email_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  142. --
  143. ALTER TABLE ONLY luticate_users
  144. ADD CONSTRAINT luticate_users_email_key UNIQUE (email);
  145. --
  146. -- Name: luticate_users_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  147. --
  148. ALTER TABLE ONLY luticate_users_groups
  149. ADD CONSTRAINT luticate_users_groups_pkey PRIMARY KEY (user_id, group_id);
  150. --
  151. -- Name: luticate_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  152. --
  153. ALTER TABLE ONLY luticate_users
  154. ADD CONSTRAINT luticate_users_pkey PRIMARY KEY (id);
  155. --
  156. -- Name: luticate_users_username_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  157. --
  158. ALTER TABLE ONLY luticate_users
  159. ADD CONSTRAINT luticate_users_username_key UNIQUE (username);
  160. --
  161. -- Name: pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
  162. --
  163. ALTER TABLE ONLY luticate_permissions_groups
  164. ADD CONSTRAINT pkey PRIMARY KEY (name, group_id);
  165. --
  166. -- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
  167. --
  168. ALTER TABLE ONLY luticate_users_groups
  169. ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id);
  170. --
  171. -- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
  172. --
  173. ALTER TABLE ONLY luticate_permissions_groups
  174. ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id);
  175. --
  176. -- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: dev
  177. --
  178. ALTER TABLE ONLY luticate_permissions_groups
  179. ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name);
  180. --
  181. -- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: dev
  182. --
  183. ALTER TABLE ONLY luticate_permissions_users
  184. ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name);
  185. --
  186. -- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: dev
  187. --
  188. ALTER TABLE ONLY luticate_users_groups
  189. ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id);
  190. --
  191. -- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: dev
  192. --
  193. ALTER TABLE ONLY luticate_permissions_users
  194. ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id);
  195. --
  196. -- Name: public; Type: ACL; Schema: -; Owner: postgres
  197. --
  198. REVOKE ALL ON SCHEMA public FROM PUBLIC;
  199. REVOKE ALL ON SCHEMA public FROM postgres;
  200. GRANT ALL ON SCHEMA public TO postgres;
  201. GRANT ALL ON SCHEMA public TO PUBLIC;
  202. --
  203. -- PostgreSQL database dump complete
  204. --