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 8d9e58b4
authored
May 02, 2020
by
Sushant
Committed by
GitHub
May 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(sync): pass options to all query methods (#12208)
1 parent
4c674e29
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
lib/model.js
lib/model.js
View file @
8d9e58b
...
...
@@ -1284,23 +1284,25 @@ class Model {
if
(
options
.
force
)
{
await
this
.
drop
(
options
);
}
await
this
.
QueryInterface
.
createTable
(
this
.
getTableName
(
options
),
attributes
,
options
,
this
);
const
tableName
=
this
.
getTableName
(
options
);
await
this
.
QueryInterface
.
createTable
(
tableName
,
attributes
,
options
,
this
);
if
(
options
.
alter
)
{
const
tableInfos
=
await
Promise
.
all
([
this
.
QueryInterface
.
describeTable
(
t
his
.
getTableName
(
options
)
),
this
.
QueryInterface
.
getForeignKeyReferencesForTable
(
t
his
.
getTableName
(
options
)
)
this
.
QueryInterface
.
describeTable
(
t
ableName
,
options
),
this
.
QueryInterface
.
getForeignKeyReferencesForTable
(
t
ableName
,
options
)
]);
const
columns
=
tableInfos
[
0
];
// Use for alter foreign keys
const
foreignKeyReferences
=
tableInfos
[
1
];
const
removedConstraints
=
{};
for
(
const
columnName
in
attributes
)
{
if
(
!
Object
.
prototype
.
hasOwnProperty
.
call
(
attributes
,
columnName
))
continue
;
if
(
!
columns
[
columnName
]
&&
!
columns
[
attributes
[
columnName
].
field
])
{
await
this
.
QueryInterface
.
addColumn
(
t
his
.
getTableName
(
options
),
attributes
[
columnName
].
field
||
columnName
,
attributes
[
columnName
]
);
await
this
.
QueryInterface
.
addColumn
(
t
ableName
,
attributes
[
columnName
].
field
||
columnName
,
attributes
[
columnName
],
options
);
}
}
...
...
@@ -1309,7 +1311,7 @@ class Model {
if
(
!
Object
.
prototype
.
hasOwnProperty
.
call
(
columns
,
columnName
))
continue
;
const
currentAttribute
=
rawAttributes
[
columnName
];
if
(
!
currentAttribute
)
{
await
this
.
QueryInterface
.
removeColumn
(
t
his
.
getTableName
(
options
)
,
columnName
,
options
);
await
this
.
QueryInterface
.
removeColumn
(
t
ableName
,
columnName
,
options
);
continue
;
}
if
(
currentAttribute
.
primaryKey
)
continue
;
...
...
@@ -1329,16 +1331,16 @@ class Model {
&&
(
schema
?
foreignKeyReference
.
referencedTableSchema
===
schema
:
true
)
&&
!
removedConstraints
[
constraintName
])
{
// Remove constraint on foreign keys.
await
this
.
QueryInterface
.
removeConstraint
(
t
his
.
getTableName
(
options
)
,
constraintName
,
options
);
await
this
.
QueryInterface
.
removeConstraint
(
t
ableName
,
constraintName
,
options
);
removedConstraints
[
constraintName
]
=
true
;
}
}
}
await
this
.
QueryInterface
.
changeColumn
(
t
his
.
getTableName
(
options
),
columnName
,
currentAttribute
);
await
this
.
QueryInterface
.
changeColumn
(
t
ableName
,
columnName
,
currentAttribute
,
options
);
}
}
}
let
indexes
=
await
this
.
QueryInterface
.
showIndex
(
t
his
.
getTableName
(
options
)
,
options
);
let
indexes
=
await
this
.
QueryInterface
.
showIndex
(
t
ableName
,
options
);
indexes
=
this
.
_indexes
.
filter
(
item1
=>
!
indexes
.
some
(
item2
=>
item1
.
name
===
item2
.
name
)
).
sort
((
index1
,
index2
)
=>
{
...
...
@@ -1352,20 +1354,13 @@ class Model {
});
for
(
const
index
of
indexes
)
{
await
this
.
QueryInterface
.
addIndex
(
this
.
getTableName
(
options
),
Object
.
assign
({
logging
:
options
.
logging
,
benchmark
:
options
.
benchmark
,
transaction
:
options
.
transaction
,
schema
:
options
.
schema
},
index
),
this
.
tableName
);
await
this
.
QueryInterface
.
addIndex
(
tableName
,
Object
.
assign
({},
options
,
index
));
}
if
(
options
.
hooks
)
{
await
this
.
runHooks
(
'afterSync'
,
options
);
}
return
this
;
}
...
...
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