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 ca91b664
authored
Jan 03, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sequelize --init is creating the migrations folder now
1 parent
e22d93ac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletions
bin/sequelize
bin/sequelize
View file @
ca91b66
...
...
@@ -7,6 +7,7 @@ const path = require("path")
,
_
=
Sequelize
.
Utils
.
_
var
configPath
=
__dirname
+
'/../config'
,
migrationsPath
=
__dirname
+
'/../migrations'
,
configFile
=
configPath
+
'/config.json'
,
configPathExists
=
path
.
existsSync
(
configPath
)
,
configFileExists
=
path
.
existsSync
(
configFile
)
...
...
@@ -22,6 +23,29 @@ var writeConfig = function(config) {
fs
.
writeFileSync
(
configFile
,
config
)
}
var
createMigrationsFolder
=
function
(
force
)
{
if
(
force
)
{
console
.
log
(
'Deleting the migrations folder.'
)
try
{
fs
.
readdirSync
(
migrationsPath
).
forEach
(
function
(
filename
)
{
fs
.
unlinkSync
(
migrationsPath
+
'/'
+
filename
)
})
}
catch
(
e
)
{}
try
{
fs
.
rmdirSync
(
migrationsPath
)
console
.
log
(
'Successfully deleted the migrations folder.'
)
}
catch
(
e
)
{}
}
console
.
log
(
'Creating migrations folder.'
)
try
{
fs
.
mkdirSync
(
migrationsPath
)
console
.
log
(
'Successfully create migrations folder.'
)
}
catch
(
e
)
{
console
.
log
(
'Migrations folder already exist.'
)
}
}
var
readConfig
=
function
()
{
try
{
return
JSON
.
parse
(
fs
.
readFileSync
(
configFile
))
...
...
@@ -58,8 +82,9 @@ if(program.migrate) {
if
(
program
.
undo
)
{
sequelize
.
migrator
.
findOrCreateSequelizeMetaModel
().
success
(
function
(
Meta
)
{
Meta
.
find
({
order
:
'id DESC'
}).
success
(
function
(
meta
)
{
if
(
meta
)
if
(
meta
)
{
migrator
=
sequelize
.
getMigrator
(
_
.
extend
(
migratorOptions
,
meta
),
true
)
}
migrator
.
migrate
({
method
:
'down'
})
})
...
...
@@ -83,6 +108,8 @@ if(program.migrate) {
}
else
{
console
.
log
(
'A config.json already exists. Run "sequelize --init --force" to overwrite it.'
)
}
createMigrationsFolder
(
program
.
force
)
}
else
{
console
.
log
(
'Please define any params!'
)
}
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