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 fc91b751
authored
Oct 11, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable foreign keys for sqlite before dropping all tables
1 parent
e82fcfe1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
lib/dialects/sqlite/query-interface.js
lib/dialects/sqlite/query-interface.js
View file @
fc91b75
...
@@ -118,5 +118,60 @@ var QueryInterface = module.exports = {
...
@@ -118,5 +118,60 @@ var QueryInterface = module.exports = {
queryAndEmit
.
call
(
this
,
queries
.
splice
(
queries
.
length
-
1
)[
0
],
methodName
,
{},
emitter
)
queryAndEmit
.
call
(
this
,
queries
.
splice
(
queries
.
length
-
1
)[
0
],
methodName
,
{},
emitter
)
}
}
}.
bind
(
this
))
}.
bind
(
this
))
},
dropAllTables
:
function
()
{
var
self
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
dropAllTablesEmitter
)
{
var
events
=
[]
,
chainer
=
new
Utils
.
QueryChainer
()
,
onError
=
function
(
err
)
{
self
.
emit
(
'dropAllTables'
,
err
)
dropAllTablesEmitter
.
emit
(
'error'
,
err
)
}
self
.
showAllTables
()
.
error
(
onError
)
.
success
(
function
(
tableNames
)
{
self
.
sequelize
.
query
(
'PRAGMA foreign_keys;'
)
.
proxy
(
dropAllTablesEmitter
,
{
events
:
[
'sql'
]
})
.
error
(
onError
)
.
success
(
function
(
result
)
{
var
foreignKeysAreEnabled
=
result
.
foreign_keys
===
1
if
(
foreignKeysAreEnabled
)
{
var
queries
=
[]
queries
.
push
(
'PRAGMA foreign_keys = OFF'
)
tableNames
.
forEach
(
function
(
tableName
)
{
queries
.
push
(
self
.
QueryGenerator
.
dropTableQuery
(
tableName
).
replace
(
';'
,
''
))
})
queries
.
push
(
'PRAGMA foreign_keys = ON'
)
QueryInterface
.
execMultiQuery
.
call
(
self
,
queries
,
'dropAllTables'
,
dropAllTablesEmitter
,
self
.
queryAndEmit
)
}
else
{
// add the table removal query to the chainer
tableNames
.
forEach
(
function
(
tableName
)
{
chainer
.
add
(
self
,
'dropTable'
,
[
tableName
,
{
cascade
:
true
}
])
})
chainer
.
runSerially
()
.
proxy
(
dropAllTablesEmitter
,
{
events
:
[
'sql'
]
})
.
error
(
onError
)
.
success
(
function
()
{
self
.
emit
(
'dropAllTables'
,
null
)
dropAllTablesEmitter
.
emit
(
'success'
,
null
)
})
}
})
})
}).
run
()
}
}
}
}
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