Closed kevinduffey closed 2 years ago
It's a standalone binary. Try running go get -u github.com/jackc/tern
outside of your project and it should be installed to $GOPATH/bin
. Your actual project doesn't need to have it installed. That is, unless you want to embed the migration tool inside your project. In that case you would import package github.com/jackc/tern/migrate
.
As far as an example of how to use it -- it's pretty flexible -- there isn't one "right" way to do it. But if you're familiar with Rails style migrations that is the primary mode. See https://github.com/jackc/booklog/tree/2b8177ff96b524e9c51036ea31b011cf8e1aebd6 for an example from one of my side projects for how I do it.
Fair enough. I don't use GOPATH any longer. However, I did checkout the project, built the binary and moved it to /usr/bin, and that worked well enough. I know of many that no longer use GOROOT with modules working, so it's probably a good idea to mention this in the instructions. I did get it to work.. works well enough. The one thing that has frustrated me is the connection always requires the DB name.. but if the db is not yet created.. I can't seem to connect/create the DB itself. I currently have to manually log in to do that, or I use the createdb binary to do so. Just seems like this would be handy to be able to do as part of a completely clean setup with using this tool (or any migration tool) to be able to create the DB as well.
Installation instructions have been updated.
Not sure why, but I tried: go get -u github.com/jackc/tern in my project root, which has go.mod, etc.. and in my go.mod I see tern is added. However, running tern tells me its not installed. Does this not work when running it in a go mod based project? I also tried that in an empty directory, still no go. Is the above supposed to install it somehow so that it runs anywhere I am at?
It would be fantastic to see more details around how it may be used in a CI/CD setup, how would a developer typically use it in say a microservice or what not.. and how it would be incorporated in a new empty env that has a fresh install of the DB but nothing yet created.