|
@@ -1,37 +1,23 @@
|
1
|
1
|
--
|
2
|
2
|
-- PostgreSQL database dump
|
3
|
3
|
--
|
4
|
|
-
|
5
|
|
-SET statement_timeout = 0;
|
6
|
|
-SET lock_timeout = 0;
|
7
|
|
-SET client_encoding = 'UTF8';
|
8
|
|
-SET standard_conforming_strings = on;
|
9
|
|
-SET check_function_bodies = false;
|
10
|
|
-SET client_min_messages = warning;
|
11
|
|
-
|
12
|
|
---
|
13
|
|
---
|
14
|
|
-
|
15
|
|
-CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
16
|
|
-
|
17
|
|
-
|
18
|
4
|
--
|
|
5
|
+-- Name: sp_lu_get_all_user_permission(integer); Type: FUNCTION; Schema: public; Owner: dev
|
19
|
6
|
--
|
20
|
7
|
|
21
|
|
-COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
22
|
|
-
|
23
|
|
-
|
24
|
|
-SET search_path = public, pg_catalog;
|
|
8
|
+CREATE FUNCTION sp_lu_get_all_user_permission(_user_id integer, OUT _permisson_name character varying, OUT val boolean) RETURNS SETOF record
|
|
9
|
+LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
|
|
10
|
+AS $$
|
|
11
|
+ SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p
|
|
12
|
+$$;
|
25
|
13
|
|
26
|
14
|
--
|
27
|
15
|
-- Name: sp_lu_get_user_permission(integer, character varying); Type: FUNCTION; Schema: public; Owner: dev
|
28
|
16
|
--
|
29
|
17
|
|
30
|
18
|
CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
|
31
|
|
- LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
|
32
|
|
- AS $$
|
|
19
|
+LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
|
|
20
|
+AS $$
|
33
|
21
|
DECLARE
|
34
|
22
|
groups int[];
|
35
|
23
|
g INT;
|
|
@@ -49,30 +35,21 @@ BEGIN
|
49
|
35
|
END if;
|
50
|
36
|
IF val is null then
|
51
|
37
|
SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
|
52
|
|
- IF val is null then
|
53
|
|
- val := FALSE;
|
54
|
|
- end if;
|
55
|
38
|
end if;
|
56
|
39
|
END IF;
|
57
|
40
|
END;
|
58
|
41
|
$$;
|
59
|
42
|
|
60
|
|
-
|
61
|
|
-ALTER FUNCTION public.sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) OWNER TO dev;
|
62
|
|
-
|
63
|
43
|
--
|
64
|
44
|
-- Name: luticate_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
|
65
|
45
|
--
|
66
|
46
|
|
67
|
47
|
CREATE SEQUENCE luticate_groups_id_seq
|
68
|
|
- START WITH 1
|
69
|
|
- INCREMENT BY 1
|
70
|
|
- NO MINVALUE
|
71
|
|
- NO MAXVALUE
|
72
|
|
- CACHE 1;
|
73
|
|
-
|
74
|
|
-
|
75
|
|
-ALTER TABLE public.luticate_groups_id_seq OWNER TO dev;
|
|
48
|
+START WITH 1
|
|
49
|
+INCREMENT BY 1
|
|
50
|
+NO MINVALUE
|
|
51
|
+NO MAXVALUE
|
|
52
|
+CACHE 1;
|
76
|
53
|
|
77
|
54
|
SET default_tablespace = '';
|
78
|
55
|
|
|
@@ -87,9 +64,6 @@ CREATE TABLE luticate_groups (
|
87
|
64
|
name character varying NOT NULL
|
88
|
65
|
);
|
89
|
66
|
|
90
|
|
-
|
91
|
|
-ALTER TABLE public.luticate_groups OWNER TO dev;
|
92
|
|
-
|
93
|
67
|
--
|
94
|
68
|
-- Name: luticate_permissions; Type: TABLE; Schema: public; Owner: dev; Tablespace:
|
95
|
69
|
--
|
|
@@ -99,9 +73,6 @@ CREATE TABLE luticate_permissions (
|
99
|
73
|
value boolean NOT NULL
|
100
|
74
|
);
|
101
|
75
|
|
102
|
|
-
|
103
|
|
-ALTER TABLE public.luticate_permissions OWNER TO dev;
|
104
|
|
-
|
105
|
76
|
--
|
106
|
77
|
-- Name: luticate_permissions_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
|
107
|
78
|
--
|
|
@@ -112,9 +83,6 @@ CREATE TABLE luticate_permissions_groups (
|
112
|
83
|
group_id integer NOT NULL
|
113
|
84
|
);
|
114
|
85
|
|
115
|
|
-
|
116
|
|
-ALTER TABLE public.luticate_permissions_groups OWNER TO dev;
|
117
|
|
-
|
118
|
86
|
--
|
119
|
87
|
-- Name: luticate_permissions_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
|
120
|
88
|
--
|
|
@@ -122,25 +90,19 @@ ALTER TABLE public.luticate_permissions_groups OWNER TO dev;
|
122
|
90
|
CREATE TABLE luticate_permissions_users (
|
123
|
91
|
name character varying(128) NOT NULL,
|
124
|
92
|
value boolean,
|
125
|
|
- user_id integer
|
|
93
|
+ user_id integer NOT NULL
|
126
|
94
|
);
|
127
|
95
|
|
128
|
|
-
|
129
|
|
-ALTER TABLE public.luticate_permissions_users OWNER TO dev;
|
130
|
|
-
|
131
|
96
|
--
|
132
|
97
|
-- Name: luticate_users_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
|
133
|
98
|
--
|
134
|
99
|
|
135
|
100
|
CREATE SEQUENCE luticate_users_id_seq
|
136
|
|
- START WITH 1
|
137
|
|
- INCREMENT BY 1
|
138
|
|
- NO MINVALUE
|
139
|
|
- NO MAXVALUE
|
140
|
|
- CACHE 1;
|
141
|
|
-
|
142
|
|
-
|
143
|
|
-ALTER TABLE public.luticate_users_id_seq OWNER TO dev;
|
|
101
|
+START WITH 1
|
|
102
|
+INCREMENT BY 1
|
|
103
|
+NO MINVALUE
|
|
104
|
+NO MAXVALUE
|
|
105
|
+CACHE 1;
|
144
|
106
|
|
145
|
107
|
--
|
146
|
108
|
-- Name: luticate_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
|
|
@@ -151,12 +113,12 @@ CREATE TABLE luticate_users (
|
151
|
113
|
username character varying(255) NOT NULL,
|
152
|
114
|
email character varying(255) NOT NULL,
|
153
|
115
|
password character varying(255) NOT NULL,
|
154
|
|
- salt character varying(10) NOT NULL
|
|
116
|
+ salt character varying(10) NOT NULL,
|
|
117
|
+ profile_id integer,
|
|
118
|
+ firstname character varying(255) NOT NULL,
|
|
119
|
+ lastname character varying(255) NOT NULL
|
155
|
120
|
);
|
156
|
121
|
|
157
|
|
-
|
158
|
|
-ALTER TABLE public.luticate_users OWNER TO dev;
|
159
|
|
-
|
160
|
122
|
--
|
161
|
123
|
-- Name: luticate_users_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
|
162
|
124
|
--
|
|
@@ -166,15 +128,12 @@ CREATE TABLE luticate_users_groups (
|
166
|
128
|
group_id integer NOT NULL
|
167
|
129
|
);
|
168
|
130
|
|
169
|
|
-
|
170
|
|
-ALTER TABLE public.luticate_users_groups OWNER TO dev;
|
171
|
|
-
|
172
|
131
|
--
|
173
|
132
|
-- Name: luticate_groups_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
|
174
|
133
|
--
|
175
|
134
|
|
176
|
135
|
ALTER TABLE ONLY luticate_groups
|
177
|
|
- ADD CONSTRAINT luticate_groups_name_key UNIQUE (name);
|
|
136
|
+ADD CONSTRAINT luticate_groups_name_key UNIQUE (name);
|
178
|
137
|
|
179
|
138
|
|
180
|
139
|
--
|
|
@@ -182,7 +141,7 @@ ALTER TABLE ONLY luticate_groups
|
182
|
141
|
--
|
183
|
142
|
|
184
|
143
|
ALTER TABLE ONLY luticate_groups
|
185
|
|
- ADD CONSTRAINT luticate_groups_pkey PRIMARY KEY (id);
|
|
144
|
+ADD CONSTRAINT luticate_groups_pkey PRIMARY KEY (id);
|
186
|
145
|
|
187
|
146
|
|
188
|
147
|
--
|
|
@@ -190,7 +149,15 @@ ALTER TABLE ONLY luticate_groups
|
190
|
149
|
--
|
191
|
150
|
|
192
|
151
|
ALTER TABLE ONLY luticate_permissions
|
193
|
|
- ADD CONSTRAINT luticate_permissions_pkey PRIMARY KEY (name);
|
|
152
|
+ADD CONSTRAINT luticate_permissions_pkey PRIMARY KEY (name);
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+--
|
|
156
|
+-- Name: luticate_permissions_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
|
|
157
|
+--
|
|
158
|
+
|
|
159
|
+ALTER TABLE ONLY luticate_permissions_users
|
|
160
|
+ADD CONSTRAINT luticate_permissions_users_pkey PRIMARY KEY (name, user_id);
|
194
|
161
|
|
195
|
162
|
|
196
|
163
|
--
|
|
@@ -198,7 +165,7 @@ ALTER TABLE ONLY luticate_permissions
|
198
|
165
|
--
|
199
|
166
|
|
200
|
167
|
ALTER TABLE ONLY luticate_users
|
201
|
|
- ADD CONSTRAINT luticate_users_email_key UNIQUE (email);
|
|
168
|
+ADD CONSTRAINT luticate_users_email_key UNIQUE (email);
|
202
|
169
|
|
203
|
170
|
|
204
|
171
|
--
|
|
@@ -206,7 +173,7 @@ ALTER TABLE ONLY luticate_users
|
206
|
173
|
--
|
207
|
174
|
|
208
|
175
|
ALTER TABLE ONLY luticate_users_groups
|
209
|
|
- ADD CONSTRAINT luticate_users_groups_pkey PRIMARY KEY (user_id, group_id);
|
|
176
|
+ADD CONSTRAINT luticate_users_groups_pkey PRIMARY KEY (user_id, group_id);
|
210
|
177
|
|
211
|
178
|
|
212
|
179
|
--
|
|
@@ -214,7 +181,7 @@ ALTER TABLE ONLY luticate_users_groups
|
214
|
181
|
--
|
215
|
182
|
|
216
|
183
|
ALTER TABLE ONLY luticate_users
|
217
|
|
- ADD CONSTRAINT luticate_users_pkey PRIMARY KEY (id);
|
|
184
|
+ADD CONSTRAINT luticate_users_pkey PRIMARY KEY (id);
|
218
|
185
|
|
219
|
186
|
|
220
|
187
|
--
|
|
@@ -222,7 +189,7 @@ ALTER TABLE ONLY luticate_users
|
222
|
189
|
--
|
223
|
190
|
|
224
|
191
|
ALTER TABLE ONLY luticate_users
|
225
|
|
- ADD CONSTRAINT luticate_users_username_key UNIQUE (username);
|
|
192
|
+ADD CONSTRAINT luticate_users_username_key UNIQUE (username);
|
226
|
193
|
|
227
|
194
|
|
228
|
195
|
--
|
|
@@ -230,23 +197,23 @@ ALTER TABLE ONLY luticate_users
|
230
|
197
|
--
|
231
|
198
|
|
232
|
199
|
ALTER TABLE ONLY luticate_permissions_groups
|
233
|
|
- ADD CONSTRAINT pkey PRIMARY KEY (name, group_id);
|
|
200
|
+ADD CONSTRAINT pkey PRIMARY KEY (name, group_id);
|
234
|
201
|
|
235
|
202
|
|
236
|
203
|
--
|
237
|
204
|
-- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
|
238
|
205
|
--
|
239
|
206
|
|
240
|
|
-ALTER TABLE ONLY luticate_users_groups
|
241
|
|
- ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id);
|
|
207
|
+ALTER TABLE ONLY luticate_permissions_groups
|
|
208
|
+ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
|
242
|
209
|
|
243
|
210
|
|
244
|
211
|
--
|
245
|
212
|
-- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
|
246
|
213
|
--
|
247
|
214
|
|
248
|
|
-ALTER TABLE ONLY luticate_permissions_groups
|
249
|
|
- ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id);
|
|
215
|
+ALTER TABLE ONLY luticate_users_groups
|
|
216
|
+ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
|
250
|
217
|
|
251
|
218
|
|
252
|
219
|
--
|
|
@@ -254,7 +221,7 @@ ALTER TABLE ONLY luticate_permissions_groups
|
254
|
221
|
--
|
255
|
222
|
|
256
|
223
|
ALTER TABLE ONLY luticate_permissions_groups
|
257
|
|
- ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name);
|
|
224
|
+ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
|
258
|
225
|
|
259
|
226
|
|
260
|
227
|
--
|
|
@@ -262,15 +229,7 @@ ALTER TABLE ONLY luticate_permissions_groups
|
262
|
229
|
--
|
263
|
230
|
|
264
|
231
|
ALTER TABLE ONLY luticate_permissions_users
|
265
|
|
- ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name);
|
266
|
|
-
|
267
|
|
-
|
268
|
|
---
|
269
|
|
---
|
270
|
|
-
|
271
|
|
-ALTER TABLE ONLY luticate_users_groups
|
272
|
|
- ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id);
|
|
232
|
+ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
|
273
|
233
|
|
274
|
234
|
|
275
|
235
|
--
|
|
@@ -278,20 +237,16 @@ ALTER TABLE ONLY luticate_users_groups
|
278
|
237
|
--
|
279
|
238
|
|
280
|
239
|
ALTER TABLE ONLY luticate_permissions_users
|
281
|
|
- ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id);
|
|
240
|
+ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
|
282
|
241
|
|
283
|
242
|
|
284
|
243
|
--
|
|
244
|
+-- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: dev
|
285
|
245
|
--
|
286
|
246
|
|
287
|
|
-REVOKE ALL ON SCHEMA public FROM PUBLIC;
|
288
|
|
-REVOKE ALL ON SCHEMA public FROM postgres;
|
289
|
|
-GRANT ALL ON SCHEMA public TO postgres;
|
290
|
|
-GRANT ALL ON SCHEMA public TO PUBLIC;
|
291
|
|
-
|
|
247
|
+ALTER TABLE ONLY luticate_users_groups
|
|
248
|
+ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
|
292
|
249
|
|
293
|
250
|
--
|
294
|
251
|
-- PostgreSQL database dump complete
|
295
|
252
|
--
|
296
|
|
-
|