Fix mssql

This commit is contained in:
Lunny Xiao 2020-03-13 23:51:41 +08:00
parent b5b6cb51e8
commit 9c55057ef2
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 4 additions and 0 deletions

View File

@ -388,6 +388,10 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
return err return err
} }
} }
if len(table.PKColumns()) > 0 && engine.dialect.URI().DBType == schemas.MSSQL {
fmt.Fprintf(w, "SET IDENTITY_INSERT [%s] ON;\n", table.Name)
}
for _, index := range table.Indexes { for _, index := range table.Indexes {
_, err = io.WriteString(w, dialect.CreateIndexSQL(table.Name, index)+";\n") _, err = io.WriteString(w, dialect.CreateIndexSQL(table.Name, index)+";\n")
if err != nil { if err != nil {