
Database Migration for Spanner Using golang-migrate
This article was originally published on bmf-tech.com . Overview I used golang-migrate for database migration with Spanner, so here's a note. Usage Assuming usage with Docker. I was running it as a binary instead of Docker, but it might not work depending on the version of OpenSSL on the host machine, so running it in a container seems safer. MIGRATE_VERSION = 'v4.14.1' docker run -v /migrations:/migrations -v ~/.config/gcloud/:/root/.config/gcloud --network host migrate/migrate: ${ MIGRATE_VERSION } -path = /migrations/ -database spanner://projects/<PROJECT ID>/instances/<INSTANCE>/databases/<DATABASE>?x-clean-statements = True <COMMAND> Specify commands like up, down, version, etc., in COMMAND. cf. github.com - golang/migrate/migrate/tree/master/cmd/migrate#usage I wrote the execution command as a one-liner, so it might be hard to read, but there shouldn't be anything particularly difficult. The two mounts are as follows: -v /migrations:/migrations -v ~/.config/gcloud/:/root/.config/
Continue reading on Dev.to
Opens in a new tab


