Fix migration v210 (#18893)
This commit is contained in:
parent
6f21a94d18
commit
c077a0361a
1 changed files with 10 additions and 4 deletions
|
@ -137,10 +137,15 @@ func remigrateU2FCredentials(x *xorm.Engine) error {
|
||||||
CreatedUnix: reg.CreatedUnix,
|
CreatedUnix: reg.CreatedUnix,
|
||||||
}
|
}
|
||||||
|
|
||||||
has, err := sess.ID(reg.ID).Where("id = ?", reg.ID).Get(new(webauthnCredential))
|
has, err := sess.ID(reg.ID).Get(new(webauthnCredential))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get webauthn_credential[%d]. Error: %w", reg.ID, err)
|
return fmt.Errorf("unable to get webauthn_credential[%d]. Error: %w", reg.ID, err)
|
||||||
}
|
}
|
||||||
|
if !has {
|
||||||
|
has, err := sess.Where("`lower_name`=?", remigrated.LowerName).And("`user_id`=?", remigrated.UserID).Exist(new(webauthnCredential))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to check webauthn_credential[lower_name: %s, user_id:%v]. Error: %w", remigrated.LowerName, remigrated.UserID, err)
|
||||||
|
}
|
||||||
if !has {
|
if !has {
|
||||||
_, err = sess.Insert(remigrated)
|
_, err = sess.Insert(remigrated)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -149,6 +154,7 @@ func remigrateU2FCredentials(x *xorm.Engine) error {
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err = sess.ID(remigrated.ID).AllCols().Update(remigrated)
|
_, err = sess.ID(remigrated.ID).AllCols().Update(remigrated)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue