-
Notifications
You must be signed in to change notification settings - Fork 383
/
upgrade-0.4.2-0.5.sql
719 lines (642 loc) · 35.5 KB
/
upgrade-0.4.2-0.5.sql
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
UPDATE "acl_board_links" SET "url" = '/boards/?/lists/?/cards/?/cards_users/?' WHERE "slug" = 'delete_card_user';
SELECT pg_catalog.setval('acl_board_links_boards_user_roles_seq', (SELECT MAX(id) FROM acl_board_links_boards_user_roles), true);
delete from settings where name='STANDARD_LOGIN_ENABLED';
INSERT INTO "acl_board_links" ("id", "created", "modified", "name", "url", "method", "slug", "group_id", "is_hide") values ('62', 'now()', 'now()', 'Labels edit', '/labels/?', 'PUT', 'edit_labels', '4', '1');
INSERT INTO "acl_board_links_boards_user_roles" ("id", "created", "modified", "acl_board_link_id", "board_user_role_id") values ('129', 'now()', 'now()', '62', '1');
INSERT INTO "acl_board_links_boards_user_roles" ("id", "created", "modified", "acl_board_link_id", "board_user_role_id") values ('130', 'now()', 'now()', '62', '2');
ALTER TABLE "labels" ADD "color" character varying NULL; COMMENT ON TABLE "labels" IS '';
CREATE OR REPLACE VIEW "cards_labels_listing" AS
SELECT cl.id,
to_char(cl.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(cl.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
cl.label_id,
cl.card_id,
c.name AS card_name,
c.list_id,
l.name,
cl.board_id,
l.color
FROM ((cards_labels cl
LEFT JOIN cards c ON ((c.id = cl.card_id)))
LEFT JOIN labels l ON ((l.id = cl.label_id)));
ALTER TABLE "cards"
ADD "color" character varying(255) NULL;
COMMENT ON TABLE "cards" IS '';
ALTER TABLE "lists"
ADD "color" character varying(255) NULL;
COMMENT ON TABLE "lists" IS '';
DROP VIEW "organizations_listing";
DROP VIEW "boards_listing";
DROP VIEW "lists_listing";
DROP VIEW "cards_listing";
CREATE OR REPLACE VIEW cards_listing AS
SELECT cards.id,
to_char(cards.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(cards.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
cards.board_id,
cards.list_id,
cards.name,
cards.description,
to_char(cards.due_date, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS due_date,
to_date(to_char(cards.due_date, 'YYYY/MM/DD'::text), 'YYYY/MM/DD'::text) AS to_date,
cards."position",
(cards.is_archived)::integer AS is_archived,
cards.attachment_count,
cards.checklist_count,
cards.checklist_item_count,
cards.checklist_item_completed_count,
cards.label_count,
cards.cards_user_count,
cards.cards_subscriber_count,
cards.card_voter_count,
cards.activity_count,
cards.user_id,
cards.name AS title,
cards.due_date AS start,
cards.due_date AS "end",
( SELECT array_to_json(array_agg(row_to_json(cc.*))) AS array_to_json
FROM ( SELECT checklists_listing.id,
checklists_listing.created,
checklists_listing.modified,
checklists_listing.user_id,
checklists_listing.card_id,
checklists_listing.name,
checklists_listing.checklist_item_count,
checklists_listing.checklist_item_completed_count,
checklists_listing."position",
checklists_listing.checklists_items
FROM checklists_listing checklists_listing
WHERE (checklists_listing.card_id = cards.id)
ORDER BY checklists_listing.id) cc) AS cards_checklists,
( SELECT array_to_json(array_agg(row_to_json(cc.*))) AS array_to_json
FROM ( SELECT cards_users_listing.username,
cards_users_listing.profile_picture_path,
cards_users_listing.id,
cards_users_listing.created,
cards_users_listing.modified,
cards_users_listing.card_id,
cards_users_listing.user_id,
cards_users_listing.initials,
cards_users_listing.full_name,
cards_users_listing.email
FROM cards_users_listing cards_users_listing
WHERE (cards_users_listing.card_id = cards.id)
ORDER BY cards_users_listing.id) cc) AS cards_users,
( SELECT array_to_json(array_agg(row_to_json(cv.*))) AS array_to_json
FROM ( SELECT card_voters_listing.id,
card_voters_listing.created,
card_voters_listing.modified,
card_voters_listing.user_id,
card_voters_listing.card_id,
card_voters_listing.username,
card_voters_listing.role_id,
card_voters_listing.profile_picture_path,
card_voters_listing.initials,
card_voters_listing.full_name
FROM card_voters_listing card_voters_listing
WHERE (card_voters_listing.card_id = cards.id)
ORDER BY card_voters_listing.id) cv) AS cards_voters,
( SELECT array_to_json(array_agg(row_to_json(cs.*))) AS array_to_json
FROM ( SELECT cards_subscribers.id,
to_char(cards_subscribers.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(cards_subscribers.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
cards_subscribers.card_id,
cards_subscribers.user_id,
(cards_subscribers.is_subscribed)::integer AS is_subscribed
FROM card_subscribers cards_subscribers
WHERE (cards_subscribers.card_id = cards.id)
ORDER BY cards_subscribers.id) cs) AS cards_subscribers,
( SELECT array_to_json(array_agg(row_to_json(cl.*))) AS array_to_json
FROM ( SELECT cards_labels.label_id,
cards_labels.card_id,
cards_labels.list_id,
cards_labels.board_id,
cards_labels.name,
cards_labels.color
FROM cards_labels_listing cards_labels
WHERE (cards_labels.card_id = cards.id)
ORDER BY cards_labels.name) cl) AS cards_labels,
cards.comment_count,
u.username,
b.name AS board_name,
l.name AS list_name,
cards.custom_fields,
cards.color,
cards.due_date AS notification_due_date
FROM (((cards cards
LEFT JOIN users u ON ((u.id = cards.user_id)))
LEFT JOIN boards b ON ((b.id = cards.board_id)))
LEFT JOIN lists l ON ((l.id = cards.list_id)));
CREATE OR REPLACE VIEW lists_listing AS
SELECT lists.id,
to_char(lists.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(lists.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
lists.board_id,
lists.name,
lists."position",
(lists.is_archived)::integer AS is_archived,
lists.card_count,
lists.lists_subscriber_count,
( SELECT array_to_json(array_agg(row_to_json(lc.*))) AS array_to_json
FROM ( SELECT cards_listing.id,
cards_listing.created,
cards_listing.modified,
cards_listing.board_id,
cards_listing.list_id,
cards_listing.name,
cards_listing.description,
cards_listing.due_date,
cards_listing.to_date,
cards_listing."position",
((cards_listing.is_archived)::boolean)::integer AS is_archived,
cards_listing.attachment_count,
cards_listing.checklist_count,
cards_listing.checklist_item_count,
cards_listing.checklist_item_completed_count,
cards_listing.label_count,
cards_listing.cards_user_count,
cards_listing.cards_subscriber_count,
cards_listing.card_voter_count,
cards_listing.activity_count,
cards_listing.user_id,
cards_listing.title,
cards_listing.start,
cards_listing."end",
cards_listing.cards_checklists,
cards_listing.cards_users,
cards_listing.cards_voters,
cards_listing.cards_subscribers,
cards_listing.cards_labels,
cards_listing.comment_count,
cards_listing.custom_fields,
cards_listing.color
FROM cards_listing cards_listing
WHERE (cards_listing.list_id = lists.id)
ORDER BY cards_listing."position") lc) AS cards,
( SELECT array_to_json(array_agg(row_to_json(ls.*))) AS array_to_json
FROM ( SELECT lists_subscribers.id,
to_char(lists_subscribers.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(lists_subscribers.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
lists_subscribers.list_id,
lists_subscribers.user_id,
(lists_subscribers.is_subscribed)::integer AS is_subscribed
FROM list_subscribers lists_subscribers
WHERE (lists_subscribers.list_id = lists.id)
ORDER BY lists_subscribers.id) ls) AS lists_subscribers,
lists.custom_fields,
lists.color
FROM lists lists;
CREATE OR REPLACE VIEW boards_listing AS
SELECT board.id,
board.name,
to_char(board.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(board.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
users.username,
users.full_name,
users.profile_picture_path,
users.initials,
board.user_id,
board.organization_id,
board.board_visibility,
board.background_color,
board.background_picture_url,
board.commenting_permissions,
board.voting_permissions,
(board.is_closed)::integer AS is_closed,
(board.is_allow_organization_members_to_join)::integer AS is_allow_organization_members_to_join,
board.boards_user_count,
board.list_count,
board.card_count,
board.archived_list_count,
board.archived_card_count,
board.boards_subscriber_count,
board.background_pattern_url,
(board.is_show_image_front_of_card)::integer AS is_show_image_front_of_card,
board.music_name,
board.music_content,
organizations.name AS organization_name,
organizations.website_url AS organization_website_url,
organizations.description AS organization_description,
organizations.logo_url AS organization_logo_url,
organizations.organization_visibility,
( SELECT array_to_json(array_agg(row_to_json(ba.*))) AS array_to_json
FROM ( SELECT activities.id,
to_char(activities.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(activities.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
activities.board_id,
activities.list_id,
activities.card_id,
activities.user_id,
activities.foreign_id AS attachment_id,
activities.type,
activities.comment,
activities.revisions,
activities.root,
activities.freshness_ts,
activities.depth,
activities.path,
activities.materialized_path,
users_1.username,
users_1.role_id,
users_1.profile_picture_path,
users_1.initials
FROM (activities activities
LEFT JOIN users users_1 ON ((users_1.id = activities.user_id)))
WHERE (activities.board_id = board.id)
ORDER BY activities.freshness_ts DESC, activities.materialized_path
OFFSET 0
LIMIT 20) ba) AS activities,
( SELECT array_to_json(array_agg(row_to_json(bs.*))) AS array_to_json
FROM ( SELECT boards_subscribers.id,
to_char(boards_subscribers.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(boards_subscribers.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
boards_subscribers.board_id,
boards_subscribers.user_id,
(boards_subscribers.is_subscribed)::integer AS is_subscribed
FROM board_subscribers boards_subscribers
WHERE (boards_subscribers.board_id = board.id)
ORDER BY boards_subscribers.id) bs) AS boards_subscribers,
( SELECT array_to_json(array_agg(row_to_json(bs.*))) AS array_to_json
FROM ( SELECT boards_stars.id,
to_char(boards_stars.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(boards_stars.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
boards_stars.created,
boards_stars.modified,
boards_stars.board_id,
boards_stars.user_id,
(boards_stars.is_starred)::integer AS is_starred
FROM board_stars boards_stars
WHERE (boards_stars.board_id = board.id)
ORDER BY boards_stars.id) bs(id, created, modified, created_1, modified_1, board_id, user_id, is_starred)) AS boards_stars,
( SELECT array_to_json(array_agg(row_to_json(batt.*))) AS array_to_json
FROM ( SELECT card_attachments.id,
to_char(card_attachments.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(card_attachments.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
card_attachments.card_id,
card_attachments.name,
card_attachments.path,
card_attachments.mimetype,
card_attachments.list_id,
card_attachments.board_id,
card_attachments.link
FROM card_attachments card_attachments
WHERE (card_attachments.board_id = board.id)
ORDER BY card_attachments.id DESC) batt) AS attachments,
( SELECT array_to_json(array_agg(row_to_json(bl.*))) AS array_to_json
FROM ( SELECT lists_listing.id,
lists_listing.created,
lists_listing.modified,
lists_listing.board_id,
lists_listing.name,
lists_listing."position",
((lists_listing.is_archived)::boolean)::integer AS is_archived,
lists_listing.card_count,
lists_listing.lists_subscriber_count,
lists_listing.cards,
lists_listing.lists_subscribers,
lists_listing.custom_fields,
lists_listing.color
FROM lists_listing lists_listing
WHERE (lists_listing.board_id = board.id)
ORDER BY lists_listing."position") bl) AS lists,
( SELECT array_to_json(array_agg(row_to_json(bu.*))) AS array_to_json
FROM ( SELECT boards_users.id,
boards_users.created,
boards_users.modified,
boards_users.board_id,
boards_users.user_id,
boards_users.board_user_role_id,
boards_users.username,
boards_users.email,
boards_users.full_name,
((boards_users.is_active)::boolean)::integer AS is_active,
((boards_users.is_email_confirmed)::boolean)::integer AS is_email_confirmed,
boards_users.board_name,
boards_users.profile_picture_path,
boards_users.initials
FROM boards_users_listing boards_users
WHERE (boards_users.board_id = board.id)
ORDER BY boards_users.id) bu) AS boards_users,
board.default_email_list_id,
board.is_default_email_position_as_bottom,
board.custom_fields
FROM ((boards board
LEFT JOIN users users ON ((users.id = board.user_id)))
LEFT JOIN organizations organizations ON ((organizations.id = board.organization_id)));
CREATE OR REPLACE VIEW organizations_listing AS
SELECT organizations.id,
to_char(organizations.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(organizations.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
organizations.user_id,
organizations.name,
organizations.website_url,
organizations.description,
organizations.logo_url,
organizations.organization_visibility,
organizations.organizations_user_count,
organizations.board_count,
( SELECT array_to_json(array_agg(row_to_json(b.*))) AS array_to_json
FROM ( SELECT boards_listing.id,
boards_listing.name,
boards_listing.user_id,
boards_listing.organization_id,
boards_listing.board_visibility,
boards_listing.background_color,
boards_listing.background_picture_url,
boards_listing.commenting_permissions,
boards_listing.voting_permissions,
((boards_listing.is_closed)::boolean)::integer AS is_closed,
((boards_listing.is_allow_organization_members_to_join)::boolean)::integer AS is_allow_organization_members_to_join,
boards_listing.boards_user_count,
boards_listing.list_count,
boards_listing.card_count,
boards_listing.boards_subscriber_count,
boards_listing.background_pattern_url,
((boards_listing.is_show_image_front_of_card)::boolean)::integer AS is_show_image_front_of_card,
boards_listing.organization_name,
boards_listing.organization_website_url,
boards_listing.organization_description,
boards_listing.organization_logo_url,
boards_listing.organization_visibility,
boards_listing.activities,
boards_listing.boards_subscribers,
boards_listing.boards_stars,
boards_listing.attachments,
boards_listing.lists,
boards_listing.boards_users
FROM boards_listing boards_listing
WHERE (boards_listing.organization_id = organizations.id)
ORDER BY boards_listing.id) b) AS boards_listing,
( SELECT array_to_json(array_agg(row_to_json(c.*))) AS array_to_json
FROM ( SELECT organizations_users_listing.id,
organizations_users_listing.created,
organizations_users_listing.modified,
organizations_users_listing.user_id,
organizations_users_listing.organization_id,
organizations_users_listing.organization_user_role_id,
organizations_users_listing.role_id,
organizations_users_listing.username,
organizations_users_listing.email,
organizations_users_listing.full_name,
organizations_users_listing.initials,
organizations_users_listing.about_me,
organizations_users_listing.created_organization_count,
organizations_users_listing.created_board_count,
organizations_users_listing.joined_organization_count,
organizations_users_listing.list_count,
organizations_users_listing.joined_card_count,
organizations_users_listing.created_card_count,
organizations_users_listing.joined_board_count,
organizations_users_listing.checklist_count,
organizations_users_listing.checklist_item_completed_count,
organizations_users_listing.checklist_item_count,
organizations_users_listing.activity_count,
organizations_users_listing.card_voter_count,
organizations_users_listing.name,
organizations_users_listing.website_url,
organizations_users_listing.description,
organizations_users_listing.logo_url,
organizations_users_listing.organization_visibility,
organizations_users_listing.profile_picture_path,
organizations_users_listing.boards_users,
organizations_users_listing.user_board_count
FROM organizations_users_listing organizations_users_listing
WHERE (organizations_users_listing.organization_id = organizations.id)
ORDER BY organizations_users_listing.id) c) AS organizations_users,
u.username,
u.full_name,
u.initials,
u.profile_picture_path
FROM (organizations organizations
LEFT JOIN users u ON ((u.id = organizations.user_id)));
DROP VIEW "cards_elasticsearch_listing";
CREATE OR REPLACE VIEW cards_elasticsearch_listing AS
SELECT card.id,
row_to_json(card.*) AS json
FROM ( SELECT cards.id,
cards.board_id,
boards.name AS board,
cards.list_id,
lists.name AS list,
cards.name,
cards.description,
to_char(cards.due_date, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS due_date,
to_char(cards.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(cards.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
(cards.is_archived)::integer AS is_archived,
cards.attachment_count,
cards.checklist_item_count,
cards.checklist_item_completed_count,
cards.card_voter_count,
cards.cards_user_count,
cards.color,
( SELECT array_to_json(array_agg(row_to_json(cc.*))) AS array_to_json
FROM ( SELECT boards_users.user_id
FROM boards_users boards_users
WHERE (boards_users.board_id = cards.board_id)
ORDER BY boards_users.id) cc) AS board_users,
( SELECT array_to_json(array_agg(row_to_json(cc.*))) AS array_to_json
FROM ( SELECT board_stars.user_id
FROM board_stars board_stars
WHERE (board_stars.board_id = cards.board_id)
ORDER BY board_stars.id) cc) AS board_stars,
( SELECT array_to_json(array_agg(row_to_json(cc.*))) AS array_to_json
FROM ( SELECT checklists.name,
checklist_items.name AS checklist_item_name
FROM (checklists checklists
LEFT JOIN checklist_items checklist_items ON ((checklist_items.checklist_id = checklists.id)))
WHERE (checklists.card_id = cards.id)
ORDER BY checklists.id) cc) AS cards_checklists,
( SELECT array_to_json(array_agg(row_to_json(cc.*))) AS array_to_json
FROM ( SELECT cards_users_listing.username,
cards_users_listing.user_id
FROM cards_users_listing cards_users_listing
WHERE (cards_users_listing.card_id = cards.id)
ORDER BY cards_users_listing.id) cc) AS cards_users,
( SELECT array_to_json(array_agg(row_to_json(cl.*))) AS array_to_json
FROM ( SELECT cards_labels.name
FROM cards_labels_listing cards_labels
WHERE (cards_labels.card_id = cards.id)
ORDER BY cards_labels.id) cl) AS cards_labels,
( SELECT array_to_json(array_agg(row_to_json(cl.*))) AS array_to_json
FROM ( SELECT activities.comment
FROM activities activities
WHERE (((activities.type)::text = 'add_comment'::text) AND (activities.card_id = cards.id))
ORDER BY activities.id) cl) AS activities
FROM ((cards cards
LEFT JOIN boards boards ON ((boards.id = cards.board_id)))
LEFT JOIN lists lists ON ((lists.id = cards.list_id)))
WHERE (boards.name IS NOT NULL)) card;
DROP VIEW "simple_board_listing";
CREATE OR REPLACE VIEW simple_board_listing AS
SELECT board.id,
board.name,
board.user_id,
board.organization_id,
board.board_visibility,
board.background_color,
board.background_picture_url,
board.commenting_permissions,
board.voting_permissions,
(board.is_closed)::integer AS is_closed,
(board.is_allow_organization_members_to_join)::integer AS is_allow_organization_members_to_join,
board.boards_user_count,
board.list_count,
board.card_count,
board.boards_subscriber_count,
board.background_pattern_url,
( SELECT array_to_json(array_agg(row_to_json(l.*))) AS array_to_json
FROM ( SELECT lists.id,
to_char(lists.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(lists.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
lists.board_id,
lists.user_id,
lists.name,
lists."position",
(lists.is_archived)::integer AS is_archived,
lists.card_count,
lists.lists_subscriber_count,
lists.color,
(lists.is_deleted)::integer AS is_deleted
FROM lists lists
WHERE (lists.board_id = board.id)
ORDER BY lists."position") l) AS lists,
( SELECT array_to_json(array_agg(row_to_json(l.*))) AS array_to_json
FROM ( SELECT cll.label_id,
cll.name
FROM cards_labels_listing cll
WHERE (cll.board_id = board.id)
ORDER BY cll.name) l) AS labels,
( SELECT array_to_json(array_agg(row_to_json(l.*))) AS array_to_json
FROM ( SELECT bs.id,
bs.board_id,
bs.user_id,
(bs.is_starred)::integer AS is_starred
FROM board_stars bs
WHERE (bs.board_id = board.id)
ORDER BY bs.id) l) AS stars,
org.name AS organization_name,
org.logo_url AS organization_logo_url,
board.music_content,
board.music_name
FROM (boards board
LEFT JOIN organizations org ON ((org.id = board.organization_id)))
ORDER BY board.name;
DROP VIEW "users_cards_listing";
CREATE OR REPLACE VIEW users_cards_listing AS
SELECT b.name AS board_name,
l.name AS list_name,
c.id,
to_char(c.created, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS created,
to_char(c.modified, 'YYYY-MM-DD"T"HH24:MI:SS'::text) AS modified,
c.board_id,
c.list_id,
c.name,
c.description,
c.due_date,
c."position",
(c.is_archived)::integer AS is_archived,
c.attachment_count,
c.checklist_count,
c.checklist_item_count,
c.checklist_item_completed_count,
c.label_count,
c.cards_user_count,
c.cards_subscriber_count,
c.card_voter_count,
c.activity_count,
c.user_id AS created_user_id,
c.color AS card_color,
(c.is_deleted)::integer AS is_deleted,
cu.user_id,
c.comment_count
FROM (((cards_users cu
JOIN cards c ON ((c.id = cu.card_id)))
JOIN boards b ON ((b.id = c.board_id)))
JOIN lists l ON ((l.id = c.list_id)));
INSERT INTO "acl_links" ("id", "created", "modified", "name", "url", "method", "slug", "group_id", "is_user_action", "is_guest_action", "is_admin_action", "is_hide") values (141, 'now()', 'now()', 'Labels Edit', '/labels/?', 'PUT', 'label_edit', '1', '0', '0', '1', '1');
INSERT INTO "acl_links_roles" ("created", "modified", "acl_link_id", "role_id")
VALUES (now(), now(), '141', '1'),
(now(), now(), '141', '2');
CREATE OR REPLACE FUNCTION update_board_user_count() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF (TG_OP = 'DELETE') THEN
UPDATE "boards" SET "boards_user_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "board_id" = OLD."board_id") t WHERE "id" = OLD."board_id";
UPDATE "users" SET "joined_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = OLD."user_id") t WHERE "id" = OLD."user_id";
UPDATE "users" SET "owner_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = OLD."user_id" AND "board_user_role_id" = 1) t WHERE "id" = OLD."user_id";
UPDATE "users" SET "member_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = OLD."user_id" AND "board_user_role_id" != 1) t WHERE "id" = OLD."user_id";
RETURN OLD;
ELSIF (TG_OP = 'UPDATE') THEN
UPDATE "boards" SET "boards_user_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "board_id" = OLD."board_id") t WHERE "id" = OLD."board_id";
UPDATE "users" SET "joined_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = OLD."user_id") t WHERE "id" = OLD."user_id";
UPDATE "users" SET "owner_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = OLD."user_id" AND "board_user_role_id" = 1) t WHERE "id" = OLD."user_id";
UPDATE "users" SET "member_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = OLD."user_id" AND "board_user_role_id" != 1) t WHERE "id" = OLD."user_id";
RETURN OLD;
ELSIF (TG_OP = 'INSERT') THEN
UPDATE "boards" SET "boards_user_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "board_id" = NEW."board_id") t WHERE "id" = NEW."board_id";
UPDATE "users" SET "joined_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = NEW."user_id") t WHERE "id" = NEW."user_id";
UPDATE "users" SET "owner_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = NEW."user_id" AND "board_user_role_id" = 1) t WHERE "id" = NEW."user_id";
UPDATE "users" SET "member_board_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "boards_users" WHERE "user_id" = NEW."user_id" AND "board_user_role_id" != 1) t WHERE "id" = NEW."user_id";
RETURN NEW;
END IF;
END;
$$;
--
-- Name: update_organization_user_count(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE OR REPLACE FUNCTION update_organization_user_count() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF (TG_OP = 'DELETE') THEN
UPDATE "organizations" SET "organizations_user_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "organization_id" = OLD."organization_id") t WHERE "id" = OLD."organization_id";
UPDATE "users" SET "joined_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = OLD."user_id") t WHERE "id" = OLD."user_id";
UPDATE "users" SET "owner_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = OLD."user_id" AND "organization_user_role_id" = 1) t WHERE "id" = OLD."user_id";
UPDATE "users" SET "member_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = OLD."user_id" AND "organization_user_role_id" != 1) t WHERE "id" = OLD."user_id";
RETURN OLD;
ELSIF (TG_OP = 'UPDATE') THEN
UPDATE "organizations" SET "organizations_user_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "organization_id" = OLD."organization_id") t WHERE "id" = OLD."organization_id";
UPDATE "users" SET "joined_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = OLD."user_id") t WHERE "id" = OLD."user_id";
UPDATE "users" SET "owner_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = OLD."user_id" AND "organization_user_role_id" = 1) t WHERE "id" = OLD."user_id";
UPDATE "users" SET "member_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = OLD."user_id" AND "organization_user_role_id" != 1) t WHERE "id" = OLD."user_id";
RETURN OLD;
ELSIF (TG_OP = 'INSERT') THEN
UPDATE "organizations" SET "organizations_user_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "organization_id" = NEW."organization_id") t WHERE "id" = NEW."organization_id";
UPDATE "users" SET "joined_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = NEW."user_id") t WHERE "id" = NEW."user_id";
UPDATE "users" SET "owner_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = NEW."user_id" AND "organization_user_role_id" = 1) t WHERE "id" = NEW."user_id";
UPDATE "users" SET "member_organization_count" = total_count FROM (SELECT COUNT(*) as total_count FROM "organizations_users" WHERE "user_id" = NEW."user_id" AND "organization_user_role_id" != 1) t WHERE "id" = NEW."user_id";
RETURN NEW;
END IF;
END;
$$;
DROP TRIGGER "update_comment_count" ON "activities";
DROP TRIGGER "update_card_activity_count" ON "activities";
UPDATE "email_templates" SET "email_text_content" = '<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body style="margin:0">
<header style="display:block;width:100%;padding-left:0;padding-right:0; border-bottom:solid 1px #dedede; float:left;background-color: #f7f7f7;">
<div style="border: 1px solid #EEEEEE;">
<h1 style="text-align:center;margin:10px 15px 5px;"> <a href="##SITE_URL##" title="Restyaboard"><img src="##SITE_URL##/img/logo.png" alt="[Restyaboard]" title="Restyaboard"></a> </h1>
</div>
</header>
<main style="width:100%;padding-top:10px; padding-bottom:10px; margin:0 auto; float:left;">
<div style="background-color:#f3f5f7;padding:10px;border: 1px solid #EEEEEE;">
<div style="width: 500px;background-color: #f3f5f7;margin:0 auto;">
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 13px;line-height:20px;margin-top:30px;"><h2 style="font-size:16px; font-family:Arial, Helvetica, sans-serif; margin: 7px 0px 0px 43px;padding:35px 0px 0px 0px;">Here''s what you missed...</h2>
<div style="white-space: normal; width: 100%;margin: 10px 0px 0px; font-family:Arial, Helvetica, sans-serif;">##CONTENT##</div>
</div>
</div>
</div>
<div style="text-align:center;margin:5px 15px;padding:10px 0px;">
<a href="##SITE_URL##/#/user/##USER_ID##/settings">Change email preferences</a>
</div>
</main>
<footer style="width:100%;padding-left:0;margin:0px auto;border-top: solid 1px #dedede; padding-bottom:10px; background:#fff;clear: both;padding-top: 10px;border-bottom: solid 1px #dedede;background-color: #f7f7f7;">
<h6 style="text-align:center;margin:5px 15px;">
<a href="http://restya.com/board/?utm_source=Restyaboard - ##SITE_NAME##&utm_medium=email&utm_campaign=notification_email" title="Open source. Trello like kanban board." rel="generator" style="font-size: 11px;text-align: center;text-decoration: none;color: #000;font-family: arial; padding-left:10px;">Powered by Restyaboard</a>
</h6>
</footer>
</body>
</html>' WHERE "name" = 'email_notification';