A cached, performance-optimized PostgreSQL database restoration tool designed for CI environments. Current stable version is 1.4.1. It creates a template database once from a dump and clones it using CREATE DATABASE WITH TEMPLATE, significantly speeding up repeated restores. Key differentiators: concurrent-safe with automatic waiting, cache invalidation based on dependency files, and automatic cleanup of old cached and restored databases. It requires only psql and PGUSER/PGPASSWORD environment variables, making it lightweight and suitable for integration test matrices.
npm install ci-pg-restoreNo compatibility data collected yet for this library.
This shows how to restore a database dump from dump.sql into testdb using caching with name my-cache.
Ensure PostgreSQL client tools are installed and environment variables are configured before running ci-pg-restore.
Do not manually create or drop databases whose names start with 'ci-pg-restore-cache-' or contain '-template-' suffix; let the tool handle them.
Use only supported suffixes: s, m, h, d, w (e.g., 30m, 8h, 3d).
Ensure restoration commands are idempotent and not destructive; consider using database transactions or consistent dump files.
Ensure the PostgreSQL server is running and the user has permissions to create databases. Alternatively, manually create an empty database with the same name.
Check the dump file for syntax errors or missing dependencies; run the command manually to debug.
Verify the path or glob pattern; ensure files exist before running the tool. Use --deps-files-cmd for more dynamic file discovery.