diff options
-rw-r--r-- | cmd/ansible/conf.toml.j2 | 5 | ||||
-rw-r--r-- | cmd/app/conf.toml | 1 | ||||
-rw-r--r-- | db/db.go | 3 | ||||
-rw-r--r-- | db/migrations.go | 16 |
4 files changed, 16 insertions, 9 deletions
diff --git a/cmd/ansible/conf.toml.j2 b/cmd/ansible/conf.toml.j2 index 5f08a26..b2c3137 100644 --- a/cmd/ansible/conf.toml.j2 +++ b/cmd/ansible/conf.toml.j2 | |||
@@ -9,6 +9,11 @@ password="{{ postgres_password }}" | |||
9 | database="{{ postgres_database }}" | 9 | database="{{ postgres_database }}" |
10 | address="localhost:5432" | 10 | address="localhost:5432" |
11 | 11 | ||
12 | [redis] | ||
13 | type="{{ redis_adress_type }}" | ||
14 | address="localhost:6379" | ||
15 | database=0 | ||
16 | |||
12 | [api] | 17 | [api] |
13 | domain="{{ app_domain }}" | 18 | domain="{{ app_domain }}" |
14 | jwt_secret="{{ jwt_secret }}" | 19 | jwt_secret="{{ jwt_secret }}" |
diff --git a/cmd/app/conf.toml b/cmd/app/conf.toml index bdbf58b..13e3e0b 100644 --- a/cmd/app/conf.toml +++ b/cmd/app/conf.toml | |||
@@ -11,6 +11,7 @@ address="localhost:5432" | |||
11 | [redis] | 11 | [redis] |
12 | type="tcp" | 12 | type="tcp" |
13 | address="cryptoportfolio.immae.eu:7617" | 13 | address="cryptoportfolio.immae.eu:7617" |
14 | database=0 | ||
14 | 15 | ||
15 | [api] | 16 | [api] |
16 | domain="localhost" | 17 | domain="localhost" |
@@ -26,6 +26,7 @@ type RedisConfig struct { | |||
26 | Type string // tcp or unix | 26 | Type string // tcp or unix |
27 | Address string | 27 | Address string |
28 | Password string | 28 | Password string |
29 | Database int | ||
29 | } | 30 | } |
30 | 31 | ||
31 | func Init(config DBConfig, redisConfig RedisConfig) { | 32 | func Init(config DBConfig, redisConfig RedisConfig) { |
@@ -42,7 +43,7 @@ func Init(config DBConfig, redisConfig RedisConfig) { | |||
42 | Network: redisConfig.Type, | 43 | Network: redisConfig.Type, |
43 | Addr: redisConfig.Address, | 44 | Addr: redisConfig.Address, |
44 | Password: redisConfig.Password, | 45 | Password: redisConfig.Password, |
45 | DB: 0, | 46 | DB: redisConfig.Database, |
46 | }) | 47 | }) |
47 | 48 | ||
48 | _, err = Redis.Ping().Result() | 49 | _, err = Redis.Ping().Result() |
diff --git a/db/migrations.go b/db/migrations.go index 286fe17..38ea8aa 100644 --- a/db/migrations.go +++ b/db/migrations.go | |||
@@ -26,22 +26,22 @@ 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 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)", | ||
29 | `CREATE TABLE report_lines ( | 36 | `CREATE TABLE report_lines ( |
30 | id BIGSERIAL PRIMARY KEY, | 37 | id BIGSERIAL PRIMARY KEY, |
31 | date timestamp with time zone NOT NULL, | 38 | date timestamp with time zone NOT NULL, |
32 | report_id bigint NOT NULL, | 39 | report_id bigint NOT NULL REFERENCES reports(id), |
33 | type text, | 40 | type text, |
34 | payload jsonb | 41 | payload jsonb |
35 | )`, | 42 | )`, |
36 | "CREATE INDEX IF NOT EXISTS report_lines_report_id ON report_lines (report_id)", | 43 | "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)", | 44 | "CREATE INDEX IF NOT EXISTS report_lines_type ON report_lines (type)", |
38 | `CREATE TABLE reports ( | ||
39 | id BIGSERIAL PRIMARY KEY, | ||
40 | date timestamp with time zone NOT NULL, | ||
41 | market_config_id bigint NOT NULL, | ||
42 | debug boolean | ||
43 | )`, | ||
44 | "CREATE INDEX IF NOT EXISTS reports_market_config_id ON reports (market_config_id)", | ||
45 | }, | 45 | }, |
46 | Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines", "DROP TABLE reports"}, | 46 | Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines", "DROP TABLE reports"}, |
47 | }, | 47 | }, |