@proximityid/proximity_sequelize_migrations
A node module for creating sequelize migrations from sequelize models.
Last updated 2 years ago by proximityid .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install @proximityid/proximity_sequelize_migrations 
SYNC missed versions from official npm registry.

proximity sequelize migrations

Generates migrations in JS from sequelize models

This package provide two tools:

  • makemigration - tool for creating new migrations for schema based migrations
  • makedatamigration - tool for creating new migration template for data based migrations

Install

npm install proximity_sequelize_migrations

Usage

  • Init sequelize, with sequelize-cli, using sequelize init
  • manually create a _current.json and _current_bak.json in the migrations directory, with the following structure
  • {
  • "tables": {
  • },
  • "revision": (0 for _current)/(-1 for _current_bak) -}
  • Create your models
  • Create initial migration - run:

node ./node_modules/proximity_sequelize_migrations/bin/makemigration --name <migration name>

  • Change models and run it again, model difference will be saved to the next migration

To preview new migration, without any changes, you can run:

node ./node_modules/sequelize-auto-migrations/bin/makemigration --preview

makemigration tool creates _current.json and _current_bak.json files in migrations dir, which are used to track changes. Do not remove!

To create and then execute migration immediately, use: makemigration --name <name> -x

Executing migrations

  • There is simple command to perform all created migrations (from selected revision):

node ./node_modules/sequelize-auto-migrations/bin/runmigration

  • To select a revision, use --rev <x>
  • If migration fails, you can continue, use --pos <x>
  • To prevent execution next migrations, use --one

For more information, use makemigration --help, runmigration --help

TODO:

  • Migration action sorting procedure need some fixes. When many foreign keys in tables, there is a bug with action order. Now, please check it manually (--preview option)
  • Need to check (and maybe fix) field types: BLOB, RANGE, ARRAY, GEOMETRY, GEOGRAPHY
  • Version control needs work, specifically the revision system
  • Fix db initialisation bug

Current Tags

  • 1.0.4                                ...           latest (2 years ago)

5 Versions

  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 2
Dependencies (7)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |