This repository was archived by the owner on Aug 17, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-6
lines changed
Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,12 @@ This package provide two tools:
1313* Create your models
1414* Create initial migration - run:
1515
16- ` node ./node_modules/sequelize-auto-migrations/bin/ makemigration --name <migration name>`
16+ ` makemigration --name <migration name> `
1717* Change models and run it again, model difference will be saved to the next migration
1818
1919To preview new migration, without any changes, you can run:
2020
21- ` node ./node_modules/sequelize-auto-migrations/bin/ makemigration --preview`
21+ ` makemigration --preview `
2222
2323` makemigration ` tool creates ` _current.json ` file in ` migrations ` dir, that is used to calculate difference to the next migration. Do not remove it!
2424
@@ -28,7 +28,7 @@ To create and then execute migration, use:
2828## Executing migrations
2929* There is simple command to perform all created migrations (from selected revision):
3030
31- ` node ./node_modules/sequelize-auto-migrations/bin/ runmigration`
31+ ` runmigration `
3232* To select a revision, use ` --rev <x> `
3333* If migration fails, you can continue, use ` --pos <x> `
3434* To prevent execution next migrations, use ` --one `
Original file line number Diff line number Diff line change 1- #!/bin/node
1+ #!/usr/ bin/env node
22
33const commandLineArgs = require ( 'command-line-args' ) ;
44const beautify = require ( 'js-beautify' ) . js_beautify ;
@@ -32,6 +32,7 @@ if (options.help)
3232 process . exit ( 0 ) ;
3333}
3434
35+ // Windows support
3536if ( ! process . env . PWD ) {
3637 process . env . PWD = process . cwd ( )
3738}
@@ -41,6 +42,16 @@ const {
4142 modelsDir
4243} = pathConfig ( options ) ;
4344
45+ if ( ! fs . existsSync ( modelsDir ) ) {
46+ console . log ( "Can't find models directory. Use `sequelize init` to create it" )
47+ return
48+ }
49+
50+ if ( ! fs . existsSync ( migrationsDir ) ) {
51+ console . log ( "Can't find migrations directory. Use `sequelize init` to create it" )
52+ return
53+ }
54+
4455// current state
4556const currentState = {
4657 tables : { }
Original file line number Diff line number Diff line change 1- #!/bin/node
1+ #!/usr/ bin/env node
22
33const path = require ( "path" ) ;
44const commandLineArgs = require ( 'command-line-args' ) ;
@@ -20,6 +20,7 @@ const optionDefinitions = [
2020
2121const options = commandLineArgs ( optionDefinitions ) ;
2222
23+ // Windows support
2324if ( ! process . env . PWD ) {
2425 process . env . PWD = process . cwd ( )
2526}
2930 modelsDir
3031} = pathConfig ( options ) ;
3132
33+ if ( ! fs . existsSync ( modelsDir ) ) {
34+ console . log ( "Can't find models directory. Use `sequelize init` to create it" )
35+ return
36+ }
37+
38+ if ( ! fs . existsSync ( migrationsDir ) ) {
39+ console . log ( "Can't find migrations directory. Use `sequelize init` to create it" )
40+ return
41+ }
42+
3243if ( options . help )
3344{
3445 console . log ( "Simple sequelize migration execution tool\n\nUsage:" ) ;
@@ -39,7 +50,6 @@ if (options.help)
3950 process . exit ( 0 ) ;
4051}
4152
42- const Sequelize = require ( "sequelize" ) ;
4353const sequelize = require ( modelsDir ) . sequelize ;
4454const queryInterface = sequelize . getQueryInterface ( ) ;
4555
You can’t perform that action at this time.
0 commit comments