summaryrefslogtreecommitdiff
path: root/util/updates
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-05-03 09:23:04 +0200
committerYorhel <git@yorhel.nl>2015-05-03 09:23:06 +0200
commit39cbaf0cd0a6f1dc16aa56a2f82d8ecd08136212 (patch)
tree3f991b22318ade9a3804b98162adf189a0fb94cb /util/updates
parentfdda38d11baba8a24d97d4c19b75eee158666bfa (diff)
Remove "script" role from vn<->staff links
Note that it's still in the postgresql ENUM type. Removing that is possible, but not very trivial.
Diffstat (limited to 'util/updates')
-rw-r--r--util/updates/update_2.25.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/updates/update_2.25.sql b/util/updates/update_2.25.sql
index 5188cca2..f9168cf7 100644
--- a/util/updates/update_2.25.sql
+++ b/util/updates/update_2.25.sql
@@ -1,2 +1,14 @@
ALTER TYPE credit_type ADD VALUE 'scenario' BEFORE 'script';
+
+BEGIN;
+-- There are no entries in the database where a single aid has both a script
+-- and a staff role, and where a note has been associated with the script role.
+-- So this conversion does not attempt to merge notes when merging roles.
+UPDATE vn_staff vs SET role = 'staff', note = CASE WHEN note = '' THEN 'Scripting' ELSE note END
+ WHERE role = 'script' AND NOT EXISTS(SELECT 1 FROM vn_staff v2 where v2.vid = vs.vid AND v2.aid = vs.aid AND role = 'staff');
+UPDATE vn_staff vs SET note = CASE WHEN note = '' THEN 'Scripting' ELSE note || ', Scripting' END
+ WHERE role = 'staff' AND EXISTS(SELECT 1 FROM vn_staff v2 where v2.vid = vs.vid AND v2.aid = vs.aid AND role = 'script');
+DELETE FROM vn_staff WHERE role = 'script';
+COMMIT;
+