aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjloup <jean-loup.jamet@trainline.com>2018-08-04 23:05:19 +0200
committerjloup <jean-loup.jamet@trainline.com>2018-08-04 23:05:19 +0200
commitc86c484700c6ce6953847128f3d50aa497568350 (patch)
treebd38cfee83835e60d90bb46ae6aba178d1d6c36a
parent215e478fa347e922ad47ace89316113f1b7f15cd (diff)
downloadFront-sell-strategy.tar.gz
Front-sell-strategy.tar.zst
Front-sell-strategy.zip
Add sell_strategy to bot_settings.sell-strategy
-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}