-
Notifications
You must be signed in to change notification settings - Fork 24
/
021-list-experiences.sql
38 lines (27 loc) · 1.21 KB
/
021-list-experiences.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
-- https://github.com/scalableminds/webknossos/pull/3060
START TRANSACTION;
CREATE TABLE webknossos.experienceDomains(
domain VARCHAR(256) PRIMARY KEY
);
INSERT INTO webknossos.experienceDomains(domain) SELECT neededExperience_domain FROM webknossos.tasks_ ON CONFLICT DO NOTHING;
INSERT INTO webknossos.experienceDomains(domain) SELECT domain FROM webknossos.user_experiences ON CONFLICT DO NOTHING;
CREATE FUNCTION webknossos.onInsertTask() RETURNS trigger AS $$
BEGIN
INSERT INTO webknossos.experienceDomains(domain) values(NEW.neededExperience_domain) ON CONFLICT DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION webknossos.onInsertUserExperience() RETURNS trigger AS $$
BEGIN
INSERT INTO webknossos.experienceDomains(domain) values(NEW.domain) ON CONFLICT DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER onDeleteAnnotationTrigger
AFTER INSERT ON webknossos.tasks
FOR EACH ROW EXECUTE PROCEDURE webknossos.onInsertTask();
CREATE TRIGGER onInsertUserExperienceTrigger
AFTER INSERT ON webknossos.user_experiences
FOR EACH ROW EXECUTE PROCEDURE webknossos.onInsertUserExperience();
UPDATE webknossos.releaseInformation SET schemaVersion = 21;
COMMIT TRANSACTION;