Skip to content

Commit

Permalink
fix copy migration at dockerfile
Browse files Browse the repository at this point in the history
fix error handling at db init
  • Loading branch information
wen-templari committed May 21, 2024
1 parent 206b800 commit b6fc8f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apk add --no-cache tzdata &&\

WORKDIR /app
COPY --from=builder /app/saturday /app
COPY --from=builder /app/migrations /app
COPY --from=builder /app/migrations /app/migrations

ENV Port=80

Expand Down
7 changes: 4 additions & 3 deletions repo/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ func InitDB() {
m, err := migrate.NewWithDatabaseInstance(
"file://migrations",
"postgres", driver)
m.Up() // or m.Step(2) if you want to explicitly set the number of migrations to run
m.Close()

if err != nil {
util.Logger.Fatal(err)
}

m.Up() // or m.Step(2) if you want to explicitly set the number of migrations to run
m.Close()

db.SetMaxOpenConns(1000) // The default is 0 (unlimited)
db.SetMaxIdleConns(10) // defaultMaxIdleConns = 2
db.SetConnMaxLifetime(time.Minute * 5) // 0, connections are reused forever.
Expand Down

0 comments on commit b6fc8f7

Please sign in to comment.