Registry / database / rethinkdb-ts-migrate

rethinkdb-ts-migrate

JSON →
library0.3.6jsnpmunverified

A migration tool for RethinkDB databases, version 0.3.6. It allows forward and backward migration of structural or data changes using a versioned approach. This is a fork of rethink-migrate with more active maintenance. It supports TypeScript, environment variable overrides, and CLI commands for creating and running migrations. Release cadence is irregular; last update was in 2017.

npm install rethinkdb-ts-migrate
INSTALL
IMPORT
SIG · RETHINKDB-TS-MIGRA
R
rethinkdb-ts-migrate
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.

default migration up/down functions
exports.up = async function(r, conn) { /* ... */ }; exports.down = async function(r, conn) { /* ... */ };
module.exports.up = function(r, conn) { ... }
Use CommonJS exports (exports.up) not module.exports. Use async functions for promises.
CLI tool
npx rethinkdb-ts-migrate create my-migration
rethinkdb-ts-migrate create my-migration (without npx or global install)
Prefer npx to avoid global install. If globally installed, the command is available directly.
database.json configuration
{ "host": "localhost", "port": 28015, "db": "migrations" }
Using a .js file or environment variables without a database.json
The tool expects a database.json file in the project root. Environment variables can override.

This shows how to install the CLI tool globally. However, it's recommended to use npx instead: npx rethinkdb-ts-migrate create add-tables.

npm install -g rethinkdb-ts-migrate
Debug
Known issues
gotchaThe package has not been updated since 2017. It may not be compatible with newer versions of RethinkDB or Node.js.
fix
Consider using an alternative like flyway-rethinkdb or writing your own migration scripts.
affects: >=0.3.0
breakingMigration files must use CommonJS exports (exports.up) not ES module exports (export). The tool does not support ES modules.
fix
Use exports.up = function(r, conn) { ... }; exports.down = function(r, conn) { ... };
affects: >=0.0.0
gotchaThe database.json file must be in the project root by default. The CLI does not accept a config file path except via -r for migration root.
fix
Ensure database.json is in the root or use environment variables: RDB_HOST, RDB_PORT, RDB_DB.
affects: >=0.0.0
gotchaUp and down migrations must return promises. Using callbacks or sync code may cause unexpected behavior.
fix
Wrap your migration logic in a function that returns a promise: exports.up = async (r, conn) => { await r.tableCreate('foo').run(conn); }
affects: >=0.0.0
gotchaThe global installation is recommended but may conflict with other projects. Use npx to avoid global dependencies.
fix
Run: npx rethinkdb-ts-migrate up --all
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rethinkdb'
RethinkDB driver not installed as a project dependency.
fix
Run: npm install --save rethinkdb
Error: ENOENT: no such file or directory, open 'database.json'
The database.json configuration file is missing from the project root.
fix
Create a database.json file in the root directory with required connection settings.
Error: exports.up is not a function
Migration file does not export a valid up function, likely due to incorrect syntax.
fix
Use: exports.up = function(r, conn) { return r.tableCreate('foo').run(conn); };
Upgrade
Version history
0.3.6latest on npm
Audit
Dependencies
rethinkdboptionalRequired as the RethinkDB driver for database operations.
rethinkdbdashoptionalAlternative RethinkDB driver with promises support.
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
rethinkdb-ts-migrate — npm install rethinkdb-ts-migrate · libregistry