go-migrate

command module
v0.0.0-...-d290fae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 9 Imported by: 0

README

Go migration tool for PostgreSQL

Includes migrations table for migrations history. Create migration, add SQL code for migration, run it. Rollback if needed or re-run migrations from scratch. CLI and library interface.

CLI Commands:

All commands accepting database related parameters:

h - database host

u - database username

p - database password

db - database name

You can also set env variable accordingly: DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME


Available commands:

  • migrate create --name=create_users_table

    This command will create 2 migration files with name create_users_table.up.sql and create_users_table.down.sql. .down.sql one going to be used for rollbacks

    Parameters:

    • name - name of the migration
    • dir - directory where all migration file are store (default path is ./migrations)
  • migrate run

    Run all migrations.

    Parameters:

    • dir - directory where all migration file are store (default path is ./migrations)
  • migrate rollback

    Rollback a single (or more) migration.

    Parameters:

    • step - how many migrations we need to rollback (default is 1)
    • dir - directory where all migration file are store (default path is ./migrations)
  • migrate fresh

    Delete all database tables and re-run migrations.

    Parameters:

    • dir - directory where all migration file are store (default path is ./migrations)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL