]>
Commit | Line | Data |
---|---|---|
4215df47 | 1 | package db |
2 | ||
3 | type Migration struct { | |
4 | Version int64 | |
5 | Up []string | |
6 | Down []string | |
7 | } | |
8 | ||
9 | var migrations []Migration = []Migration{ | |
10 | { | |
11 | Version: 1, | |
12 | Up: []string{ | |
13 | `CREATE TABLE users ( | |
14 | id BIGSERIAL PRIMARY KEY, | |
15 | email text NOT NULL, | |
16 | password_hash text NOT NULL, | |
17 | otp_secret text, | |
18 | is_otp_setup boolean, | |
19 | status smallint, | |
20 | UNIQUE(email) | |
21 | )`, | |
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), | |
26 | config jsonb, | |
27 | UNIQUE(user_id, market_name) | |
28 | )`, | |
17b68539 | 29 | `CREATE TABLE reports ( |
30 | id BIGSERIAL PRIMARY KEY, | |
31 | date timestamp with time zone NOT NULL, | |
32 | market_config_id bigint NOT NULL, | |
33 | debug boolean | |
34 | )`, | |
35 | "CREATE INDEX IF NOT EXISTS reports_market_config_id ON reports (market_config_id)", | |
4215df47 | 36 | `CREATE TABLE report_lines ( |
37 | id BIGSERIAL PRIMARY KEY, | |
38 | date timestamp with time zone NOT NULL, | |
17b68539 | 39 | report_id bigint NOT NULL REFERENCES reports(id), |
4215df47 | 40 | type text, |
41 | payload jsonb | |
42 | )`, | |
43 | "CREATE INDEX IF NOT EXISTS report_lines_report_id ON report_lines (report_id)", | |
44 | "CREATE INDEX IF NOT EXISTS report_lines_type ON report_lines (type)", | |
45 | }, | |
2b2fd737 | 46 | Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines", "DROP TABLE reports"}, |
4215df47 | 47 | }, |
48 | } |