Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 685 Bytes

readme.md

File metadata and controls

26 lines (20 loc) · 685 Bytes

Migration

Prerequisites

go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
  • postgresql

Usage

# Export your postgres url:
export POSTGRESQL='postgres://user:password@host:port/dbname?sslmode=disable'
# Example:
export POSTGRESQL='postgres://postgres:postgres@localhost:5432/shopping-cart?sslmode=disable'
# Create migration step:
migrate create -ext sql -dir internal/migration/ -seq create_user_table
# Migrate up:
migrate -database ${POSTGRESQL} -path internal/migration/ up
# Migrate down:
migrate -database ${POSTGRESQL} -path internal/migration/ down