summaryrefslogtreecommitdiff
path: root/util/updates
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2014-10-13 10:24:01 +0200
committerYorhel <git@yorhel.nl>2014-10-13 10:24:01 +0200
commita1b4da1d3ae9e6ed9326df41f9831be81f6b839a (patch)
treef9a6aff31799cb4eaa5ddc133553b9cdf789bfbe /util/updates
parent26506d2bd7543aea1a4f49634be8b9bf110ad57c (diff)
SQL: Use enum to represent platforms
I believe I didn't do this conversion earlier (back when I converted the language types) because PostgreSQL didn't support dynamically adding new values to an existing enum back then, and modifying an enum was a huge pain. Recent versions do support this, so there's no reason to keep it as a string. ...I just felt like adding some churn to the code base.
Diffstat (limited to 'util/updates')
-rw-r--r--util/updates/update_2.23.sql9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/updates/update_2.23.sql b/util/updates/update_2.23.sql
index e3b32a11..f93b1480 100644
--- a/util/updates/update_2.23.sql
+++ b/util/updates/update_2.23.sql
@@ -83,3 +83,12 @@ CREATE TABLE login_throttle (
-- timeout is a timestamp...
ALTER TABLE login_throttle ALTER COLUMN timeout TYPE timestamptz USING to_timestamp(timeout);
+
+-- platform from varchar to enum
+CREATE TYPE platform AS ENUM ('win', 'dos', 'lin', 'mac', 'ios', 'and', 'dvd', 'bdp', 'gba', 'gbc', 'msx', 'nds', 'nes', 'p88', 'p98', 'pcf', 'psp', 'ps1', 'ps2', 'ps3', 'ps4', 'psv', 'drc', 'sat', 'sfc', 'wii', 'n3d', 'xb1', 'xb3', 'xbo', 'web', 'oth');
+ALTER TABLE releases_platforms ALTER COLUMN platform DROP DEFAULT;
+ALTER TABLE releases_platforms ALTER COLUMN platform TYPE platform USING platform::platform;
+
+ALTER TABLE vn ALTER COLUMN c_platforms DROP DEFAULT;
+ALTER TABLE vn ALTER COLUMN c_platforms TYPE platform[] USING string_to_array(c_platforms, '/')::platform[];
+ALTER TABLE vn ALTER COLUMN c_platforms SET DEFAULT '{}';