summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-10-09 08:52:32 +0200
committerYorhel <git@yorhel.nl>2009-10-09 08:52:32 +0200
commitd96c546f8beb1fdc79847b462f46ced9332e4c48 (patch)
tree7d0bcf2c1be46e4a1dd53dbf718905c821e79e48 /util
parent4304d30193646fdecbe2fcd081cfbce46ad82ed6 (diff)
SQL: Converted releases_media.medium to an ENUM type
Diffstat (limited to 'util')
-rw-r--r--util/dump.sql5
-rw-r--r--util/updates/update_2.8.sql7
2 files changed, 10 insertions, 2 deletions
diff --git a/util/dump.sql b/util/dump.sql
index 7a621103..b43d8c62 100644
--- a/util/dump.sql
+++ b/util/dump.sql
@@ -5,8 +5,9 @@ CREATE LANGUAGE plpgsql;
-- data types
-CREATE TYPE vn_relation AS ENUM ('seq', 'preq', 'set', 'alt', 'char', 'side', 'par', 'ser', 'fan', 'orig');
CREATE TYPE anime_type AS ENUM ('tv', 'ova', 'mov', 'oth', 'web', 'spe', 'mv');
+CREATE TYPE medium AS ENUM ('cd', 'dvd', 'gdr', 'blr', 'flp', 'mrt', 'mem', 'umd', 'nod', 'in', 'otc');
+CREATE TYPE vn_relation AS ENUM ('seq', 'preq', 'set', 'alt', 'char', 'side', 'par', 'ser', 'fan', 'orig');
-----------------------------------------
@@ -86,7 +87,7 @@ CREATE TABLE releases_lang (
-- releases_media
CREATE TABLE releases_media (
rid integer NOT NULL DEFAULT 0,
- medium character(3) NOT NULL DEFAULT '',
+ medium medium NOT NULL,
qty smallint NOT NULL DEFAULT 1,
PRIMARY KEY(rid, medium, qty)
);
diff --git a/util/updates/update_2.8.sql b/util/updates/update_2.8.sql
index e72af294..df5221ee 100644
--- a/util/updates/update_2.8.sql
+++ b/util/updates/update_2.8.sql
@@ -47,3 +47,10 @@ ALTER TABLE anime ALTER COLUMN type TYPE anime_type USING
ELSE NULL
END;
+
+-- Release media stored as enum
+CREATE TYPE medium AS ENUM ('cd', 'dvd', 'gdr', 'blr', 'flp', 'mrt', 'mem', 'umd', 'nod', 'in', 'otc');
+ALTER TABLE releases_media ALTER COLUMN medium DROP DEFAULT;
+ALTER TABLE releases_media ALTER COLUMN medium TYPE medium USING TRIM(both ' ' from medium)::medium;
+
+