package main import ( "gorm.io/driver/sqlite" "gorm.io/gorm" "gorm.io/gorm/schema" ) // CustomDialector allows for customization of the type affinity for booleans. type CustomDialector struct { sqlite.Dialector } // CustomMigrator overrides behavior of the SQLite migrator. type CustomMigrator struct { sqlite.Migrator } // DataTypeOf returns the data type for the supplied field. func (d CustomDialector) DataTypeOf(field *schema.Field) string { if field.DataType == schema.Bool { return "integer" } return d.Dialector.DataTypeOf(field) } // Migrator returns the migrator for the dialector. func (d CustomDialector) Migrator(db *gorm.DB) gorm.Migrator { m := d.Dialector.Migrator(db).(sqlite.Migrator) m.Migrator.Config.Dialector = d return m } func main() { c, err := gorm.Open( CustomDialector{ sqlite.Dialector{ DSN: "filename.db", }, }, &gorm.Config{}, ) if err != nil { panic(err) } // TODO: do something with c }