Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sequelize migration generator and es6 init tool (Planned)

License

NotificationsYou must be signed in to change notification settings

MRVMV/sequelize-mig

 
 

npmnodeBuild StatusSnyk Vulnerabilities for GitHub RepoLGTM Grade

semantic-releaseContribution-WelcomedCommunity Chat

Warning: THIS TOOL IS UNDER DEVELOPMENT AND NOT INTENDED TO PRODUCTION USE RIGHT NOW!!!!

The tool is built using es6And its not intended to replace sequelize-cli its just completing it

This tool provide these commands:

  • migration:make ormigration:add - to create new migrations by comparing new version of your modules to old ones
  • migration:undo ormigration:revert - delete last migration file and return to backup state file of the models
  • migration:sync - Sync the models schema file with current models without migrating (Planned)

Planned:

  • init - tool to init required files for sequelize using new es6 schema (Planned)

Install

(Globally - Recommended)

npm install sequelize-mig -g / yarn global add sequelize-mig

Or

(devDependencies)

npm install sequelize-mig -D / yarn add sequelize-mig -D

Usage

For New Users

  • Init sequelize, with sequelize-cli, usingsequelize init (or using es6 init by sequelize-mig -Planned-)
  • Create your models manually or using sequelize-cli (or using es6 init by sequelize-mig -Planned-)
  • Create initial migration:
sequelize-mig migration:make -n<migration name>
  • To preview new migration, without any changes, you can run:
sequelize-mig migration:make --preview
  • Finally run migration using sequelize-clisequelize db:migrate
  • You can use --help to view help of the tool or specific command

For Old Users

If you already used migrations before knowing this tool you can easily fully migrate in the sequelize-cli tooland then runmigration:sync and tool will update_current.jsonand you can continue using this tool normally

Limitations

The migration:make tool supports auto detecting these actions

dropTable, removeColumn, removeIndex,createTable, addColumn, addIndex,changeColumn

and Im trying to find a way to know old column name to implement renameColumn because it's now translated to removeColumn then addColumn

Explanation

The tool works by getting the schema of the models into_current.json and every time you runmigration:make the tool will compare this file with new schema and write the new migration filethenthis tool cant actually know if you deleted, or migrated or whatever you edited to these files...

Notes

  • You will be able to make index and modules as es6 but keep migration files as es5 because sequelize-cli isn't compatible with it yet.
  • migration:make tool creates_current.json and_current_bak.json files inmigrations dir, these are used to calculate difference to the next migration. Do not remove them!
  • Tool create new migration with name{timestamp}_{name}.{js|cjs} but you can change every single option with parameters

TODO

  • Allow init using es6 modules
  • AddingrenameColumn in some way I didn't know until now (maybe comments)
  • auto add renameColumn conversion when edits are only to letters case or adding _

Credits

  • Depending on Scimonster/sequelize-auto-migrations which is forked from flexxnn/sequelize-auto-migrations
  • The main projects are not maintained any more

About

Sequelize migration generator and es6 init tool (Planned)

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors21


[8]ページ先頭

©2009-2025 Movatter.jp