forked from ProjectSidewalk/SidewalkWebpageDC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8.sql
59 lines (50 loc) · 1.72 KB
/
8.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
# --- !Ups
INSERT INTO role (role_id, role) VALUES (5, 'Owner');
INSERT INTO user_role (user_id, role_id) VALUES
('49787727-e427-4835-a153-9af6a83d1ed1', 5);
UPDATE role SET role = 'Turker' WHERE role_id = 2;
UPDATE role SET role = 'Administrator' WHERE role_id = 4;
UPDATE user_role SET role_id = 0 WHERE role_id = 2;
UPDATE user_role SET role_id = 2 WHERE role_id = 4;
UPDATE user_role SET role_id = 4 WHERE role_id = 0;
DELETE FROM user_role WHERE user_id IN (
SELECT user_id FROM user_role WHERE role_id = 5
) AND role_id < 5;
DELETE FROM user_role WHERE user_id IN (
SELECT user_id FROM user_role WHERE role_id = 4
) AND role_id < 4;
DELETE FROM user_role WHERE user_id IN (
SELECT user_id FROM user_role WHERE role_id = 3
) AND role_id < 3;
DELETE FROM user_role WHERE user_id IN (
SELECT user_id FROM user_role WHERE role_id = 2
) AND role_id < 2;
# --- !Downs
INSERT INTO user_role (user_id, role_id)
SELECT user_id, 1
FROM (
SELECT user_id, role_id
FROM user_role
WHERE role_id > 2
) researchers_to_owner;
INSERT INTO user_role (user_id, role_id)
SELECT user_id, 3
FROM (
SELECT user_id, role_id
FROM user_role
WHERE role_id > 3
) admins_and_owner;
INSERT INTO user_role (user_id, role_id)
SELECT user_id, 4
FROM (
SELECT user_id, role_id
FROM user_role
WHERE role_id > 4
) owner;
DELETE FROM user_role WHERE role_id = 5;
UPDATE user_role SET role_id = 0 WHERE role_id = 2;
UPDATE user_role SET role_id = 2 WHERE role_id = 4;
UPDATE user_role SET role_id = 4 WHERE role_id = 0;
UPDATE role SET role = 'Administrator' WHERE role_id = 2;
UPDATE role SET role = 'Turker' WHERE role_id = 4;
DELETE FROM role WHERE role_id = 5;