mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-31 15:21:00 +08:00
Fix order by parameter (#19849)
Upgrade builder to v0.3.11 Upgrade xorm to v1.3.1 and fixed some hidden bugs. Replace #19821 Replace #19834 Included #19850 Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@ -86,21 +87,23 @@ func setDefaultPasswordToArgon2(x *xorm.Engine) error {
|
||||
}
|
||||
return x.Sync2(new(User))
|
||||
}
|
||||
|
||||
tempTableName := "tmp_recreate__user"
|
||||
column.Default = "'argon2'"
|
||||
|
||||
createTableSQL, _, err := x.Dialect().CreateTableSQL(context.Background(), x.DB(), table, tempTableName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err := sess.Begin(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tempTableName := "tmp_recreate__user"
|
||||
column.Default = "'argon2'"
|
||||
|
||||
createTableSQL, _ := x.Dialect().CreateTableSQL(table, tempTableName)
|
||||
for _, sql := range createTableSQL {
|
||||
if _, err := sess.Exec(sql); err != nil {
|
||||
log.Error("Unable to create table %s. Error: %v\n", tempTableName, err, createTableSQL)
|
||||
return err
|
||||
}
|
||||
if _, err := sess.Exec(createTableSQL); err != nil {
|
||||
log.Error("Unable to create table %s. Error: %v\n", tempTableName, err, createTableSQL)
|
||||
return err
|
||||
}
|
||||
for _, index := range table.Indexes {
|
||||
if _, err := sess.Exec(x.Dialect().CreateIndexSQL(tempTableName, index)); err != nil {
|
||||
|
@ -24,8 +24,9 @@ func convertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
|
||||
SQLType: schemas.SQLType{
|
||||
Name: "VARCHAR",
|
||||
},
|
||||
Length: 16,
|
||||
Nullable: true, // To keep compatible as nullable
|
||||
Length: 16,
|
||||
Nullable: true, // To keep compatible as nullable
|
||||
DefaultIsEmpty: true,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -49,8 +50,9 @@ func convertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
|
||||
SQLType: schemas.SQLType{
|
||||
Name: "VARCHAR",
|
||||
},
|
||||
Length: 16,
|
||||
Nullable: true, // To keep compatible as nullable
|
||||
Length: 16,
|
||||
Nullable: true, // To keep compatible as nullable
|
||||
DefaultIsEmpty: true,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ func convertAvatarURLToText(x *xorm.Engine) error {
|
||||
SQLType: schemas.SQLType{
|
||||
Name: schemas.Text,
|
||||
},
|
||||
Nullable: true,
|
||||
Nullable: true,
|
||||
DefaultIsEmpty: true,
|
||||
})
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ func migrateUserPasswordSalt(x *xorm.Engine) error {
|
||||
},
|
||||
Length: 32,
|
||||
// MySQL will like us again.
|
||||
Nullable: true,
|
||||
Nullable: true,
|
||||
DefaultIsEmpty: true,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -33,7 +34,8 @@ func migrateUserPasswordSalt(x *xorm.Engine) error {
|
||||
SQLType: schemas.SQLType{
|
||||
Name: "VARCHAR",
|
||||
},
|
||||
Length: 32,
|
||||
Nullable: true,
|
||||
Length: 32,
|
||||
Nullable: true,
|
||||
DefaultIsEmpty: true,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user