pg_migrate

Crates.iopg_migrate
lib.rspg_migrate
version0.1.2
sourcesrc
created_at2024-07-01 12:20:20.489541
updated_at2024-07-07 18:30:42.527717
descriptionDatabase migration tool for PostgreSQL
homepage
repositoryhttps://github.com/allelementary/pg-migrate
max_upload_size
id1288688
size73,368
Mikhail Antonov (allelementary)

documentation

README

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
Commit count: 10

cargo fmt