Skip to content

Commit

Permalink
🎨 change fotmat
Browse files Browse the repository at this point in the history
  • Loading branch information
iChemy committed Jul 22, 2024
1 parent ed39d08 commit 0fd0de1
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions infra/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,27 @@ func (repo *GormRepository) Setup(host, user, password, database, port, key, log
tokenKey = []byte(key)

var err error
repo.db, err = gorm.Open(mysql.New(mysql.Config{
DSNConfig: &gomysql.Config{
User: user,
Passwd: password,
Net: "tcp",
Addr: host + ":" + port,
DBName: database,
Loc: loc,
AllowNativePasswords: true,
ParseTime: true,
},
DefaultStringSize: 256, // default size for string fields
DisableDatetimePrecision: true, // disable datetime precision, which not supported before MySQL 5.6
DontSupportRenameIndex: true, // drop & create when rename index, rename index not supported before MySQL 5.7, MariaDB
DontSupportRenameColumn: false, // `change` when rename column, rename column not supported before MySQL 8, MariaDB
SkipInitializeWithVersion: false, // auto configure based on currently MySQL version
}), &gorm.Config{
Logger: logger.Default.LogMode(loglevel),
})
repo.db, err = gorm.Open(
mysql.New(mysql.Config{
DSNConfig: &gomysql.Config{
User: user,
Passwd: password,
Net: "tcp",
Addr: host + ":" + port,
DBName: database,
Loc: loc,
AllowNativePasswords: true,
ParseTime: true,
},
DefaultStringSize: 256, // default size for string fields
DisableDatetimePrecision: true, // disable datetime precision, which not supported before MySQL 5.6
DontSupportRenameIndex: true, // drop & create when rename index, rename index not supported before MySQL 5.7, MariaDB
DontSupportRenameColumn: false, // `change` when rename column, rename column not supported before MySQL 8, MariaDB
SkipInitializeWithVersion: false, // auto configure based on currently MySQL version
}),
&gorm.Config{
Logger: logger.Default.LogMode(loglevel),
})
if err != nil {
return err
}
Expand Down

0 comments on commit 0fd0de1

Please sign in to comment.