Registry / database / knex-scripts

knex-scripts

JSON →
library0.3.6jsnpmunverified

A utility package providing CLI commands and Node.js API for PostgreSQL database management tasks such as creating, dropping, dumping, loading, truncating databases, and checking structure. Version 0.3.6 is the latest stable release. It integrates with Knex.js and supports Docker for local development. The package offers convenience scripts that automate common database operations, reducing boilerplate code. It is maintained by Smooth Code and follows a simple configuration through knexfile.

npm install knex-scripts
INSTALL
IMPORT
SIG · KNEX-SCRIPTS
K
knex-scripts
databasejavascriptv0.3.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.

truncate
import { truncate } from 'knex-scripts'
const truncate = require('knex-scripts').truncate
ESM default; CommonJS users should use destructuring require.
dump
import { dump } from 'knex-scripts'
import dump from 'knex-scripts'
Named export, not default.
truncate
const { truncate } = require('knex-scripts')
const truncate = require('knex-scripts/truncate')
CommonJS require pattern; no subpath exports.

Truncates all tables in a PostgreSQL database using knex-scripts truncate function with Knex configuration.

import knex from 'knex'; import { truncate } from 'knex-scripts'; import config from './knexfile.js'; const db = knex(config.development); truncate({ getKnex: () => db }) .then(() => console.log('Truncated')) .catch(err => console.error(err)) .finally(() => db.destroy());
Debug
Known issues
gotchatruncate() depends on process.env.NODE_ENV or --env flag to determine environment.
fix
Pass --env flag or set NODE_ENV environment variable explicitly.
affects: >=0.0.0
gotchaCLI commands require a knexfile.js in the working directory or specify --knexfile.
fix
Ensure knexfile.js exists or use --knexfile <path>.
affects: >=0.0.0
gotchaDocker mode is disabled by default; use --docker flag to enable.
fix
Add --docker flag to CLI command.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'knex-scripts'
Package not installed or not in node_modules.
fix
Run 'npm install knex-scripts' or ensure it's in package.json.
Knex: warning - mysql client is not installed
Database client driver not installed; knex-scripts requires pg for PostgreSQL.
fix
Run 'npm install pg' to install PostgreSQL client.
Cannot read property 'connection' of undefined
knexfile missing or misconfigured environment.
fix
Check knexfile.js has correct environment keys (e.g., development.connection).
Upgrade
Version history
0.3.6latest on npm
Audit
Dependencies
knexoptionalpeer dependency for database interaction
Agent activity
6 hits · last 30 days
node
6
Resources
knex-scripts — npm install knex-scripts · libregistry