Skip to content

Commit

Permalink
fix: Sqlite强制外键约束
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Apr 7, 2024
1 parent 9610841 commit aed43f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
// 容器镜像
github.com/opencontainers/image-spec v1.1.0
// 辅助类库
github.com/opentdp/go-helper v0.7.2-0.20240401033254-82dada9d897b
github.com/opentdp/go-helper v0.7.2
// 计划任务
github.com/robfig/cron/v3 v3.0.1
// Go 官方模块
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
github.com/opentdp/go-helper v0.7.2-0.20240401033254-82dada9d897b h1:qOmmQAQ0wp04kamUya1/MYFC0vLMRtBgd1DlNLjtzTM=
github.com/opentdp/go-helper v0.7.2-0.20240401033254-82dada9d897b/go.mod h1:bRR6EpSuQNNNwgCSWwwuO90Lh1lUG+PnMa6PFS41mF8=
github.com/opentdp/go-helper v0.7.2 h1:u0DGQ8JxbyApcNPYAurQ1CqOhdUyw7/sVXcDdJP3JQE=
github.com/opentdp/go-helper v0.7.2/go.mod h1:bRR6EpSuQNNNwgCSWwwuO90Lh1lUG+PnMa6PFS41mF8=
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
4 changes: 1 addition & 3 deletions service/server/origin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ func dbConnect() {
Option: args.Gormio.Option,
})

// 设置默认参数
// 开启外键约束
if args.Gormio.Type == "sqlite" {
dborm.Db.Exec("PRAGMA foreign_keys=ON;")
dborm.Db.Exec("PRAGMA journal_mode=WAL;")
dborm.Db.Exec("PRAGMA busy_timeout=5000;")
}

// 实施自动迁移
Expand Down

0 comments on commit aed43f9

Please sign in to comment.