diff options
author | Matthew Lemon <y@yulqen.org> | 2024-04-10 19:33:21 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-04-10 19:33:21 +0100 |
commit | e69391d4f309f6268440632585bbddf3a2a5bd60 (patch) | |
tree | 9e0faa4a92f06dbd8c228ba80752ea5f4d89dd17 /cmd/dbasik-api | |
parent | d36c48b3251b9da483f06318ecaa14b9a4fa7118 (diff) |
First introduction of migrations using golang-migrate
Diffstat (limited to 'cmd/dbasik-api')
-rw-r--r-- | cmd/dbasik-api/datamaps.go | 10 | ||||
-rw-r--r-- | cmd/dbasik-api/main.go | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/cmd/dbasik-api/datamaps.go b/cmd/dbasik-api/datamaps.go index 8d371ab..1e668ef 100644 --- a/cmd/dbasik-api/datamaps.go +++ b/cmd/dbasik-api/datamaps.go @@ -30,6 +30,7 @@ import ( // The fields need to be exported otherwise they won't be included when encoding // the struct to json. type datamapLine struct { + ID int64 `json:"id"` Key string `json:"key"` Sheet string `json:"sheet"` DataType string `json:"datatype"` @@ -38,6 +39,7 @@ type datamapLine struct { // datamap includes a slice of datamapLine objects alongside header metadata type datamap struct { + ID int64 `json:"id"` Name string `json:"name"` Description string `json:"description"` Created time.Time `json:"created"` @@ -85,10 +87,10 @@ func (app *application) createDatamapHandler(w http.ResponseWriter, r *http.Requ } dmls = append(dmls, datamapLine{ - Key: line[0], - Sheet: line[1], - DataType: line[2], - Cellref: line[3], + Key: line[1], + Sheet: line[2], + DataType: line[3], + Cellref: line[4], }) } dm = datamap{Name: dmName, Description: dmDesc, Created: time.Now(), DMLs: dmls} diff --git a/cmd/dbasik-api/main.go b/cmd/dbasik-api/main.go index e86f91c..f132c50 100644 --- a/cmd/dbasik-api/main.go +++ b/cmd/dbasik-api/main.go @@ -73,8 +73,8 @@ func main() { //Read connection pool settings (explained in Configuring the pool in the book) flag.IntVar(&cfg.db.maxOpenConns, "db-max-open-conns", 25, "PostgreSQL max open connections") - flag.IntVar(&cfg.db.maxIdleConns, "db-max-idel-conns", 25, "PostgreSQL max idle connections") - flag.StringVar(&cfg.db.maxIdleTime, "db-max-idel-conns", "15m", "PostgreSQL max connection idle time") + flag.IntVar(&cfg.db.maxIdleConns, "db-max-idle-conns", 25, "PostgreSQL max idle connections") + flag.StringVar(&cfg.db.maxIdleTime, "db-max-idle-time", "15m", "PostgreSQL max connection idle time") flag.Parse() |