0.2.3 • Published 1 year ago

pigmig v0.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
1 year ago

pigmig

Pigmig is a postgresql database migration tool with a minimal feature set.

Install

npm install pigmig

Usage

  1. Provide a database via the DATABASE_URL environment variable. Pigmig will find it automatically by reading it from process.env.DATABASE_URL.

  2. Create migrations and ensure their proper ordering. The easiest way to do this is by using the provided command line tool pigmig.newmig.

    npx pigmig.newmig src/db/migrations add_user_table

    This creates a .sql file in src/db/migrations that is prepended with a timestamp, e.g., 1606291679849.add_user_table.sql

  3. Run migrations. There are two ways to do this, via the cli or programmatically.

    • CLI: Run pigmig.migrate, passing in the path to your migrations directory.

      npx pigmig.migrate src/db/migrations
    • Programmatically: Include the following line near the top of your server.[js|ts] file or it's equivalent for your tech stack.

      import pigmig from 'pigmig'
      ...
      await pigmig.migrate('src/db/migrations')

Notes

Pigmig creates a migrations table if one does not already exist. It verifies the checksums of previously ran migrations. Each time it runs a new migration, it adds a row for it to the migrations table.

The philosophy behind pigmig is an "always up" / "no rollbacks" / "no down" migration strategy.

0.2.3

1 year ago

0.2.2

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago

0.0.3

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.2

3 years ago

0.0.1

5 years ago