Sobes.tech
Middle+

Kuidas teete migratsioone?

sobes.tech AI

Vastus AI-lt

To manage migrations in Go, specialized tools are often used that allow describing changes to the database schema 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

Migrations are usually stored in a separate folder, and the execution of migrations is integrated into the deployment or CI/CD process.

The choice depends on the project requirements, convenience, and the support of the necessary database.