aboutsummaryrefslogtreecommitdiff
path: root/db/migrations.go
diff options
context:
space:
mode:
authorjloup <jeanloup.jamet@gmail.com>2018-04-30 21:12:37 +0200
committerjloup <jeanloup.jamet@gmail.com>2018-04-30 21:12:37 +0200
commit4215df47c93c6ea26f21c74a9d52f78d1d103dde (patch)
treec8892d241c0c1f7663a09b4f3b8e1c7d2dc7abc5 /db/migrations.go
parent1fc43bfa508b3579ca5a8944f8fc3e84cacee500 (diff)
downloadFront-4215df47c93c6ea26f21c74a9d52f78d1d103dde.tar.gz
Front-4215df47c93c6ea26f21c74a9d52f78d1d103dde.tar.zst
Front-4215df47c93c6ea26f21c74a9d52f78d1d103dde.zip
Databse migrations.
Diffstat (limited to 'db/migrations.go')
-rw-r--r--db/migrations.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/db/migrations.go b/db/migrations.go
new file mode 100644
index 0000000..ce5caf6
--- /dev/null
+++ b/db/migrations.go
@@ -0,0 +1,41 @@
1package db
2
3type Migration struct {
4 Version int64
5 Up []string
6 Down []string
7}
8
9var 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 )`,
29 `CREATE TABLE report_lines (
30 id BIGSERIAL PRIMARY KEY,
31 date timestamp with time zone NOT NULL,
32 report_id bigint NOT NULL,
33 type text,
34 payload jsonb
35 )`,
36 "CREATE INDEX IF NOT EXISTS report_lines_report_id ON report_lines (report_id)",
37 "CREATE INDEX IF NOT EXISTS report_lines_type ON report_lines (type)",
38 },
39 Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines"},
40 },
41}