This commit is contained in:
Lunny Xiao 2024-02-08 16:26:18 +08:00
parent 140ee90928
commit 5b41d53f25
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 7 additions and 12 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"reflect"
"xorm.io/xorm" "xorm.io/xorm"
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
@ -196,19 +197,13 @@ func (m *Migrate) createMigrationTableIfNotExists() error {
return nil return nil
} }
idCol := schemas.Column{ idCol := schemas.NewColumn(m.options.IDColumnName, "", schemas.SQLType{
Name: m.options.IDColumnName, Name: "VARCHAR",
SQLType: schemas.SQLType{ }, 255, 0, true)
Name: "VARCHAR", idCol.IsPrimaryKey = true
DefaultLength: 255,
},
IsPrimaryKey: true,
}
table := &schemas.Table{ table := schemas.NewTable(m.options.TableName, reflect.TypeOf(new(schemas.Table)))
Name: m.options.TableName, table.AddColumn(idCol)
}
table.AddColumn(&idCol)
sql, _, err := m.db.Dialect().CreateTableSQL(context.Background(), m.db.DB(), table, m.options.TableName) sql, _, err := m.db.Dialect().CreateTableSQL(context.Background(), m.db.DB(), table, m.options.TableName)
if err != nil { if err != nil {