Middle+
What do you use to apply migrations?
sobes.tech AI
Answer from AI
To manage migrations in Go, specialized tools are often used that allow describing database schema changes and applying them sequentially.
Popular options:
- golang-migrate/migrate — CLI and library for migrations, supports many databases.
- pressly/goose — simple and convenient tool with support for SQL and Go scripts.
- sql-migrate — simple tool with YAML configuration.
Example of using golang-migrate:
migrate -path ./migrations -database "postgres://user:pass@localhost:5432/dbname?sslmode=disable" up
In a project, migrations are usually stored in a separate folder, and migration execution is integrated into the deployment or CI/CD process.
The choice depends on the project requirements, convenience, and support for the needed database.