소스 검색

sql

develop
Robin Thoni 8 년 전
부모
커밋
38255ad8d4
2개의 변경된 파일770개의 추가작업 그리고 0개의 파일을 삭제
  1. 274
    0
      sql/data_init.sql
  2. 496
    0
      sql/struct_init.sql

+ 274
- 0
sql/data_init.sql 파일 보기

@@ -0,0 +1,274 @@
1
+--
2
+-- PostgreSQL database dump
3
+--
4
+
5
+-- Dumped from database version 9.4.7
6
+-- Dumped by pg_dump version 9.4.7
7
+-- Started on 2016-04-27 09:42:45 CEST
8
+
9
+SET statement_timeout = 0;
10
+SET lock_timeout = 0;
11
+SET client_encoding = 'UTF8';
12
+SET standard_conforming_strings = on;
13
+SET check_function_bodies = false;
14
+SET client_min_messages = warning;
15
+
16
+SET search_path = public, pg_catalog;
17
+
18
+--
19
+-- TOC entry 2119 (class 0 OID 25804)
20
+-- Dependencies: 184
21
+-- Data for Name: images; Type: TABLE DATA; Schema: public; Owner: dev
22
+--
23
+
24
+
25
+
26
+--
27
+-- TOC entry 2124 (class 0 OID 0)
28
+-- Dependencies: 183
29
+-- Name: images_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
30
+--
31
+
32
+SELECT pg_catalog.setval('images_id_seq', 14, true);
33
+
34
+
35
+--
36
+-- TOC entry 2109 (class 0 OID 25696)
37
+-- Dependencies: 174
38
+-- Data for Name: luticate_groups; Type: TABLE DATA; Schema: public; Owner: dev
39
+--
40
+
41
+INSERT INTO luticate_groups VALUES (0, 'Super Administrators');
42
+INSERT INTO luticate_groups VALUES (1, 'Administrators');
43
+
44
+
45
+--
46
+-- TOC entry 2125 (class 0 OID 0)
47
+-- Dependencies: 173
48
+-- Name: luticate_groups_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
49
+--
50
+
51
+SELECT pg_catalog.setval('luticate_groups_id_seq', 2, true);
52
+
53
+
54
+--
55
+-- TOC entry 2110 (class 0 OID 25703)
56
+-- Dependencies: 175
57
+-- Data for Name: luticate_permissions; Type: TABLE DATA; Schema: public; Owner: dev
58
+--
59
+
60
+INSERT INTO luticate_permissions VALUES ('LU_USER_SET_PASSWORD', false);
61
+INSERT INTO luticate_permissions VALUES ('LU_USER_LOGIN', true);
62
+INSERT INTO luticate_permissions VALUES ('LU_USER_EDIT_ME', true);
63
+INSERT INTO luticate_permissions VALUES ('LU_USER_SET_PASSWORD_ME', true);
64
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_ADD', false);
65
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_DEL', false);
66
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_EDIT', false);
67
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_USER_ADD', false);
68
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_USER_DEL', false);
69
+INSERT INTO luticate_permissions VALUES ('LU_PERM_ADD', false);
70
+INSERT INTO luticate_permissions VALUES ('LU_PERM_DEL', false);
71
+INSERT INTO luticate_permissions VALUES ('LU_PERM_EDIT', false);
72
+INSERT INTO luticate_permissions VALUES ('LU_PERM_EFFECTIVE_GET', false);
73
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GET', false);
74
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_ADD', false);
75
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_DEL', false);
76
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_EDIT', false);
77
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_GET', false);
78
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_GET', false);
79
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_ADD', false);
80
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_DEL', false);
81
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_EDIT', false);
82
+INSERT INTO luticate_permissions VALUES ('LU_USER_EDIT', false);
83
+INSERT INTO luticate_permissions VALUES ('LU_USER_DEL', false);
84
+INSERT INTO luticate_permissions VALUES ('LU_USER_ADD', false);
85
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_GET', false);
86
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_DEL', false);
87
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EDIT', false);
88
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EFFECTIVE_GET', false);
89
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_GET', false);
90
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_USER_EDIT', false);
91
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_USER_GET', false);
92
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EDIT_ME', false);
93
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_ADD', false);
94
+INSERT INTO luticate_permissions VALUES ('PX_UPLOAD', true);
95
+INSERT INTO luticate_permissions VALUES ('LU_USER_GET', true);
96
+
97
+
98
+--
99
+-- TOC entry 2111 (class 0 OID 25706)
100
+-- Dependencies: 176
101
+-- Data for Name: luticate_permissions_groups; Type: TABLE DATA; Schema: public; Owner: dev
102
+--
103
+
104
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_ADD', true, 0);
105
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_DEL', true, 0);
106
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_EDIT', true, 0);
107
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_GET', true, 0);
108
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_ADD', true, 0);
109
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_DEL', true, 0);
110
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EFFECTIVE_GET', true, 0);
111
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GET', true, 0);
112
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_ADD', true, 0);
113
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_DEL', true, 0);
114
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_EDIT', true, 0);
115
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_GET', true, 0);
116
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_ADD', true, 0);
117
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_DEL', true, 0);
118
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_EDIT', true, 0);
119
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_GET', true, 0);
120
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_ADD', true, 0);
121
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_DEL', true, 0);
122
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT', true, 0);
123
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT_ME', true, 0);
124
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_GET', true, 0);
125
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_LOGIN', true, 0);
126
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD', true, 0);
127
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD_ME', true, 0);
128
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_ADD', true, 1);
129
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_DEL', true, 1);
130
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_EDIT', true, 1);
131
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_GET', true, 1);
132
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_ADD', true, 1);
133
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_DEL', true, 1);
134
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EFFECTIVE_GET', true, 1);
135
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GET', true, 1);
136
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_ADD', true, 1);
137
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_DEL', true, 1);
138
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_EDIT', true, 1);
139
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_GET', true, 1);
140
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_ADD', true, 1);
141
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_DEL', true, 1);
142
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_EDIT', true, 1);
143
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_GET', true, 1);
144
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_ADD', true, 1);
145
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_DEL', true, 1);
146
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT', true, 1);
147
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT_ME', true, 1);
148
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_GET', true, 1);
149
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_LOGIN', true, 1);
150
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD', true, 1);
151
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD_ME', true, 1);
152
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EDIT', true, 0);
153
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_DEL', true, 0);
154
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_ADD', true, 0);
155
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_ADD', false, 1);
156
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EDIT', false, 1);
157
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_DEL', false, 1);
158
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_ADD', false, 1);
159
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_DEL', false, 1);
160
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT', true, 1);
161
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EFFECTIVE_GET', true, 1);
162
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_GET', true, 1);
163
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_EDIT', true, 1);
164
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_GET', true, 1);
165
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_ADD', true, 0);
166
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_DEL', true, 0);
167
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT', true, 0);
168
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EFFECTIVE_GET', true, 0);
169
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_GET', true, 0);
170
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_EDIT', true, 0);
171
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_GET', true, 0);
172
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT_ME', true, 1);
173
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT_ME', true, 0);
174
+
175
+
176
+--
177
+-- TOC entry 2114 (class 0 OID 25714)
178
+-- Dependencies: 179
179
+-- Data for Name: luticate_users; Type: TABLE DATA; Schema: public; Owner: dev
180
+--
181
+
182
+INSERT INTO luticate_users VALUES (0, 'anonymous', 'anonymous@example.com', '', '', NULL, 'anonymous', 'anonymous');
183
+INSERT INTO luticate_users VALUES (1, 'root', 'root@example.com', '$2y$10$m1aN1a1ZEr1vmjFPfWl4Pu/63EhcxVCrC/DF0DFhdGbvORwtJtCmy', 'AGLUILNxbh', NULL, 'root', 'root');
184
+
185
+
186
+--
187
+-- TOC entry 2112 (class 0 OID 25709)
188
+-- Dependencies: 177
189
+-- Data for Name: luticate_permissions_users; Type: TABLE DATA; Schema: public; Owner: dev
190
+--
191
+
192
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_ADD', false, 0);
193
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_DEL', false, 0);
194
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_EDIT', false, 0);
195
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_USER_ADD', false, 0);
196
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_USER_DEL', false, 0);
197
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_ADD', false, 0);
198
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_DEL', false, 0);
199
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_EDIT', false, 0);
200
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_EFFECTIVE_GET', false, 0);
201
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GET', false, 0);
202
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_ADD', false, 0);
203
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_DEL', false, 0);
204
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_EDIT', false, 0);
205
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_GET', false, 0);
206
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_ADD', false, 0);
207
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_DEL', false, 0);
208
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_EDIT', false, 0);
209
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_GET', false, 0);
210
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_DEL', false, 0);
211
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_EDIT', false, 0);
212
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_EDIT_ME', false, 0);
213
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_SET_PASSWORD', false, 0);
214
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_SET_PASSWORD_ME', false, 0);
215
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_LOGIN', true, 0);
216
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_GET', false, 0);
217
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_USER_GET', true, 0);
218
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_ADD', false, 0);
219
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EDIT', false, 0);
220
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EFFECTIVE_GET', false, 0);
221
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_DEL', false, 0);
222
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EDIT_ME', false, 0);
223
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_GET', false, 0);
224
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_USER_EDIT', false, 0);
225
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_ADD', true, 0);
226
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_GET', true, 0);
227
+INSERT INTO luticate_permissions_users VALUES ('PX_UPLOAD', false, 0);
228
+
229
+
230
+--
231
+-- TOC entry 2116 (class 0 OID 25774)
232
+-- Dependencies: 181
233
+-- Data for Name: luticate_settings; Type: TABLE DATA; Schema: public; Owner: dev
234
+--
235
+
236
+INSERT INTO luticate_settings VALUES ('LU_SESSION_DAYS', 'int', '30', true, true);
237
+INSERT INTO luticate_settings VALUES ('LU_USERS_PER_PAGE', 'int', '15', false, false);
238
+INSERT INTO luticate_settings VALUES ('LU_GROUPS_PER_PAGE', 'int', '15', false, false);
239
+INSERT INTO luticate_settings VALUES ('LU_SETTINGS_PER_PAGE', 'int', '15', false, false);
240
+INSERT INTO luticate_settings VALUES ('LU_PERMISSIONS_PER_PAGE', 'int', '15', false, false);
241
+
242
+
243
+--
244
+-- TOC entry 2117 (class 0 OID 25780)
245
+-- Dependencies: 182
246
+-- Data for Name: luticate_settings_users; Type: TABLE DATA; Schema: public; Owner: dev
247
+--
248
+
249
+
250
+
251
+--
252
+-- TOC entry 2115 (class 0 OID 25721)
253
+-- Dependencies: 180
254
+-- Data for Name: luticate_users_groups; Type: TABLE DATA; Schema: public; Owner: dev
255
+--
256
+
257
+INSERT INTO luticate_users_groups VALUES (1, 0);
258
+
259
+
260
+--
261
+-- TOC entry 2126 (class 0 OID 0)
262
+-- Dependencies: 178
263
+-- Name: luticate_users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
264
+--
265
+
266
+SELECT pg_catalog.setval('luticate_users_id_seq', 3, true);
267
+
268
+
269
+-- Completed on 2016-04-27 09:42:45 CEST
270
+
271
+--
272
+-- PostgreSQL database dump complete
273
+--
274
+

+ 496
- 0
sql/struct_init.sql 파일 보기

@@ -0,0 +1,496 @@
1
+--
2
+-- PostgreSQL database dump
3
+--
4
+
5
+-- Dumped from database version 9.4.7
6
+-- Dumped by pg_dump version 9.4.7
7
+-- Started on 2016-04-27 09:40:56 CEST
8
+
9
+SET statement_timeout = 0;
10
+SET lock_timeout = 0;
11
+SET client_encoding = 'UTF8';
12
+SET standard_conforming_strings = on;
13
+SET check_function_bodies = false;
14
+SET client_min_messages = warning;
15
+
16
+--
17
+-- TOC entry 1 (class 3079 OID 11893)
18
+-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
19
+--
20
+
21
+CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
22
+
23
+
24
+--
25
+-- TOC entry 2114 (class 0 OID 0)
26
+-- Dependencies: 1
27
+-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
28
+--
29
+
30
+COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
31
+
32
+
33
+SET search_path = public, pg_catalog;
34
+
35
+--
36
+-- TOC entry 201 (class 1255 OID 25843)
37
+-- Name: sp_get_images(boolean, integer); Type: FUNCTION; Schema: public; Owner: -
38
+--
39
+
40
+CREATE FUNCTION sp_get_images(_only_mine boolean, _user_id_me integer, OUT id integer, OUT name text, OUT user_id integer, OUT date timestamp without time zone) RETURNS SETOF record
41
+    LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
42
+    AS $$
43
+        SELECT i.id, i.name, i.user_id, i.date
44
+        FROM images i
45
+        WHERE (CASE WHEN _only_mine THEN i.user_id = _user_id_me ELSE TRUE END)
46
+$$;
47
+
48
+
49
+--
50
+-- TOC entry 198 (class 1255 OID 25773)
51
+-- Name: sp_lu_get_all_user_permission(integer); Type: FUNCTION; Schema: public; Owner: -
52
+--
53
+
54
+CREATE FUNCTION sp_lu_get_all_user_permission(_user_id integer, OUT _permisson_name character varying, OUT val boolean) RETURNS SETOF record
55
+    LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
56
+    AS $$
57
+SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p ORDER bY p.name
58
+$$;
59
+
60
+
61
+--
62
+-- TOC entry 200 (class 1255 OID 25801)
63
+-- Name: sp_lu_get_all_user_settings(integer); Type: FUNCTION; Schema: public; Owner: -
64
+--
65
+
66
+CREATE FUNCTION sp_lu_get_all_user_settings(_user_id integer, OUT _settings json) RETURNS SETOF json
67
+    LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
68
+    AS $$
69
+	SELECT sp_lu_get_user_setting(_user_id, s.name)
70
+	FROM luticate_settings s
71
+	WHERE NOT s.is_admin
72
+	ORDER BY s.name
73
+$$;
74
+
75
+
76
+--
77
+-- TOC entry 197 (class 1255 OID 25772)
78
+-- Name: sp_lu_get_user_permission(integer, character varying); Type: FUNCTION; Schema: public; Owner: -
79
+--
80
+
81
+CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
82
+    LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
83
+    AS $$
84
+DECLARE
85
+    groups int[];
86
+    g INT;
87
+BEGIN
88
+    SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
89
+    IF val is null THEN
90
+        SELECT lpg."value" into val FROM luticate_permissions_groups lpg
91
+            INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
92
+            INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
93
+        WHERE lpg."name" = _permisson_name and lpg."value" = FALSE;
94
+        IF val is null then
95
+            SELECT lpg."value" into val FROM luticate_permissions_groups lpg
96
+                INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
97
+                INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
98
+            WHERE lpg."name" = _permisson_name and lpg."value" = TRUE;
99
+            IF val is null then
100
+                SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
101
+            END IF;
102
+        end if;
103
+    END IF;
104
+END;
105
+$$;
106
+
107
+
108
+--
109
+-- TOC entry 199 (class 1255 OID 25800)
110
+-- Name: sp_lu_get_user_setting(integer, character varying); Type: FUNCTION; Schema: public; Owner: -
111
+--
112
+
113
+CREATE FUNCTION sp_lu_get_user_setting(_user_id integer, _setting_name character varying, OUT setting json) RETURNS json
114
+    LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
115
+    AS $$
116
+DECLARE
117
+_setting luticate_settings;
118
+_setting_user luticate_settings_users;
119
+BEGIN
120
+    SELECT * INTO _setting FROM luticate_settings WHERE "name" = _setting_name AND NOT "is_admin";
121
+    IF _setting IS NULL THEN
122
+        setting := NULL;
123
+    ELSE
124
+        IF NOT _setting.is_blocked THEN
125
+            SELECT * INTO _setting_user FROM luticate_settings_users WHERE "user_id" = _user_id AND "name" = _setting_name;
126
+            IF _setting_user IS NOT NULL THEN
127
+                _setting.value := _setting_user.value;
128
+            END IF;
129
+        END IF;
130
+        setting := to_json(_setting);
131
+    END IF;
132
+END;
133
+$$;
134
+
135
+
136
+SET default_tablespace = '';
137
+
138
+SET default_with_oids = false;
139
+
140
+--
141
+-- TOC entry 184 (class 1259 OID 25804)
142
+-- Name: images; Type: TABLE; Schema: public; Owner: -; Tablespace: 
143
+--
144
+
145
+CREATE TABLE images (
146
+    id integer NOT NULL,
147
+    user_id integer NOT NULL,
148
+    path text NOT NULL,
149
+    date timestamp without time zone DEFAULT now() NOT NULL,
150
+    name text NOT NULL
151
+);
152
+
153
+
154
+--
155
+-- TOC entry 183 (class 1259 OID 25802)
156
+-- Name: images_id_seq; Type: SEQUENCE; Schema: public; Owner: -
157
+--
158
+
159
+CREATE SEQUENCE images_id_seq
160
+    START WITH 1
161
+    INCREMENT BY 1
162
+    NO MINVALUE
163
+    NO MAXVALUE
164
+    CACHE 1;
165
+
166
+
167
+--
168
+-- TOC entry 2115 (class 0 OID 0)
169
+-- Dependencies: 183
170
+-- Name: images_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
171
+--
172
+
173
+ALTER SEQUENCE images_id_seq OWNED BY images.id;
174
+
175
+
176
+--
177
+-- TOC entry 173 (class 1259 OID 25694)
178
+-- Name: luticate_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
179
+--
180
+
181
+CREATE SEQUENCE luticate_groups_id_seq
182
+    START WITH 1
183
+    INCREMENT BY 1
184
+    NO MINVALUE
185
+    NO MAXVALUE
186
+    CACHE 1;
187
+
188
+
189
+--
190
+-- TOC entry 174 (class 1259 OID 25696)
191
+-- Name: luticate_groups; Type: TABLE; Schema: public; Owner: -; Tablespace: 
192
+--
193
+
194
+CREATE TABLE luticate_groups (
195
+    id integer DEFAULT nextval('luticate_groups_id_seq'::regclass) NOT NULL,
196
+    name character varying NOT NULL
197
+);
198
+
199
+
200
+--
201
+-- TOC entry 175 (class 1259 OID 25703)
202
+-- Name: luticate_permissions; Type: TABLE; Schema: public; Owner: -; Tablespace: 
203
+--
204
+
205
+CREATE TABLE luticate_permissions (
206
+    name character varying(128) NOT NULL,
207
+    value boolean NOT NULL
208
+);
209
+
210
+
211
+--
212
+-- TOC entry 176 (class 1259 OID 25706)
213
+-- Name: luticate_permissions_groups; Type: TABLE; Schema: public; Owner: -; Tablespace: 
214
+--
215
+
216
+CREATE TABLE luticate_permissions_groups (
217
+    name character varying(128) NOT NULL,
218
+    value boolean NOT NULL,
219
+    group_id integer NOT NULL
220
+);
221
+
222
+
223
+--
224
+-- TOC entry 177 (class 1259 OID 25709)
225
+-- Name: luticate_permissions_users; Type: TABLE; Schema: public; Owner: -; Tablespace: 
226
+--
227
+
228
+CREATE TABLE luticate_permissions_users (
229
+    name character varying(128) NOT NULL,
230
+    value boolean,
231
+    user_id integer NOT NULL
232
+);
233
+
234
+
235
+--
236
+-- TOC entry 181 (class 1259 OID 25774)
237
+-- Name: luticate_settings; Type: TABLE; Schema: public; Owner: -; Tablespace: 
238
+--
239
+
240
+CREATE TABLE luticate_settings (
241
+    name character varying(128) NOT NULL,
242
+    type character varying(128) NOT NULL,
243
+    value text NOT NULL,
244
+    is_blocked boolean NOT NULL,
245
+    is_admin boolean NOT NULL
246
+);
247
+
248
+
249
+--
250
+-- TOC entry 182 (class 1259 OID 25780)
251
+-- Name: luticate_settings_users; Type: TABLE; Schema: public; Owner: -; Tablespace: 
252
+--
253
+
254
+CREATE TABLE luticate_settings_users (
255
+    name character varying(128) NOT NULL,
256
+    value text NOT NULL,
257
+    user_id integer NOT NULL,
258
+    is_blocked boolean NOT NULL
259
+);
260
+
261
+
262
+--
263
+-- TOC entry 178 (class 1259 OID 25712)
264
+-- Name: luticate_users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
265
+--
266
+
267
+CREATE SEQUENCE luticate_users_id_seq
268
+    START WITH 1
269
+    INCREMENT BY 1
270
+    NO MINVALUE
271
+    NO MAXVALUE
272
+    CACHE 1;
273
+
274
+
275
+--
276
+-- TOC entry 179 (class 1259 OID 25714)
277
+-- Name: luticate_users; Type: TABLE; Schema: public; Owner: -; Tablespace: 
278
+--
279
+
280
+CREATE TABLE luticate_users (
281
+    id integer DEFAULT nextval('luticate_users_id_seq'::regclass) NOT NULL,
282
+    username character varying(255) NOT NULL,
283
+    email character varying(255) NOT NULL,
284
+    password character varying(255) NOT NULL,
285
+    salt character varying(10) NOT NULL,
286
+    profile_id integer,
287
+    firstname character varying(255) NOT NULL,
288
+    lastname character varying(255) NOT NULL
289
+);
290
+
291
+
292
+--
293
+-- TOC entry 180 (class 1259 OID 25721)
294
+-- Name: luticate_users_groups; Type: TABLE; Schema: public; Owner: -; Tablespace: 
295
+--
296
+
297
+CREATE TABLE luticate_users_groups (
298
+    user_id integer NOT NULL,
299
+    group_id integer NOT NULL
300
+);
301
+
302
+
303
+--
304
+-- TOC entry 1965 (class 2604 OID 25807)
305
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
306
+--
307
+
308
+ALTER TABLE ONLY images ALTER COLUMN id SET DEFAULT nextval('images_id_seq'::regclass);
309
+
310
+
311
+--
312
+-- TOC entry 1990 (class 2606 OID 25812)
313
+-- Name: images_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
314
+--
315
+
316
+ALTER TABLE ONLY images
317
+    ADD CONSTRAINT images_pkey PRIMARY KEY (id);
318
+
319
+
320
+--
321
+-- TOC entry 1968 (class 2606 OID 25725)
322
+-- Name: luticate_groups_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
323
+--
324
+
325
+ALTER TABLE ONLY luticate_groups
326
+    ADD CONSTRAINT luticate_groups_name_key UNIQUE (name);
327
+
328
+
329
+--
330
+-- TOC entry 1970 (class 2606 OID 25727)
331
+-- Name: luticate_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
332
+--
333
+
334
+ALTER TABLE ONLY luticate_groups
335
+    ADD CONSTRAINT luticate_groups_pkey PRIMARY KEY (id);
336
+
337
+
338
+--
339
+-- TOC entry 1972 (class 2606 OID 25729)
340
+-- Name: luticate_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
341
+--
342
+
343
+ALTER TABLE ONLY luticate_permissions
344
+    ADD CONSTRAINT luticate_permissions_pkey PRIMARY KEY (name);
345
+
346
+
347
+--
348
+-- TOC entry 1976 (class 2606 OID 25731)
349
+-- Name: luticate_permissions_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
350
+--
351
+
352
+ALTER TABLE ONLY luticate_permissions_users
353
+    ADD CONSTRAINT luticate_permissions_users_pkey PRIMARY KEY (name, user_id);
354
+
355
+
356
+--
357
+-- TOC entry 1986 (class 2606 OID 25787)
358
+-- Name: luticate_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
359
+--
360
+
361
+ALTER TABLE ONLY luticate_settings
362
+    ADD CONSTRAINT luticate_settings_pkey PRIMARY KEY (name);
363
+
364
+
365
+--
366
+-- TOC entry 1988 (class 2606 OID 25789)
367
+-- Name: luticate_settings_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
368
+--
369
+
370
+ALTER TABLE ONLY luticate_settings_users
371
+    ADD CONSTRAINT luticate_settings_users_pkey PRIMARY KEY (name, user_id);
372
+
373
+
374
+--
375
+-- TOC entry 1978 (class 2606 OID 25733)
376
+-- Name: luticate_users_email_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
377
+--
378
+
379
+ALTER TABLE ONLY luticate_users
380
+    ADD CONSTRAINT luticate_users_email_key UNIQUE (email);
381
+
382
+
383
+--
384
+-- TOC entry 1984 (class 2606 OID 25735)
385
+-- Name: luticate_users_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
386
+--
387
+
388
+ALTER TABLE ONLY luticate_users_groups
389
+    ADD CONSTRAINT luticate_users_groups_pkey PRIMARY KEY (user_id, group_id);
390
+
391
+
392
+--
393
+-- TOC entry 1980 (class 2606 OID 25737)
394
+-- Name: luticate_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
395
+--
396
+
397
+ALTER TABLE ONLY luticate_users
398
+    ADD CONSTRAINT luticate_users_pkey PRIMARY KEY (id);
399
+
400
+
401
+--
402
+-- TOC entry 1982 (class 2606 OID 25739)
403
+-- Name: luticate_users_username_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
404
+--
405
+
406
+ALTER TABLE ONLY luticate_users
407
+    ADD CONSTRAINT luticate_users_username_key UNIQUE (username);
408
+
409
+
410
+--
411
+-- TOC entry 1974 (class 2606 OID 25741)
412
+-- Name: pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
413
+--
414
+
415
+ALTER TABLE ONLY luticate_permissions_groups
416
+    ADD CONSTRAINT pkey PRIMARY KEY (name, group_id);
417
+
418
+
419
+--
420
+-- TOC entry 1991 (class 2606 OID 25742)
421
+-- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: -
422
+--
423
+
424
+ALTER TABLE ONLY luticate_permissions_groups
425
+    ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
426
+
427
+
428
+--
429
+-- TOC entry 1995 (class 2606 OID 25747)
430
+-- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: -
431
+--
432
+
433
+ALTER TABLE ONLY luticate_users_groups
434
+    ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
435
+
436
+
437
+--
438
+-- TOC entry 1992 (class 2606 OID 25752)
439
+-- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: -
440
+--
441
+
442
+ALTER TABLE ONLY luticate_permissions_groups
443
+    ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
444
+
445
+
446
+--
447
+-- TOC entry 1993 (class 2606 OID 25757)
448
+-- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: -
449
+--
450
+
451
+ALTER TABLE ONLY luticate_permissions_users
452
+    ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
453
+
454
+
455
+--
456
+-- TOC entry 1994 (class 2606 OID 25762)
457
+-- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: -
458
+--
459
+
460
+ALTER TABLE ONLY luticate_permissions_users
461
+    ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
462
+
463
+
464
+--
465
+-- TOC entry 1996 (class 2606 OID 25767)
466
+-- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: -
467
+--
468
+
469
+ALTER TABLE ONLY luticate_users_groups
470
+    ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
471
+
472
+
473
+--
474
+-- TOC entry 1997 (class 2606 OID 25790)
475
+-- Name: luticate_settings_users_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
476
+--
477
+
478
+ALTER TABLE ONLY luticate_settings_users
479
+    ADD CONSTRAINT luticate_settings_users_name_fkey FOREIGN KEY (name) REFERENCES luticate_settings(name) ON DELETE CASCADE;
480
+
481
+
482
+--
483
+-- TOC entry 1998 (class 2606 OID 25795)
484
+-- Name: luticate_settings_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
485
+--
486
+
487
+ALTER TABLE ONLY luticate_settings_users
488
+    ADD CONSTRAINT luticate_settings_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
489
+
490
+
491
+-- Completed on 2016-04-27 09:40:56 CEST
492
+
493
+--
494
+-- PostgreSQL database dump complete
495
+--
496
+

Loading…
취소
저장