golang-migrate

A migration tool for Go projects with a CLI and a library. It applies numbered up and down SQL files and records the current version and a dirty flag in a schema_migrations table.

Minimal example

bash
migrate create -ext sql -dir db/migrations -seq restaurants
migrate -path db/migrations -database "mysql://root:dev@tcp(127.0.0.1:3306)/zomato" up

Learn this concept

Lesson 2.2 · Versioned migrations with golang-migrate

Used in exercises

Exercise 2.3 · Write the restaurant and menu migrations Exercise 2.24 · GET /v1/restaurants: search by name
Prerequisite conceptsDatabase migration