chore(sync): 上游同步 - 快照导入 upstream/main@e70fe1b9(v1.6.5)并重放本项目差异

This commit is contained in:
2026-10-12 11:52:01 +08:00
parent c9979a4a2b
commit 43c3dd3568
167 changed files with 5794 additions and 7804 deletions

View File

@@ -8,6 +8,7 @@ import (
"yingce/backend/internal/logging"
"github.com/jackc/pgx/v5/stdlib"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -39,7 +40,10 @@ func Open(config Config) (*gorm.DB, error) {
if dsn == "" {
return nil, errors.New("PostgreSQL 模式必须配置 DATABASE_URL")
}
return gorm.Open(postgres.Open(dsn), &gorm.Config{Logger: logging.GormLogger()})
return gorm.Open(postgres.New(postgres.Config{
DSN: dsn,
OptionOpenDB: []stdlib.OptionOpenDB{stdlib.OptionBeforeConnect(configurePostgresConnection)},
}), &gorm.Config{Logger: logging.GormLogger()})
default:
return nil, fmt.Errorf("不支持的数据库驱动:%s", driver)
}