]> git.stg.codes - stg.git/blobdiff - stargazer/inst/var/02-alter-03.postgresql.sql
Port to CMake, get rid of os_int.h.
[stg.git] / stargazer / inst / var / 02-alter-03.postgresql.sql
diff --git a/stargazer/inst/var/02-alter-03.postgresql.sql b/stargazer/inst/var/02-alter-03.postgresql.sql
new file mode 100644 (file)
index 0000000..e8b248b
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ *  DB migration from v02 to v03 (postgres)
+ */
+BEGIN;
+
+CREATE DOMAIN DM_TARIFF_CHANGE_POLICY AS TEXT NOT NULL
+    CONSTRAINT valid_value CHECK (VALUE IN ('allow', 'to_cheap', 'to_expensive', 'deny'));
+
+ALTER TABLE tb_tariffs ADD change_policy DM_TARIFF_CHANGE_POLICY DEFAULT 'allow';
+ALTER TABLE tb_tariffs ADD change_policy_timeout TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00';
+ALTER TABLE tb_tariffs ALTER COLUMN change_policy DROP DEFAULT;
+ALTER TABLE tb_tariffs ALTER COLUMN change_policy_timeout DROP DEFAULT;
+
+UPDATE tb_info SET version = 8;
+
+COMMIT;