netlify / git-gateway

A Gateway to Git APIs
MIT License
404 stars 89 forks source link

Database migrations #25

Closed ghost closed 2 years ago

ghost commented 5 years ago

- Do you want to request a feature or report a bug? Both, probably.

- What is the current behavior? the command migrate has no effect.

- If the current behavior is a bug, please provide the steps to reproduce. ./git-gateway migrate -c .env

- What is the expected behavior? I would like it to create the database structues for sqlite3 as well as mysql. It doesn't work on either.

- Please mention your Go version, and operating system version. go version go1.11.4 linux/amd64, debian 9 stretch

This is the bug part. The feature request part: Documentation.

Using a Database is necessary for handling multi tenant mode. Working myself through the code reproducing the steps on your own is not for everyone.

gumaerc commented 4 years ago

I've been looking into this recently, and I've found that this microservice uses GORM and implements the "Automigrate" functionality. The issue I've found is that, while it seems like the default for the feature flag that enables it is set to true in app.json as:

"git-gateway_DB_AUTOMIGRATE": {
      "value": true
    }

... the database still has no migrations run on it. I debugged this by printing the value of config.DB.Automigrate in dial.go and found that the value was false, even though the default is true. It turns out the only way to get this to be enabled is to add GITGATEWAY_DB_AUTOMIGRATE=true into your .env file. The issue seems to be that the first part of the key needs to be GITGATEWAY and not git-gateway... so I think that most likely none of these defaults are working properly.