Registry / database / knex-schema-builder

knex-schema-builder

JSON →
library0.4.10jsnpmunverified

A schema builder helper for Knex that automates database initialization and migration using JSON schema files. It provides a declarative way to define database schemas (schema.json) and versioned upgrade scripts (upgrade.####.json). The tool supports MySQL, PostgreSQL, and SQLite. Version 0.4.10 is the current stable release, with low release cadence (last update years ago). It relies on Knex as a peer dependency. Key differentiator: JSON-driven schema definition and upgrade path, ideal for projects that need a simple, migration-based DB setup without writing raw SQL or complex migration files. Note: The package is unmaintained (last commit in 2016).

npm install knex-schema-builder
INSTALL
IMPORT
SIG · KNEX-SCHEMA-BUILDE
K
knex-schema-builder
databasejavascriptv0.4.10
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.

install
const schema = require('knex-schema-builder'); schema.install(db, path, callback);
import { install } from 'knex-schema-builder'
CommonJS only; ESM not supported. Must call with knex instance and schema path.
upgrade
const schema = require('knex-schema-builder'); schema.upgrade(db, path, callback);
CommonJS only; ESM not supported.
isInstallNeeded
const schema = require('knex-schema-builder'); schema.isInstallNeeded(db, path, callback);
Checks if database needs fresh install based on schema version.

Initializes a fresh SQLite database using a JSON schema folder with knex-schema-builder.

const knex = require('knex'); const path = require('path'); const schemaInstaller = require('knex-schema-builder'); const db = knex({ client: 'sqlite3', connection: { filename: './mydb.sqlite' }, useNullAsDefault: true }); const schemaPath = path.join(__dirname, './db_schema'); // Install fresh database schemaInstaller.install(db, schemaPath, (err) => { if (err) { console.error('Installation failed:', err); } else { console.log('Database installed successfully'); } });
Debug
Known issues
breakingPackage is unmaintained and relies on outdated Knex versions (<0.21).
fix
Consider using Knex migrations or a maintained alternative.
affects: >=0.0.0
gotchaAll schema files must be placed in a folder including schema.json, version.json, and optional upgrade files.
fix
Ensure folder contains at least schema.json and version.json before calling install/upgrade.
affects: >=0.0.0
gotchaUpgrade file naming: upgrade.####.json where #### is version number (e.g., upgrade.2.json). Incorrect naming causes failure.
fix
Name files exactly like 'upgrade.2.json' where 2 is the target version number.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'knex-schema-builder'
Package not installed or not in node_modules.
fix
Run: npm install knex-schema-builder
TypeError: schemaInstaller.install is not a function
Import method mismatch (e.g., destructured import or incorrect require).
fix
Use: const schemaInstaller = require('knex-schema-builder'); then schemaInstaller.install(...)
Upgrade
Version history
0.4.10latest on npm
Audit
Dependencies
knexrequiredpeer dependency required for all database interactions
Agent activity
6 hits · last 30 days
node
4
Amazon
1
Resources
knex-schema-builder — npm install knex-schema-builder · libregistry