How to Run Database Migrations in Go (golang-migrate, goose)

Install golang-migrate or goose and run the up command with your database URL to apply schema changes.

Run database migrations in Go by installing a tool like golang-migrate or goose and executing its CLI commands against your database.

go install github.com/golang-migrate/migrate/v4/cmd/migrate@latest
migrate -path ./migrations -database "postgres://user:pass@host:5432/dbname?sslmode=disable" up