]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/commitdiff
Fix PG migrations + redis config.
authorjloup <jeanloup.jamet@gmail.com>
Tue, 1 May 2018 08:16:53 +0000 (10:16 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 1 May 2018 08:22:51 +0000 (10:22 +0200)
cmd/ansible/conf.toml.j2
cmd/app/conf.toml
db/db.go
db/migrations.go

index 5f08a26c10b020f9236e059182575741b9f427a3..b2c3137cfaf6eaf1fc3e151bc08c859e9faf50ad 100644 (file)
@@ -9,6 +9,11 @@ password="{{ postgres_password }}"
 database="{{ postgres_database }}"
 address="localhost:5432"
 
+[redis]
+type="{{ redis_adress_type }}"
+address="localhost:6379"
+database=0
+
 [api]
 domain="{{ app_domain }}"
 jwt_secret="{{ jwt_secret }}"
index bdbf58b802696ab352f5906dbf66f9630fdfb49c..13e3e0b7e931e6fe41ed4a57d218785d2a29d626 100644 (file)
@@ -11,6 +11,7 @@ address="localhost:5432"
 [redis]
 type="tcp"
 address="cryptoportfolio.immae.eu:7617"
+database=0
 
 [api]
 domain="localhost"
index 078cd5895885f5308a13729c3acca58ed2544266..2596dcb25c24c1daa428f4c526224919c16a1433 100644 (file)
--- a/db/db.go
+++ b/db/db.go
@@ -26,6 +26,7 @@ type RedisConfig struct {
        Type     string // tcp or unix
        Address  string
        Password string
+       Database int
 }
 
 func Init(config DBConfig, redisConfig RedisConfig) {
@@ -42,7 +43,7 @@ func Init(config DBConfig, redisConfig RedisConfig) {
                Network:  redisConfig.Type,
                Addr:     redisConfig.Address,
                Password: redisConfig.Password,
-               DB:       0,
+               DB:       redisConfig.Database,
        })
 
        _, err = Redis.Ping().Result()
index 286fe17eb334427adcef19bad5aa2189c8825c9d..38ea8aa03f713ba234efb1a9c563b52588a9f2cf 100644 (file)
@@ -26,22 +26,22 @@ var migrations []Migration = []Migration{
                                config      jsonb,
                                UNIQUE(user_id, market_name)
                        )`,
+                       `CREATE TABLE reports (
+                               id               BIGSERIAL PRIMARY KEY,
+                               date             timestamp with time zone NOT NULL,
+                               market_config_id bigint NOT NULL,
+                               debug            boolean
+                       )`,
+                       "CREATE INDEX IF NOT EXISTS reports_market_config_id ON reports (market_config_id)",
                        `CREATE TABLE report_lines (
                                id        BIGSERIAL PRIMARY KEY,
                                date      timestamp with time zone NOT NULL,
-                               report_id bigint NOT NULL,
+                               report_id bigint NOT NULL REFERENCES reports(id),
                                type      text,
                                payload   jsonb
                        )`,
                        "CREATE INDEX IF NOT EXISTS report_lines_report_id ON report_lines (report_id)",
                        "CREATE INDEX IF NOT EXISTS report_lines_type      ON report_lines (type)",
-                       `CREATE TABLE reports (
-                               id               BIGSERIAL PRIMARY KEY,
-                               date             timestamp with time zone NOT NULL,
-                               market_config_id bigint NOT NULL,
-                               debug            boolean
-                       )`,
-                       "CREATE INDEX IF NOT EXISTS reports_market_config_id ON reports (market_config_id)",
                },
                Down: []string{"DROP TABLE users", "DROP TABLE market_configs", "DROP TABLE report_lines", "DROP TABLE reports"},
        },