From 15382265b39f045fc5f20e9e676b24941da6bd63 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 11 Oct 2015 12:00:48 +0200 Subject: SQL: Convert producers_rev.type into enum Same reasoning as 19ce5fcf536ed478ad34b6b1014bf6f44841d25d --- util/sql/all.sql | 1 + util/sql/schema.sql | 2 +- util/updates/update_2.25.sql | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/util/sql/all.sql b/util/sql/all.sql index a1689149..91f58267 100644 --- a/util/sql/all.sql +++ b/util/sql/all.sql @@ -17,6 +17,7 @@ CREATE TYPE notification_ntype AS ENUM ('pm', 'dbdel', 'listdel', 'dbedit', 'ann CREATE TYPE notification_ltype AS ENUM ('v', 'r', 'p', 'c', 't', 's'); CREATE TYPE platform AS ENUM ('win', 'dos', 'lin', 'mac', 'ios', 'and', 'dvd', 'bdp', 'fmt', 'gba', 'gbc', 'msx', 'nds', 'nes', 'p88', 'p98', 'pce', 'pcf', 'psp', 'ps1', 'ps2', 'ps3', 'ps4', 'psv', 'drc', 'sat', 'sfc', 'wii', 'n3d', 'x68', 'xb1', 'xb3', 'xbo', 'web', 'oth'); CREATE TYPE prefs_key AS ENUM ('l10n', 'skin', 'customcss', 'filter_vn', 'filter_release', 'show_nsfw', 'hide_list', 'notify_nodbedit', 'notify_announce', 'vn_list_own', 'vn_list_wish', 'tags_all', 'tags_cat', 'spoilers', 'traits_sexual'); +CREATE TYPE producer_type AS ENUM ('co', 'in', 'ng'); CREATE TYPE producer_relation AS ENUM ('old', 'new', 'sub', 'par', 'imp', 'ipa', 'spa', 'ori'); CREATE TYPE release_type AS ENUM ('complete', 'partial', 'trial'); CREATE TYPE tag_category AS ENUM('cont', 'ero', 'tech'); diff --git a/util/sql/schema.sql b/util/sql/schema.sql index 8de05fde..3fba4342 100644 --- a/util/sql/schema.sql +++ b/util/sql/schema.sql @@ -127,7 +127,7 @@ CREATE TABLE producers_relations ( CREATE TABLE producers_rev ( id integer NOT NULL PRIMARY KEY, pid integer NOT NULL DEFAULT 0, - type character(2) NOT NULL DEFAULT 'co', + type producer_type NOT NULL DEFAULT 'co', name varchar(200) NOT NULL DEFAULT '', original varchar(200) NOT NULL DEFAULT '', website varchar(250) NOT NULL DEFAULT '', diff --git a/util/updates/update_2.25.sql b/util/updates/update_2.25.sql index 07275ae7..6302daaf 100644 --- a/util/updates/update_2.25.sql +++ b/util/updates/update_2.25.sql @@ -67,3 +67,10 @@ $$ LANGUAGE sql IMMUTABLE; -- Changes to search normalization UPDATE vn SET c_search = NULL; + + +-- Convert producers_rev.type to enum +CREATE TYPE producer_type AS ENUM ('co', 'in', 'ng'); +ALTER TABLE producers_rev ALTER COLUMN type DROP DEFAULT; +ALTER TABLE producers_rev ALTER COLUMN type TYPE producer_type USING type::producer_type; +ALTER TABLE producers_rev ALTER COLUMN type SET DEFAULT 'co'; -- cgit v1.2.3