3 releases

0.1.2 Jul 7, 2024
0.1.1 Jul 1, 2024
0.1.0 Jul 1, 2024

#1725 in Database interfaces

Download history 207/week @ 2024-06-27 152/week @ 2024-07-04 13/week @ 2024-07-11 2/week @ 2024-07-18 17/week @ 2024-07-25 34/week @ 2024-09-12 23/week @ 2024-09-19 15/week @ 2024-09-26

72 downloads per month

MIT license

35KB
712 lines

PG Migrate

About

Database migration tool for PostgreSQL written in Rust

Features

  • Create migration
  • Upgrade / Downgrade database
  • Get current migration
  • Get head migration
  • Get migrations history

Installation

cargo install pg_migrate

Set up the database URL and migrations directory in the environment variables DATABASE_URL and MIGRATION_DIR.

DATABASE_URL=postgresql://username:password@localhost/dbname

CLI Usage

  • Create migration:
pg_migrate_cli new <migration name>
  • Upgrade / Downgrade: There is multiple options to upgrade or downgrade the database:

    • Upgrade to the latest migration:
      pg_migrate_cli upgrade head
      
    • Upgrade / Downgrade to a specific migration by migration id:
      pg_migrate_cli upgrade/downgrade migration-id <migration-id>
      
    • Upgrade / Downgrade by number of migrations:
      pg_migrate_cli upgrade/downgrade number <number>
      
  • Get head:

pg_migrate_cli head
  • Get current migration:
pg_migrate_cli current
  • Get migrations history
pg_migrate_cli history

Dependencies

~11–22MB
~339K SLoC