sheerun / Knex Migrate
Licence: mit
Modern database migration toolkit for knex.js
Stars: ✭ 330
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Knex Migrate
web-haskell-graphql-postgres-boilerplate
Modern webserver in Haskell: Graphql + Postgresql + Authentication + DB migration + Dotenv and more
Stars: ✭ 114 (-65.45%)
Mutual labels: migration
server-migration-onprem-to-aws
Simple demonstration on how to Lift & Shift OnPremise workload to AWS 🎓
Stars: ✭ 24 (-92.73%)
Mutual labels: migration
project-migration-tools
Project Migration tools to help you migrating to IAR Embedded Workbench more efficiently.
Stars: ✭ 36 (-89.09%)
Mutual labels: migration
medium-to-wordpress-migration
Script to export medium blogs to wordpress rss xml format
Stars: ✭ 15 (-95.45%)
Mutual labels: migration
hasura-metadata-patcher
CLI tool to patch Hasura metadata json file. Helps to organize complex CI/CD flows through different environments.
Stars: ✭ 14 (-95.76%)
Mutual labels: migration
Automigrate
version your SQL schemas with git + automatically migrate them
Stars: ✭ 318 (-3.64%)
Mutual labels: migration
illustrated-python-3-course
Course materials and handouts for Python 3, an illustrated tour course
Stars: ✭ 60 (-81.82%)
Mutual labels: migration
codeigniter-migrate
An easy way to manage database migrations
Stars: ✭ 13 (-96.06%)
Mutual labels: migration
SampleOAuth2 UsingPythonClient
Django Sample app using Python OAuth client
Stars: ✭ 23 (-93.03%)
Mutual labels: migration
code2pg
Tool to help migrate application code from Oracle to PostgreSQL
Stars: ✭ 18 (-94.55%)
Mutual labels: migration
dbup-cli
Cross platform command line tool that helps you to deploy changes to SQL Server databases
Stars: ✭ 18 (-94.55%)
Mutual labels: migration
cloud-services-to-service-fabric
Migrate a Cloud Services application to Service Fabric
Stars: ✭ 27 (-91.82%)
Mutual labels: migration
Clickhouse Mysql Data Reader
utility to read mysql data
Stars: ✭ 257 (-22.12%)
Mutual labels: migration
mongration
MongoDB data migration tool for Spring Boot projects
Stars: ✭ 21 (-93.64%)
Mutual labels: migration
CoreDataMigrationRevised-Example
An example project showing how to implement progressive Core Data migrations
Stars: ✭ 54 (-83.64%)
Mutual labels: migration
Pgloader
Migrate to PostgreSQL in a single command!
Stars: ✭ 3,754 (+1037.58%)
Mutual labels: migration
typedb-loader
TypeDB Loader - Data Migration Tool for TypeDB
Stars: ✭ 43 (-86.97%)
Mutual labels: migration
Modern migration toolkit for knex.js
Features
- [x] 100% compatible with knex.js migrations cli
- [x] can migrate upto and downto any migration
- [x] able to run individual migrations
- [x] quickly rollback recent migrations
- [x] redo feature: rollback and migrate again for quick testing
- [x] runs migrations in transactions
- [x] friendly ui 🌹
Installation
npm install --save knex-migrate
You should also install knex
as it's a peer dependency of this package.
Usage
First, init project with knex init
, and then:
Usage
$ knex-migrate <command> [options]
Commands
generate Generate migration
pending Lists all pending migrations
list Lists all executed migrations
up Performs all pending migrations
down Rollbacks last migration
rollback Rollbacks last batch of migrations
redo Rollbacks last batch and performs all migrations
Options for "up" and "down":
--to, -t Migrate upto (downto) specific version
--from, -f Start migration from specific version
--only, -o Migrate only specific version
--step, -s Limit the number of migrations to apply
Global options:
--cwd Specify the working directory
--knexfile Specify the knexfile path ($cwd/knexfile.js)
--migrations Specify migrations path ($cwd/migrations)
--env Specify environment ($KNEX_ENV || $NODE_ENV || 'development')
--raw Disable transactions
--verbose Be more verbose
As a convenience, you can skip --to flag, and just provide migration name.
Examples
$ knex-migrate up # migrate to the latest version
$ knex-migrate up 20160905 # migrate to a specific version
$ knex-migrate up --to 20160905 # the same as above
$ knex-migrate up --only 201609085 # apply a single migration
$ knex-migrate up --step # apply only the next migration
$ knex-migrate up --step 2 # apply only the next two migrations
$ knex-migrate down --to 0 # rollback all migrations
$ knex-migrate down # rollback single migration
$ knex-migrate down --step 2 # rollback the previous two migrations
$ knex-migrate rollback # rollback previous "up"
$ knex-migrate redo --verbose # rollback and migrate everything
$ knex-migrate generate create_users # generate migration creating users table
Programmatic API
import knexMigrate from 'knex-migrate'
// It has following signature:
// knexMigrate(command: String, flags: Object, progress: Function)
async function run() {
// Action can be: migrate, revert. Migration is migration name. For example:
// Doing migrate on 20170427093232_add_users
// Doing revert on 20170427093232_add_users
const log = ({ action, migration }) =>
console.log('Doing ' + action + ' on ' + migration)
await knexMigrate('up', { to: '20170727093232' }, log)
await knexMigrate('down', { step: 2 }, log)
await knexMigrate('down', { to: 0 }, log)
await knexMigrate('up', {}, log)
await knexMigrate('redo', {}, log)
await knexMigrate('rollback', {}, log)
await knexMigrate('redo', {}, log)
await knexMigrate('down', { to: 0 }, log)
}
run()
Thank you
- @marcbachmann for inspiration and starting point (knex-umzug and umzug-cli)
-
@carlbennettnz for suggesting and implementing
--step
option - @chadxz for suggesting and implementing various improvements
License
MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].