Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 0920a17a
authored
Dec 31, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added undo for migrations
1 parent
3992d875
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
bin/sequelize
bin/sequelize
View file @
0920a17
...
@@ -34,6 +34,7 @@ program
...
@@ -34,6 +34,7 @@ program
.
version
(
'1.3.0'
)
.
version
(
'1.3.0'
)
.
option
(
'-i, --init'
,
'Initializes the project. Creates a config/config.json'
)
.
option
(
'-i, --init'
,
'Initializes the project. Creates a config/config.json'
)
.
option
(
'-m, --migrate'
,
'Runs undone migrations'
)
.
option
(
'-m, --migrate'
,
'Runs undone migrations'
)
.
option
(
'-u, --undo'
,
'Redo the last migration.'
)
.
option
(
'-f, --force'
,
'Forces the action to be done.'
)
.
option
(
'-f, --force'
,
'Forces the action to be done.'
)
.
parse
(
process
.
argv
)
.
parse
(
process
.
argv
)
...
@@ -50,8 +51,22 @@ if(program.migrate) {
...
@@ -50,8 +51,22 @@ if(program.migrate) {
options
=
_
.
extend
(
options
,
{
logging
:
false
})
options
=
_
.
extend
(
options
,
{
logging
:
false
})
var
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
options
)
var
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
options
)
sequelize
.
migrate
({
path
:
__dirname
+
'/../spec/assets/migrations'
})
,
migratorOptions
=
{
path
:
__dirname
+
'/../spec/assets/migrations'
}
,
migrator
=
sequelize
.
getMigrator
(
migratorOptions
)
if
(
program
.
undo
)
{
sequelize
.
migrator
.
findOrCreateSequelizeMetaModel
().
success
(
function
(
Meta
)
{
Meta
.
find
({
order
:
'id DESC'
}).
success
(
function
(
meta
)
{
if
(
meta
)
migrator
=
sequelize
.
getMigrator
(
_
.
extend
(
migratorOptions
,
meta
),
true
)
migrator
.
migrate
({
method
:
'down'
})
})
})
}
else
{
sequelize
.
migrate
()
}
}
else
{
}
else
{
throw
new
Error
(
'Please add a configuration file under config/config.json. You might run "sequelize --init".'
)
throw
new
Error
(
'Please add a configuration file under config/config.json. You might run "sequelize --init".'
)
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment