2 DROP TABLE role_setting ;
5 DROP VIEW artifact_group_list_vw;
6 CREATE VIEW artifact_group_list_vw AS
7 SELECT agl.group_artifact_id, agl.group_id, agl.name, agl.description,
8 agl.email_all_updates, agl.email_address,
9 agl.due_period, agl.submit_instructions, agl.browse_instructions,
10 agl.browse_list, agl.datatype, agl.status_timeout, agl.custom_status_field,
11 agl.custom_renderer, aca.count, aca.open_count
12 FROM artifact_group_list agl
13 LEFT JOIN artifact_counts_agg aca USING (group_artifact_id);
15 CREATE OR REPLACE FUNCTION tmp_migrate_tracker_allow_anon_to_rbac () RETURNS integer AS $$
17 agl artifact_group_list%ROWTYPE ;
20 UPDATE pfo_role_setting SET perm_val = perm_val|8 WHERE perm_val > 0 AND role_id != 1 AND (section_name = 'tracker' OR section_name = 'new_tracker');
21 FOR agl IN SELECT * FROM artifact_group_list WHERE allow_anon = 1
23 tid = agl.group_artifact_id ;
24 UPDATE pfo_role_setting SET perm_val = perm_val|8 WHERE perm_val > 0 AND role_id = 1 AND section_name = 'tracker' AND ref_id = tid;
30 SELECT tmp_migrate_tracker_allow_anon_to_rbac ();
32 DROP FUNCTION tmp_migrate_tracker_allow_anon_to_rbac () ;
34 ALTER TABLE artifact_group_list DROP COLUMN is_public;
35 ALTER TABLE artifact_group_list DROP COLUMN allow_anon;
37 DROP VIEW forum_group_list_vw;
38 CREATE VIEW forum_group_list_vw AS
39 SELECT forum_group_list.group_forum_id, forum_group_list.group_id, forum_group_list.forum_name, forum_group_list.description, forum_group_list.send_all_posts_to, forum_agg_msg_count.count AS total, (SELECT max(forum.post_date) AS recent FROM forum WHERE (forum.group_forum_id = forum_group_list.group_forum_id)) AS recent, (SELECT count(*) AS count FROM (SELECT forum.thread_id FROM forum WHERE (forum.group_forum_id = forum_group_list.group_forum_id) GROUP BY forum.thread_id) tmp) AS threads FROM (forum_group_list LEFT JOIN forum_agg_msg_count USING (group_forum_id));
41 DROP TRIGGER IF EXISTS fmsg_agg_trig ON forum;
42 DROP TRIGGER IF EXISTS fora_agg_trig ON forum_group_list;
44 CREATE OR REPLACE FUNCTION project_sums () RETURNS TRIGGER AS $$
51 --- Get number of things this group has now
53 IF TG_ARGV[0]='surv' THEN
54 IF TG_OP='DELETE' THEN
55 SELECT INTO num count(*) FROM surveys WHERE OLD.group_id=group_id AND is_active=1;
56 curr_group := OLD.group_id;
58 SELECT INTO num count(*) FROM surveys WHERE NEW.group_id=group_id AND is_active=1;
59 curr_group := NEW.group_id;
62 IF TG_ARGV[0]='mail' THEN
63 IF TG_OP='DELETE' THEN
64 SELECT INTO num count(*) FROM mail_group_list WHERE OLD.group_id=group_id AND is_public=1;
65 curr_group := OLD.group_id;
67 SELECT INTO num count(*) FROM mail_group_list WHERE NEW.group_id=group_id AND is_public=1;
68 curr_group := NEW.group_id;
72 --- See if this group already has a row in project_sums_agg for these things
74 SELECT INTO found count(group_id) FROM project_sums_agg WHERE curr_group=group_id AND type=TG_ARGV[0];
78 --- Create row for this group
80 INSERT INTO project_sums_agg
81 VALUES (curr_group, TG_ARGV[0], num);
86 UPDATE project_sums_agg SET count=num
87 WHERE curr_group=group_id AND type=TG_ARGV[0];
90 IF TG_OP='DELETE' THEN
97 DELETE FROM project_sums_agg WHERE type='fora' OR type='fmsg';
99 ALTER TABLE forum_group_list DROP COLUMN is_public;
100 ALTER TABLE forum_group_list DROP COLUMN allow_anonymous;
101 ALTER TABLE forum_group_list DROP COLUMN moderation_level;
103 DROP VIEW project_group_list_vw;
104 ALTER TABLE project_group_list DROP COLUMN is_public;
105 CREATE VIEW project_group_list_vw AS SELECT * FROM project_group_list NATURAL JOIN project_counts_agg;
107 ALTER TABLE groups DROP COLUMN is_public;
108 ALTER TABLE groups DROP COLUMN enable_anonscm;
109 -- ALTER TABLE groups DROP COLUMN enable_pserver;
111 DROP SEQUENCE foundry_news_pk_seq;