https://github.com/lawzava/go-pg-migrate
CLI-friendly package for pg migrations management.
https://github.com/lawzava/go-pg-migrate
cli go go-pg golang hacktoberfest migrate migration migration-tool migrations postgresql
Last synced: about 2 months ago
JSON representation
CLI-friendly package for pg migrations management.
- Host: GitHub
- URL: https://github.com/lawzava/go-pg-migrate
- Owner: lawzava
- License: mit
- Created: 2021-01-16T17:01:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-09T20:46:34.000Z (over 1 year ago)
- Last Synced: 2025-02-25T21:51:13.256Z (2 months ago)
- Topics: cli, go, go-pg, golang, hacktoberfest, migrate, migration, migration-tool, migrations, postgresql
- Language: Go
- Homepage: https://pkg.go.dev/github.com/lawzava/go-pg-migrate
- Size: 51.8 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
- awesome-go - go-pg-migrate - CLI-friendly package for go-pg migrations management. (Database / Database Schema Migration)
- awesome-go-extra - go-pg-migrate - friendly package for pg migrations management.|7|3|0|2021-01-16T17:01:32Z|2021-11-30T23:35:34Z| (Generators / Database Schema Migration)
README

[](https://github.com/lawzava/go-pg-migrate/releases)
[](https://goreportcard.com/report/github.com/lawzava/go-pg-migrate)
[](https://coveralls.io/github/lawzava/go-pg-migrate?branch=main)
[](https://pkg.go.dev/github.com/lawzava/go-pg-migrate)
[](https://awesome-go.com)# 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](examples) directory. The example is CLI-friendly and can be used as a base for CLI-based migrations utility.