@aippt/pg-migrate (0.1.0)

Published 2026-09-02 14:11:17 +00:00 by doom2wad

Installation

@aippt:registry=
npm install @aippt/pg-migrate@0.1.0
"@aippt/pg-migrate": "0.1.0"

About this package

pg-migrate

Forward-only PostgreSQL migrator with checksum drift detection. It applies plain SQL scripts in lexicographic order, records each one in a bookkeeping table, and refuses to run when an applied script was edited, removed, or inserted out of order.

Command line

pg-migrate                # apply the pending scripts in ./migrations
pg-migrate --check        # report applied, pending, and problem scripts
pg-migrate --dir db/migrations --url postgres://user:pass@host/db

The connection comes from --url, DATABASE_URL, or the libpq PG* variables, in that order. Run pg-migrate --help for the complete command reference.

Library

Pass an existing postgres.js connection and the migration directory to runMigrations:

import { runMigrations } from '@aippt/pg-migrate'

await runMigrations(sql, './migrations')

Use inspectMigrations to read the same applied, pending, modified, missing, and out-of-order status without changing the database. See migration behavior for the complete contract.

Development

Open the repository in its dev container; it provides the PostgreSQL test server. Then run:

vp install
vp check
vp test
vp run package

The tests create and drop isolated schemas. Override the standard PG* variables to use another PostgreSQL server. See publishing for the release process.

Dependencies

Development dependencies

ID Version
@types/node 26.1.1
@vitest/coverage-v8 4.1.11
node runtime:26.8.1
postgres 3.4.9
publint 0.3.23
typescript 7.0.2
vite npm:@voidzero-dev/vite-plus-core@0.3.0
vite-plus 0.3.0

Peer dependencies

ID Version
postgres >=3.4
Details
npm
2026-09-02 14:11:17 +00:00
4
Karel Smutný <karel.smutny@outlook.com>
MIT
latest
8.8 KiB
Assets (1)
Versions (1) View all
0.1.0 2026-09-02