fix: sqlite dialector cannot apply PRIMARY KEY AUTOINCREMENT type

fix #4760
This commit is contained in:
Samuel N Cui 2023-10-04 22:33:48 +08:00
parent e57e5d8884
commit 3fe5335dfd

View File

@ -217,7 +217,7 @@ func (m Migrator) CreateTable(values ...interface{}) error {
field := stmt.Schema.FieldsByDBName[dbName] field := stmt.Schema.FieldsByDBName[dbName]
if !field.IgnoreMigration { if !field.IgnoreMigration {
createTableSQL += "? ?" createTableSQL += "? ?"
hasPrimaryKeyInDataType = hasPrimaryKeyInDataType || strings.Contains(strings.ToUpper(string(field.DataType)), "PRIMARY KEY") hasPrimaryKeyInDataType = hasPrimaryKeyInDataType || strings.Contains(strings.ToUpper(m.DataTypeOf(field)), "PRIMARY KEY")
values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field)) values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field))
createTableSQL += "," createTableSQL += ","
} }