summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-09-02 13:08:26 +0200
committerYorhel <git@yorhel.nl>2019-09-02 13:09:00 +0200
commit3540b91daae0be093f8fb8825c749be3ead1d8bb (patch)
tree794b2511e1b3d307006cd6790a2a7a9e6ff5e43e /util
parentb30d366002b2c34f4f756292872688c0b94fc16d (diff)
Allow multiple Gyutto & DMM links per release
To handle https://vndb.org/t12755.37
Diffstat (limited to 'util')
-rw-r--r--util/sql/schema.sql8
-rw-r--r--util/updates/update_20190902.sql12
2 files changed, 16 insertions, 4 deletions
diff --git a/util/sql/schema.sql b/util/sql/schema.sql
index 80008067..2983f290 100644
--- a/util/sql/schema.sql
+++ b/util/sql/schema.sql
@@ -296,13 +296,13 @@ CREATE TABLE releases ( -- dbentry_type=r
l_gog text NOT NULL DEFAULT '', -- [pub]
l_denpa text NOT NULL DEFAULT '', -- [pub]
l_jlist text NOT NULL DEFAULT '', -- [pub]
- l_gyutto integer NOT NULL DEFAULT 0, -- [pub]
+ l_gyutto integer[] NOT NULL DEFAULT '{}', -- [pub]
l_digiket integer NOT NULL DEFAULT 0, -- [pub]
l_melon integer NOT NULL DEFAULT 0, -- [pub]
l_mg integer NOT NULL DEFAULT 0, -- [pub]
l_getchu integer NOT NULL DEFAULT 0, -- [pub]
l_getchudl integer NOT NULL DEFAULT 0, -- [pub]
- l_dmm text NOT NULL DEFAULT '', -- [pub]
+ l_dmm text[] NOT NULL DEFAULT '{}', -- [pub]
l_itch text NOT NULL DEFAULT '', -- [pub]
l_jastusa text NOT NULL DEFAULT '', -- [pub]
l_egs integer NOT NULL DEFAULT 0, -- [pub]
@@ -336,13 +336,13 @@ CREATE TABLE releases_hist (
l_gog text NOT NULL DEFAULT '',
l_denpa text NOT NULL DEFAULT '',
l_jlist text NOT NULL DEFAULT '',
- l_gyutto integer NOT NULL DEFAULT 0,
+ l_gyutto integer[] NOT NULL DEFAULT '{}',
l_digiket integer NOT NULL DEFAULT 0,
l_melon integer NOT NULL DEFAULT 0,
l_mg integer NOT NULL DEFAULT 0,
l_getchu integer NOT NULL DEFAULT 0,
l_getchudl integer NOT NULL DEFAULT 0,
- l_dmm text NOT NULL DEFAULT '',
+ l_dmm text[] NOT NULL DEFAULT '{}',
l_itch text NOT NULL DEFAULT '',
l_jastusa text NOT NULL DEFAULT '',
l_egs integer NOT NULL DEFAULT 0,
diff --git a/util/updates/update_20190902.sql b/util/updates/update_20190902.sql
new file mode 100644
index 00000000..fbf24c44
--- /dev/null
+++ b/util/updates/update_20190902.sql
@@ -0,0 +1,12 @@
+ALTER TABLE releases ALTER COLUMN l_dmm DROP DEFAULT;
+ALTER TABLE releases ALTER COLUMN l_gyutto DROP DEFAULT;
+ALTER TABLE releases_hist ALTER COLUMN l_dmm DROP DEFAULT;
+ALTER TABLE releases_hist ALTER COLUMN l_gyutto DROP DEFAULT;
+ALTER TABLE releases ALTER COLUMN l_dmm TYPE text[] USING CASE WHEN l_dmm = '' THEN '{}' ELSE ARRAY[l_dmm ] END;
+ALTER TABLE releases ALTER COLUMN l_gyutto TYPE integer[] USING CASE WHEN l_gyutto = 0 THEN '{}' ELSE ARRAY[l_gyutto] END;
+ALTER TABLE releases_hist ALTER COLUMN l_dmm TYPE text[] USING CASE WHEN l_dmm = '' THEN '{}' ELSE ARRAY[l_dmm ] END;
+ALTER TABLE releases_hist ALTER COLUMN l_gyutto TYPE integer[] USING CASE WHEN l_gyutto = 0 THEN '{}' ELSE ARRAY[l_gyutto] END;
+ALTER TABLE releases ALTER COLUMN l_dmm SET DEFAULT '{}';
+ALTER TABLE releases ALTER COLUMN l_gyutto SET DEFAULT '{}';
+ALTER TABLE releases_hist ALTER COLUMN l_dmm SET DEFAULT '{}';
+ALTER TABLE releases_hist ALTER COLUMN l_gyutto SET DEFAULT '{}';