aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/migrations.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/db/migrations.go b/db/migrations.go
index 9246eaa..7576668 100644
--- a/db/migrations.go
+++ b/db/migrations.go
@@ -137,4 +137,39 @@ var migrations []Migration = []Migration{
137 "DROP VIEW market_configs_augmented", 137 "DROP VIEW market_configs_augmented",
138 }, 138 },
139 }, 139 },
140 {
141 Version: 201808041000,
142 Up: []string{
143 "CREATE TYPE sell_strategy AS ENUM ('sell-needed', 'sell-all')",
144 "ALTER TABLE bot_settings ADD sell_strategy sell_strategy",
145 `CREATE OR REPLACE VIEW market_configs_augmented AS
146 SELECT market_configs.*,
147 COALESCE(u.portfolio_profile, g.portfolio_profile) AS portfolio_profile,
148 COALESCE(u.sell_strategy, g.sell_strategy) AS sell_strategy
149 FROM market_configs
150 LEFT JOIN bot_settings AS u
151 ON u.user_id = market_configs.user_id,
152 (
153 SELECT portfolio_profile, sell_strategy
154 FROM bot_settings
155 WHERE user_id IS NULL
156 ) AS g`,
157 },
158 Down: []string{
159 `CREATE OR REPLACE VIEW market_configs_augmented AS
160 SELECT market_configs.*,
161 COALESCE(u.portfolio_profile, g.portfolio_profile)
162 AS portfolio_profile
163 FROM market_configs
164 LEFT JOIN bot_settings AS u
165 ON u.user_id = market_configs.user_id,
166 (
167 SELECT portfolio_profile
168 FROM bot_settings
169 WHERE user_id IS NULL
170 ) AS g`,
171 "ALTER TABLE bot_setttings DROP COLUMN sell_strategy",
172 "DROP TYPE sell_strategy",
173 },
174 },
140} 175}