3 type Migration struct {
9 var migrations []Migration = []Migration{
14 id BIGSERIAL PRIMARY KEY,
16 password_hash text NOT NULL,
22 `CREATE TABLE market_configs (
23 id BIGSERIAL PRIMARY KEY,
24 market_name text NOT NULL,
25 user_id bigint NOT NULL REFERENCES users(id),
27 UNIQUE(user_id, market_name)
29 `CREATE INDEX IF NOT EXISTS market_configs_user_id ON market_configs (user_id)`,
30 `CREATE TABLE reports (
31 id BIGSERIAL PRIMARY KEY,
32 date timestamp with time zone NOT NULL,
33 market_config_id bigint NOT NULL,
36 "CREATE INDEX IF NOT EXISTS reports_market_config_id ON reports (market_config_id)",
37 `CREATE TABLE report_lines (
38 id BIGSERIAL PRIMARY KEY,
39 date timestamp with time zone NOT NULL,
40 report_id bigint NOT NULL REFERENCES reports(id),
44 "CREATE INDEX IF NOT EXISTS report_lines_report_id ON report_lines (report_id)",
45 "CREATE INDEX IF NOT EXISTS report_lines_type ON report_lines (type)",
47 Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines", "DROP TABLE reports"},
50 Version: 201805061000,
52 `CREATE VIEW "view_balances" AS
53 SELECT report_lines.id,
54 reports.id AS report_id,
55 market_configs.market_name,
57 users.email AS user_email,
58 reports.date AS report_date,
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'))`,
68 Down: []string{"DROP VIEW view_balances", "DROP INDEX checkpoints_idx"},