redis-migrate
CLI tool to create and run redis key migrations.
Overview
A migration file consists of a single exported object with two keys: up
and
down
. The current release is designed to be backwards compatible with Redis
2.6 and 2.4. As such, it uses KEYS
, which is blocking and should not be used
on a production db when dealing with any significant number of keys. Future
releases will allow for non-blocking operation using SCAN
, HSCAN
, etc.
Installation
It can be installed via npm
using:
npm install -g redis-migrate
Usage
Usage: redis-migrate [up|down|create] <migrationName>
Options:
-h, --help output usage information
-V, --version output the version number
Example Migration File
exportsup =cmd: 'moveKeysToHashFields'src: key: /:address/dst: key: '$1:properties' field: 'address'cmd: 'renameKeys'src: key: /:lastModifiedTimestamp/dst: key: '$1:lastModified';exportsdown =cmd: 'moveHashFieldsToKeys'src: key: /:properties/ field: 'address'dst: key: '$1:address'cmd: 'renameKeys'src: key: /:lastModified/dst: key: '$1:lastModifiedTimestamp';