Which tool would yourself (or anyone else) recommend to manage migrations with Go and MongoDB?
Atlas and Goose are my preference, but are SQL focused so I use go-migrations - but the migrations are written in JSON and I'd really like to write the migrations in Go instead!
Data scientist with 4 years experience. I transform raw data into insights, uncover patterns, and predict trends. Skilled in algorithms and analytics, I solve problems innovatively.
To manage MongoDB migrations in Go without using JSON, use the migrate library with the MongoDB driver and write migrations programmatically in Go. Hereβs a concise guide:
Install dependencies:
go get -u-d github.com/golang-migrate/migrate/cmd/migrate
go get -u github.com/golang-migrate/migrate/v4/database/mongodb
go get -u github.com/golang-migrate/migrate/v4/source/file
Great article Mohd, congrats!
Which tool would yourself (or anyone else) recommend to manage migrations with Go and MongoDB?
Atlas and Goose are my preference, but are SQL focused so I use go-migrations - but the migrations are written in JSON and I'd really like to write the migrations in Go instead!
To manage MongoDB migrations in Go without using JSON, use the migrate library with the MongoDB driver and write migrations programmatically in Go. Hereβs a concise guide:
Install dependencies:
Create a migration in Go:
Write migrations as Go scripts.
This setup allows you to handle MongoDB migrations using Go code.
Ever since I learned about goose I have used goose for migrations for PostgreSQL. I feel it gives me more control.