Registry / database / mini-pg-migrate

mini-pg-migrate

JSON →
library0.0.6jsnpmunverified

A minimal PostgreSQL database migration tool, version 0.0.6. Offers commands to generate, up, and down migrations. Released as a lightweight alternative to node-pg-migrate with no external dependencies. Configuration is done via a JavaScript file exporting a PG connection config. Migration files are SQL-based and versioned.

npm install mini-pg-migrate
INSTALL
IMPORT
SIG · MINI-PG-MIGRATE
M
mini-pg-migrate
databasejavascriptv0.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CLI
npx mini-pg-migrate generate <name> <dir> <version>
node node_modules/mini-pg-migrate/dist/index.cjs generate ...
CLI is run via npx or npm scripts, not directly imported as a module.
config
export default { connectionString: '...' } or module.exports = { ... } in a .js config file
Configuration file exports a plain object with PostgreSQL connection parameters.

Demonstrates installation, config setup, generate, up, and down commands.

// 1. Install npm install -D mini-pg-migrate pg // 2. Create migration config (config/migration.config.js) module.exports = { connectionString: process.env.DATABASE_URL ?? 'postgres://user:pass@localhost:5432/mydb', }; // 3. Generate a migration npx mini-pg-migrate generate init ./migrations // 4. Write SQL in ./migrations/001_do_something.sql // 5. Run migrations up npx mini-pg-migrate migrate:up ./config/migration.config.js ./migrations // 6. Run migrations down npx mini-pg-migrate migrate:down ./config/migration.config.js ./migrations
Debug
Known issues
gotchaThe CLI command for 'up' is `migrate:up`, but it is documented as `migrate:up` and `migrate:down` in script names. Make sure to use the exact string in npm scripts.
fix
Use `mini-pg-migrate migrate:up ...` and `mini-pg-migrate migrate:down ...` in npm scripts.
affects: >=0.0.6
gotchaThe config file path must be relative to the current working directory. If using a script, ensure the correct path.
fix
Always use absolute paths or paths relative to where you run the command.
affects: >=0.0.6
gotchaMigration files are simple SQL files. There is no type checking or validation for the SQL content.
fix
Manually review SQL for errors. The tool does not parse or validate SQL.
affects: >=0.0.6
Errors
Common errors & fixes
Cannot find module 'pg'
pg is not installed as a dependency
fix
npm install pg
Error: Cannot find module './config/migration.config.js'
Invalid or missing config file path
fix
Ensure the config file exists and path is correct.
Error: Connection terminated unexpectedly
Database credentials incorrect or database not reachable
fix
Check DATABASE_URL or connection settings in config.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies
pgrequiredpeer dependency for database connectivity
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
mini-pg-migrate — npm install mini-pg-migrate · libregistry