Registry / database / rethink-migrate

rethink-migrate

JSON →
library1.3.1jsnpmunverified

A migration tool for RethinkDB databases. Version 1.3.1 is the latest stable release (last updated in 2018). It supports both the rethinkdb and rethinkdbdash drivers. Key differentiators: simple CLI tool for creating, running up and down migrations, and configuration via database.json file. Low maintenance project with few updates.

npm install rethink-migrate
INSTALL
IMPORT
SIG · RETHINK-MIGRATE
R
rethink-migrate
databasejavascriptv1.3.1
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.

up
exports.up = function(r, connection) { return r.tableCreate('foo').run(connection); };
exports.up = function(connection) { return r.tableCreate('foo').run(connection); };
Breaking change in v1.2: up/down functions receive r as first argument.
down
exports.down = function(r, connection) { return r.tableDrop('foo').run(connection); };
exports.down = function(connection) { return r.tableDrop('foo').run(connection); };
Breaking change in v1.2: down function also receives r.
cli
npx rethink-migrate create add-tables
rethink-migrate create add-tables
If not installed globally, use npx or add to package.json scripts.

Shows complete setup: create config, install driver, create migration, define up/down functions, and run migration.

// 1. Create database.json (or use env vars) { "host": "localhost", "port": 28015, "db": "migrations", "discovery": true, "timeout": 60 } // 2. Install driver npm install --save rethinkdb // 3. Create migration npx rethink-migrate create add-tables // 4. Edit generated file (e.g., ./migrations/1234567890-add-tables.js) exports.up = function(r, connection) { return r.tableCreate('foo').run(connection); }; exports.down = function(r, connection) { return r.tableDrop('foo').run(connection); }; // 5. Run up migration npx rethink-migrate up
Debug
Known issues
breakingMigration function signature changed: up/down receive r as first argument.
fix
Update migration files: change function(connection) to function(r, connection).
affects: >=1.2
gotchaThe package requires a driver (rethinkdb or rethinkdbdash) to be installed separately.
fix
Run: npm install --save rethinkdb (or rethinkdbdash).
affects: *
gotchaDatabase configuration file must be named database.json in root.
fix
Create database.json or use environment variables/arguments.
affects: *
gotchaThe package uses an old API; r is the rethinkdb driver instance passed to migration functions.
fix
Ensure migration functions use r for all rethinkdb operations.
affects: *
Errors
Common errors & fixes
Cannot find module 'rethinkdb'
RethinkDB driver not installed.
fix
Run: npm install --save rethinkdb
ReferenceError: r is not defined
Migration functions using old signature without 'r' parameter.
fix
Change exports.up = function(connection) to exports.up = function(r, connection)
Cannot read property 'tableCreate' of undefined
r is undefined due to incorrect function signature.
fix
Update migration functions to accept r as first argument.
No database configuration found
database.json file is missing or in wrong location.
fix
Create 'database.json' in the project root with appropriate settings.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
rethinkdboptionalRequired database driver for running migrations
rethinkdbdashoptionalAlternative database driver
Agent activity
15 hits · last 30 days
node
12
Meta
1
Amazon
1
Resources
rethink-migrate — npm install rethink-migrate · libregistry