Awesome Go

go-pg-migrate

CategoryDatabase
SubcategoryDatabase Schema Migration
Stars0

CLI-friendly package for go-pg migrations management

About go-pg-migrate

GolangCI Version Go Report Card Coverage Status Go Reference Mentioned in Awesome Go

go-pg-migrate

CLI-friendly package for PostgreSQL migrations management.

Installation

Requires Go Modules enabled.

go get github.com/lawzava/go-pg-migrate/v2

Usage

Initialize the migrate with options payload where choices are:

  • DatabaseURI database connection string. In a format of postgres://user:password@host:port/database?sslmode=disable.

  • VersionNumberToApply uint value of a migration number up to which the migrations should be applied. When the requested migration number is lower than currently applied migration number it will run backward migrations, otherwise it will run forward migrations.

  • PrintVersionAndExit if true, the currently applied version number will be printed into stdout and the migrations will not be applied.

  • ForceVersionWithoutMigrations if true, the migrations will not be applied, but they will be registered as applied up to the specified version number.

  • RefreshSchema if true, public schema will be dropped and recreated before the migrations are applied. Useful for frequent testing and CI environments.

Example

You will find the example in examples directory. The example is CLI-friendly and can be used as a base for CLI-based migrations utility.

Frequently Asked Questions

What is go-pg-migrate?

go-pg-migrate is a Database library for the Go programming language. CLI-friendly package for go-pg migrations management

How do I install go-pg-migrate?

Install go-pg-migrate with the Go module system using `go get lawzava/go-pg-migrate`. Check the repository for the current installation instructions.

What category does go-pg-migrate belong to?

go-pg-migrate is listed under Database, specifically Database Schema Migration.

← Back to Database Schema Migration