From 98520d6315a3149266584d34722d4102a85695b9 Mon Sep 17 00:00:00 2001 From: timerzz Date: Sun, 12 May 2024 22:27:12 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E6=94=B9gorm=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3pgsql=20automrigate=20=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/model/pusher.go | 2 +- pkg/pusher/anPush_test.go | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 2637724..6406eee 100644 --- a/go.mod +++ b/go.mod @@ -9,10 +9,10 @@ require ( github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/metacubex/mihomo v1.18.3 github.com/pkg/errors v0.9.1 - github.com/timerzz/proxypool v0.0.0-20240407102509-f13ba2d1b0ca + github.com/timerzz/proxypool v0.0.0-20240512142241-f74bcb3534c5 gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/postgres v1.5.2 - gorm.io/gorm v1.25.9 + gorm.io/gorm v1.25.5 ) require ( diff --git a/go.sum b/go.sum index d66d511..09f2242 100644 --- a/go.sum +++ b/go.sum @@ -294,8 +294,8 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/temoto/robotstxt v1.1.1/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo= github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg= github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo= -github.com/timerzz/proxypool v0.0.0-20240407102509-f13ba2d1b0ca h1:EbyIUW/bB7vZtwgrno1V5nyx38mCE+4DrWurtVMs0fQ= -github.com/timerzz/proxypool v0.0.0-20240407102509-f13ba2d1b0ca/go.mod h1:KVeB0Qlvv/sdR7dbB7ys1EqK4qGKpSnSiIhPhkHukwQ= +github.com/timerzz/proxypool v0.0.0-20240512142241-f74bcb3534c5 h1:/UVxZzOD+N5HVX+A+kDUDVE1cJSHbh4PSfL8H+EW5nM= +github.com/timerzz/proxypool v0.0.0-20240512142241-f74bcb3534c5/go.mod h1:Ba8aQPgnCdkBJoKGs9Fb6bPR+RHcmXhsSYVAQzREC8k= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= @@ -485,8 +485,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/postgres v1.5.2 h1:ytTDxxEv+MplXOfFe3Lzm7SjG09fcdb3Z/c056DTBx0= gorm.io/driver/postgres v1.5.2/go.mod h1:fmpX0m2I1PKuR7mKZiEluwrP3hbs+ps7JIGMUBpCgl8= -gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8= -gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls= +gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= diff --git a/pkg/model/pusher.go b/pkg/model/pusher.go index 439ffbf..f772a17 100644 --- a/pkg/model/pusher.go +++ b/pkg/model/pusher.go @@ -20,7 +20,7 @@ type Pusher[T any] struct { Type PusherType `json:"type"` Name string `json:"name"` Remark string `json:"remark"` - Option T `json:"option" gorm:"serializer:json"` + Option T `json:"option" gorm:"type:json;serializer:json"` } func (p *Pusher[T]) TableName() string { diff --git a/pkg/pusher/anPush_test.go b/pkg/pusher/anPush_test.go index 82779dc..6ca583c 100644 --- a/pkg/pusher/anPush_test.go +++ b/pkg/pusher/anPush_test.go @@ -1,6 +1,10 @@ package pusher import ( + "fmt" + "gorm.io/driver/postgres" + "gorm.io/gorm" + "haitao_watcher/pkg/model" "haitao_watcher/pkg/options" "testing" ) @@ -16,3 +20,17 @@ func TestAnPush_Push(t *testing.T) { t.Fatal(err) } } + +func TestMri(t *testing.T) { + dsn := fmt.Sprintf("host=192.168.31.55 user=timerzz password=zhhg1997 dbname=kedaya port=5432 sslmode=disable TimeZone=Asia/Shanghai") + db, _ := gorm.Open(postgres.Open(dsn), &gorm.Config{}) + err := db.AutoMigrate(&model.Pusher[options.AnPushOption]{}) + if err != nil { + t.Fatal(err) + } + var opt = model.Pusher[options.AnPushOption]{} + if err := db.Raw("select * from pusher").Scan(&opt).Error; err != nil { + t.Fatal(err) + } + t.Log(opt) +}