Unison is a simple library to write and version Google Datastore migrations in Go.
$ go get -u github.com/utsavgupta/go-unison/unisoner
$ go get -u github.com/utsavgupta/go-unison/unison
Read this blog article for a comprehensive walkthrough.
The example directory contains a sample web application that shows how the library can possbily be used.
Before you run the application make sure that the GOOGLE_APPLICATION_CREDENTIALS
environment variable is set. The service account should have the necessary permissions to read from and write to Google Datastore. You can find more on this here.
To run the web app you can directly navigate to example/webapp
and run go run .
. The application will be served in port 8080
.
From your terminal execute curl http://localhost:8080/artists
which will return an empty data json structure.
Next, navigate to example/predeploy
and run go run .
. Congratulations on executing your first Datastore migration set with unison!
If you run curl http://localhost:8080/artists
again, you should be presented with the following JSON.
{
"items": [
{
"id": "rhcp",
"name": "Red Hot Chili Peppers"
},
{
"id": "toto",
"name": "Toto"
},
{
"id": "whitesnake",
"name": "Whitesnake"
}
]
}
The project is in it's early stages. Contributions in terms of bug reports, documentation, and testing are welcome. Do not hesitate to report issues or to raise pull requests.