From 215e478fa347e922ad47ace89316113f1b7f15cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 3 Aug 2018 10:40:45 +0200 Subject: [PATCH] Add view for augmented market config --- db/migrations.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/db/migrations.go b/db/migrations.go index 1a105fc..9246eaa 100644 --- a/db/migrations.go +++ b/db/migrations.go @@ -117,4 +117,24 @@ var migrations []Migration = []Migration{ "DROP TYPE portfolio_profile", }, }, + { + Version: 201808031000, + Up: []string{ + `CREATE VIEW market_configs_augmented AS + SELECT market_configs.*, + COALESCE(u.portfolio_profile, g.portfolio_profile) + AS portfolio_profile + FROM market_configs + LEFT JOIN bot_settings AS u + ON u.user_id = market_configs.user_id, + ( + SELECT portfolio_profile + FROM bot_settings + WHERE user_id IS NULL + ) AS g`, + }, + Down: []string{ + "DROP VIEW market_configs_augmented", + }, + }, } -- 2.41.0