Skip to content

Commit

Permalink
Fix: ssl mode has multi contents (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
AH-dark authored Sep 12, 2022
1 parent 1283eb0 commit 5a54573
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions model/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,13 @@ func NewDatabase() (*gorm.DB, error) {
conf.DataSourceConfig.Database,
))
case "postgres", "postgresql":
ssl := "disable"
if conf.DataSourceConfig.SSL {
ssl = "enable"
}
dialect = postgres.Open(fmt.Sprintf("host=%s port=%d user=%s dbname=%s password=%s sslmode=%s TimeZone=%s",
conf.DataSourceConfig.Host,
conf.DataSourceConfig.Port,
conf.DataSourceConfig.Username,
conf.DataSourceConfig.Database,
conf.DataSourceConfig.Password,
ssl,
conf.DataSourceConfig.SSLMode,
time.Local.String(),
))
case "mssql", "sqlserver":
Expand Down
2 changes: 1 addition & 1 deletion pkg/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type datasource struct {
Password string
File string
Prefix string
SSL bool
SSLMode string
}

type redis struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/conf/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var DataSourceConfig = &datasource{
Password: env("DB_PASSWORD", "root"),
File: env("DB_FILE", "leziapi.db"),
Prefix: env("DB_PREFIX", "lezi_"),
SSL: env("DB_SSL", "false") == "true",
SSLMode: env("DB_SSL", "disable"),
}

var RedisConfig = &redis{
Expand Down

0 comments on commit 5a54573

Please sign in to comment.