mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-05 05:50:19 +08:00
Improve error handling in migrator
This commit is contained in:
@ -49,19 +49,27 @@ func (*Migrator_1_240_0_PR_1539) DoMigration() *migrate.Migration {
|
|||||||
SessionId []string `json:"sessionId"`
|
SessionId []string `json:"sessionId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
|
||||||
tx := engine.NewSession()
|
tx := engine.NewSession()
|
||||||
|
|
||||||
defer tx.Close()
|
defer tx.Close()
|
||||||
|
|
||||||
tx.Begin()
|
err := tx.Begin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
tx.Table("session_tmp").CreateTable(&Session{})
|
err = tx.Table("session_tmp").CreateTable(&Session{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
oldSessions := []*oldSession{}
|
oldSessions := []*oldSession{}
|
||||||
newSessions := []*Session{}
|
newSessions := []*Session{}
|
||||||
|
|
||||||
tx.Table("session").Find(&oldSessions)
|
err = tx.Table("session").Find(&oldSessions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, oldSession := range oldSessions {
|
for _, oldSession := range oldSessions {
|
||||||
newApplication := "null"
|
newApplication := "null"
|
||||||
|
Reference in New Issue
Block a user