Skip to content

Commit

Permalink
Merge pull request #430 from traPtitech/fix/location
Browse files Browse the repository at this point in the history
🐛 add loc
  • Loading branch information
ras0q committed Jun 27, 2023
2 parents 4259ae3 + 87b3b05 commit 7c5e651
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion infra/db/db.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package db

import (
"time"

gomysql "github.com/go-sql-driver/mysql"
"github.com/traPtitech/knoQ/migration"
"gorm.io/driver/mysql"
Expand All @@ -15,7 +17,7 @@ type GormRepository struct {

var tokenKey []byte

func (repo *GormRepository) Setup(host, user, password, database, port, key, logLevel string) error {
func (repo *GormRepository) Setup(host, user, password, database, port, key, logLevel string, loc *time.Location) error {
loglevel := func() logger.LogLevel {
switch logLevel {
case "slient":
Expand Down Expand Up @@ -43,6 +45,7 @@ func (repo *GormRepository) Setup(host, user, password, database, port, key, log
Net: "tcp",
Addr: host + ":" + port,
DBName: database,
Loc: loc,
AllowNativePasswords: true,
ParseTime: true,
},
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ var (
webhookSecret = getenv("WEBHOOK_SECRET", "")
activityChannelID = getenv("ACTIVITY_CHANNEL_ID", "")
dailyChannelID = getenv("DAILY_CHANNEL_ID", "")

jst, _ = time.LoadLocation("Asia/Tokyo")
)

func main() {
Expand All @@ -51,7 +53,7 @@ func main() {
domain.DEVELOPMENT, _ = strconv.ParseBool(development)

gormRepo := db.GormRepository{}
err := gormRepo.Setup(mariadbHost, mariadbUser, mariadbPassword, mariadbDatabase, mariadbPort, tokenKey, gormLogLevel)
err := gormRepo.Setup(mariadbHost, mariadbUser, mariadbPassword, mariadbDatabase, mariadbPort, tokenKey, gormLogLevel, jst)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 7c5e651

Please sign in to comment.