-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_platform.sql
More file actions
512 lines (404 loc) · 14.9 KB
/
Copy pathinit_platform.sql
File metadata and controls
512 lines (404 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE EXTENSION IF NOT EXISTS "citext";
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS dblink;
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS ltree;
SET default_tablespace = '';
CREATE TABLE public.comments (
id integer NOT NULL,
contributor uuid,
doctype character varying(19),
docid integer,
date timestamp with time zone DEFAULT now() NOT NULL,
message text,
source integer
);
CREATE SEQUENCE public.comments_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id;
CREATE TABLE public.engagement (
id integer NOT NULL,
contributor uuid,
doctype character varying(19),
docid integer,
type character varying(19),
date timestamp with time zone DEFAULT now() NOT NULL,
message text
);
CREATE SEQUENCE public.engagement_id_seq1
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.engagement_id_seq1 OWNED BY public.engagement.id;
CREATE TABLE public.files (
id integer NOT NULL,
name character varying(99),
path text,
vignette text,
full_text text,
sdgs jsonb,
tags jsonb,
status integer DEFAULT 1,
date timestamp with time zone DEFAULT now() NOT NULL,
update_at timestamp with time zone DEFAULT now() NOT NULL,
owner uuid,
published boolean DEFAULT false,
source integer
);
CREATE SEQUENCE public.files_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.files_id_seq OWNED BY public.files.id;
CREATE TABLE public.locations (
id integer NOT NULL,
pad integer,
lat double precision,
lng double precision,
iso3 character varying(3)
);
CREATE SEQUENCE public.locations_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.locations_id_seq OWNED BY public.locations.id;
CREATE TABLE public.metafields (
id integer NOT NULL,
pad integer,
type character varying(19),
name public.citext,
value text,
key integer
);
CREATE SEQUENCE public.metafields_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.metafields_id_seq OWNED BY public.metafields.id;
CREATE TABLE public.mobilization_contributions (
id integer NOT NULL,
pad integer,
mobilization integer
);
CREATE SEQUENCE public.mobilization_contributions_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.mobilization_contributions_id_seq OWNED BY public.mobilization_contributions.id;
CREATE TABLE public.mobilization_contributors (
id integer NOT NULL,
mobilization integer,
participant uuid
);
CREATE SEQUENCE public.mobilization_contributors_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.mobilization_contributors_id_seq OWNED BY public.mobilization_contributors.id;
CREATE TABLE public.mobilizations (
id integer NOT NULL,
title character varying(99),
template integer,
status integer DEFAULT 1,
start_date timestamp with time zone DEFAULT now() NOT NULL,
end_date timestamp with time zone,
owner uuid,
source integer,
copy boolean DEFAULT false,
pad_limit integer DEFAULT 0,
public boolean DEFAULT false,
child boolean DEFAULT false,
description text,
language character varying(9),
old_collection integer,
version public.ltree,
collection integer
);
CREATE SEQUENCE public.mobilizations_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.mobilizations_id_seq OWNED BY public.mobilizations.id;
CREATE TABLE public.pads (
id integer NOT NULL,
title character varying(99),
full_text text,
status integer DEFAULT 0,
date timestamp with time zone DEFAULT now() NOT NULL,
template integer,
owner uuid,
sections jsonb,
update_at timestamp with time zone DEFAULT now() NOT NULL,
source integer,
version public.ltree
);
CREATE SEQUENCE public.pads_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.pads_id_seq OWNED BY public.pads.id;
CREATE SEQUENCE public.pinboard_contributions_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE SEQUENCE public.pinboard_contributors_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE SEQUENCE public.pinboards_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE public.review_requests (
id integer NOT NULL,
pad integer NOT NULL,
language character varying(9),
status integer DEFAULT 0,
date timestamp with time zone DEFAULT now() NOT NULL
);
CREATE SEQUENCE public.review_requests_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.review_requests_id_seq OWNED BY public.review_requests.id;
CREATE TABLE public.review_templates (
id integer NOT NULL,
template integer NOT NULL,
language character varying(9)
);
CREATE SEQUENCE public.review_templates_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.review_templates_id_seq OWNED BY public.review_templates.id;
CREATE TABLE public.reviewer_pool (
id integer NOT NULL,
reviewer uuid,
request integer,
rank integer DEFAULT 0,
status integer DEFAULT 0,
invited_at timestamp with time zone DEFAULT now() NOT NULL
);
CREATE SEQUENCE public.reviewer_pool_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.reviewer_pool_id_seq OWNED BY public.reviewer_pool.id;
CREATE TABLE public.reviews (
id integer NOT NULL,
pad integer,
review integer,
reviewer uuid,
status integer DEFAULT 0
);
CREATE SEQUENCE public.reviews_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.reviews_id_seq OWNED BY public.reviews.id;
CREATE TABLE public.session (
sid character varying NOT NULL,
sess json NOT NULL,
expire timestamp(6) without time zone NOT NULL
);
CREATE TABLE public.tagging (
id integer NOT NULL,
pad integer,
tag_id integer NOT NULL,
type character varying(19)
);
CREATE SEQUENCE public.tagging_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.tagging_id_seq OWNED BY public.tagging.id;
CREATE TABLE public.templates (
id integer NOT NULL,
medium character varying(9),
title character varying(99),
description text,
items jsonb,
language character varying(9),
date timestamp with time zone DEFAULT now() NOT NULL,
full_text text,
status integer DEFAULT 0,
imported boolean DEFAULT false,
owner uuid,
sections jsonb,
update_at timestamp with time zone DEFAULT now() NOT NULL,
source integer,
slideshow boolean DEFAULT false,
version public.ltree
);
CREATE SEQUENCE public.templates_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.templates_id_seq OWNED BY public.templates.id;
ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.comments_id_seq'::regclass);
ALTER TABLE ONLY public.engagement ALTER COLUMN id SET DEFAULT nextval('public.engagement_id_seq1'::regclass);
ALTER TABLE ONLY public.files ALTER COLUMN id SET DEFAULT nextval('public.files_id_seq'::regclass);
ALTER TABLE ONLY public.locations ALTER COLUMN id SET DEFAULT nextval('public.locations_id_seq'::regclass);
ALTER TABLE ONLY public.metafields ALTER COLUMN id SET DEFAULT nextval('public.metafields_id_seq'::regclass);
ALTER TABLE ONLY public.mobilization_contributions ALTER COLUMN id SET DEFAULT nextval('public.mobilization_contributions_id_seq'::regclass);
ALTER TABLE ONLY public.mobilization_contributors ALTER COLUMN id SET DEFAULT nextval('public.mobilization_contributors_id_seq'::regclass);
ALTER TABLE ONLY public.mobilizations ALTER COLUMN id SET DEFAULT nextval('public.mobilizations_id_seq'::regclass);
ALTER TABLE ONLY public.pads ALTER COLUMN id SET DEFAULT nextval('public.pads_id_seq'::regclass);
ALTER TABLE ONLY public.review_requests ALTER COLUMN id SET DEFAULT nextval('public.review_requests_id_seq'::regclass);
ALTER TABLE ONLY public.review_templates ALTER COLUMN id SET DEFAULT nextval('public.review_templates_id_seq'::regclass);
ALTER TABLE ONLY public.reviewer_pool ALTER COLUMN id SET DEFAULT nextval('public.reviewer_pool_id_seq'::regclass);
ALTER TABLE ONLY public.reviews ALTER COLUMN id SET DEFAULT nextval('public.reviews_id_seq'::regclass);
ALTER TABLE ONLY public.tagging ALTER COLUMN id SET DEFAULT nextval('public.tagging_id_seq'::regclass);
ALTER TABLE ONLY public.templates ALTER COLUMN id SET DEFAULT nextval('public.templates_id_seq'::regclass);
ALTER TABLE ONLY public.comments
ADD CONSTRAINT comments_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.engagement
ADD CONSTRAINT engagement_pkey1 PRIMARY KEY (id);
ALTER TABLE ONLY public.files
ADD CONSTRAINT files_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.locations
ADD CONSTRAINT locations_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.metafields
ADD CONSTRAINT metafields_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.mobilization_contributions
ADD CONSTRAINT mobilization_contributions_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.mobilization_contributors
ADD CONSTRAINT mobilization_contributors_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.mobilizations
ADD CONSTRAINT mobilizations_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.metafields
ADD CONSTRAINT pad_value_type UNIQUE (pad, value, type);
ALTER TABLE ONLY public.pads
ADD CONSTRAINT pads_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.review_requests
ADD CONSTRAINT review_requests_pad_key UNIQUE (pad);
ALTER TABLE ONLY public.review_requests
ADD CONSTRAINT review_requests_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.review_templates
ADD CONSTRAINT review_templates_language_key UNIQUE (language);
ALTER TABLE ONLY public.review_templates
ADD CONSTRAINT review_templates_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.reviewer_pool
ADD CONSTRAINT reviewer_pool_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.reviews
ADD CONSTRAINT reviews_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.session
ADD CONSTRAINT session_pkey PRIMARY KEY (sid);
ALTER TABLE ONLY public.tagging
ADD CONSTRAINT tagging_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.templates
ADD CONSTRAINT templates_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.engagement
ADD CONSTRAINT unique_engagement UNIQUE (contributor, doctype, docid, type);
ALTER TABLE ONLY public.locations
ADD CONSTRAINT unique_pad_lnglat UNIQUE (pad, lng, lat);
ALTER TABLE ONLY public.tagging
ADD CONSTRAINT unique_pad_tag_type UNIQUE (pad, tag_id, type);
ALTER TABLE ONLY public.reviewer_pool
ADD CONSTRAINT unique_reviewer_pad UNIQUE (reviewer, request);
CREATE INDEX "IDX_session_expire" ON public.session USING btree (expire);
CREATE INDEX version_idx ON public.pads USING gist (version);
ALTER TABLE ONLY public.comments
ADD CONSTRAINT comments_source_fkey FOREIGN KEY (source) REFERENCES public.comments(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.files
ADD CONSTRAINT files_source_fkey FOREIGN KEY (source) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.locations
ADD CONSTRAINT locations_pad_fkey FOREIGN KEY (pad) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.metafields
ADD CONSTRAINT metafields_pad_fkey FOREIGN KEY (pad) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.mobilization_contributions
ADD CONSTRAINT mobilization_contributions_mobilization_fkey FOREIGN KEY (mobilization) REFERENCES public.mobilizations(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.mobilization_contributions
ADD CONSTRAINT mobilization_contributions_pad_fkey FOREIGN KEY (pad) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.mobilization_contributors
ADD CONSTRAINT mobilization_contributors_mobilization_fkey FOREIGN KEY (mobilization) REFERENCES public.mobilizations(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.mobilizations
ADD CONSTRAINT mobilizations_source_fkey FOREIGN KEY (source) REFERENCES public.mobilizations(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.mobilizations
ADD CONSTRAINT mobilizations_template_fkey FOREIGN KEY (template) REFERENCES public.templates(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.pads
ADD CONSTRAINT pads_source_fkey FOREIGN KEY (source) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.pads
ADD CONSTRAINT pads_template_fkey FOREIGN KEY (template) REFERENCES public.templates(id);
ALTER TABLE ONLY public.review_requests
ADD CONSTRAINT review_requests_pad_fkey FOREIGN KEY (pad) REFERENCES public.pads(id);
ALTER TABLE ONLY public.review_templates
ADD CONSTRAINT review_templates_template_fkey FOREIGN KEY (template) REFERENCES public.templates(id);
ALTER TABLE ONLY public.reviewer_pool
ADD CONSTRAINT reviewer_pool_request_fkey FOREIGN KEY (request) REFERENCES public.review_requests(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.reviews
ADD CONSTRAINT reviews_pad_fkey FOREIGN KEY (pad) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.reviews
ADD CONSTRAINT reviews_review_fkey FOREIGN KEY (review) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.tagging
ADD CONSTRAINT tagging_pad_fkey FOREIGN KEY (pad) REFERENCES public.pads(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.templates
ADD CONSTRAINT templates_source_fkey FOREIGN KEY (source) REFERENCES public.templates(id) ON UPDATE CASCADE ON DELETE CASCADE;