aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-06 10:03:23 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-05-06 10:03:23 +0200
commit18344354c5985373740b0e0c815b79a7936ef34e (patch)
treeb548898501006c9b79851d644f47e5793024f12e
parent87b6d05e5b289f3e9d1554fe455296ba09655c3a (diff)
downloadFront-view_balances.tar.gz
Front-view_balances.tar.zst
Front-view_balances.zip
Add missing index and viewview_balances
-rw-r--r--db/migrations.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrations.go b/db/migrations.go
index 38ea8aa..e6a7f22 100644
--- a/db/migrations.go
+++ b/db/migrations.go
@@ -26,6 +26,7 @@ var migrations []Migration = []Migration{
26 config jsonb, 26 config jsonb,
27 UNIQUE(user_id, market_name) 27 UNIQUE(user_id, market_name)
28 )`, 28 )`,
29 `CREATE INDEX IF NOT EXISTS market_configs_user_id ON market_configs (user_id)`,
29 `CREATE TABLE reports ( 30 `CREATE TABLE reports (
30 id BIGSERIAL PRIMARY KEY, 31 id BIGSERIAL PRIMARY KEY,
31 date timestamp with time zone NOT NULL, 32 date timestamp with time zone NOT NULL,
@@ -45,4 +46,25 @@ var migrations []Migration = []Migration{
45 }, 46 },
46 Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines", "DROP TABLE reports"}, 47 Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines", "DROP TABLE reports"},
47 }, 48 },
49 {
50 Version: 201805061000,
51 Up: []string{
52 `CREATE VIEW "view_balances" AS
53 SELECT report_lines.id,
54 reports.id AS report_id,
55 market_configs.market_name,
56 users.id AS user_id,
57 users.email AS user_email,
58 reports.date AS report_date,
59 report_lines.date,
60 report_lines.payload
61 FROM (((report_lines
62 JOIN reports ON ((reports.id = report_lines.report_id)))
63 JOIN market_configs ON ((reports.market_config_id = market_configs.id)))
64 JOIN users ON ((market_configs.user_id = users.id)))
65 WHERE report_lines.payload::jsonb->'checkpoint' IS NOT NULL`,
66 `CREATE INDEX checkpoints_idx ON report_lines ((payload->>'checkpoint'))`,
67 },
68 Down: []string{"DROP VIEW view_balances", "DROP INDEX checkpoints_idx"},
69 },
48} 70}