Skip to content

Commit

Permalink
Merge pull request #47 from NpoolPlatform/feat/auto-increment-id
Browse files Browse the repository at this point in the history
Feat/auto increment
  • Loading branch information
kikakkz authored Nov 30, 2023
2 parents bd66d3d + 765dc17 commit fe7e3a5
Show file tree
Hide file tree
Showing 26 changed files with 1,453 additions and 117 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ verify-spelling: ## Verifies spelling.

gen-ent:
go get -d entgo.io/ent/cmd/[email protected]
go run entgo.io/ent/cmd/ent generate --feature sql/upsert ./pkg/db/ent/schema
go run -mod=mod entgo.io/ent/cmd/ent generate --feature entql,sql/lock,sql/execquery,sql/upsert,privacy,schema/snapshot,sql/modifier ./pkg/db/ent/schema


all: verify-build

Expand Down
5 changes: 3 additions & 2 deletions cmd/sphinx-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"os"

"github.com/NpoolPlatform/go-service-framework/pkg/app"
"github.com/NpoolPlatform/go-service-framework/pkg/config"
"github.com/NpoolPlatform/go-service-framework/pkg/logger"
mysqlconst "github.com/NpoolPlatform/go-service-framework/pkg/mysql/const"
redisconst "github.com/NpoolPlatform/go-service-framework/pkg/redis/const"
"github.com/NpoolPlatform/sphinx-proxy/pkg/servicename"
cli "github.com/urfave/cli/v2"
)
Expand All @@ -29,7 +29,8 @@ func main() {
"./",
nil,
commands,
config.ServiceNameToNamespace(mysqlconst.MysqlServiceName),
mysqlconst.MysqlServiceName,
redisconst.RedisServiceName,
)
if err != nil {
logger.Sugar().Errorf("fail to create %v: %v", serviceName, err)
Expand Down
5 changes: 5 additions & 0 deletions cmd/sphinx-proxy/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/NpoolPlatform/go-service-framework/pkg/logger"
"github.com/NpoolPlatform/sphinx-proxy/api"
"github.com/NpoolPlatform/sphinx-proxy/pkg/db"
"github.com/NpoolPlatform/sphinx-proxy/pkg/migrator"

"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
cli "github.com/urfave/cli/v2"
"google.golang.org/grpc"
Expand All @@ -29,6 +31,9 @@ var runCmd = &cli.Command{
}

func run(ctx context.Context) error {
if err := migrator.Migrate(ctx); err != nil {
return err
}
if err := db.Init(); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/NpoolPlatform/sphinx-proxy
go 1.17

require (
entgo.io/ent v0.12.0
entgo.io/ent v0.11.2
github.com/NpoolPlatform/basal-middleware v0.0.0-20231015112137-254853c60eec
github.com/NpoolPlatform/chain-middleware v0.0.0-20231020114413-49166aeb1ec8
github.com/NpoolPlatform/go-service-framework v0.0.0-20230930023319-e48074d9472e
Expand Down Expand Up @@ -78,6 +78,7 @@ require (
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dfuse-io/logging v0.0.0-20210109005628-b97a57253f70 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/ethereum/go-ethereum v1.10.26 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/filecoin-project/go-address v0.0.6 // indirect
Expand Down Expand Up @@ -115,6 +116,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-redis/redis/v8 v8.11.4 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
Expand Down Expand Up @@ -217,7 +219,6 @@ require (
github.com/myxtype/filecoin-client v0.3.2 // indirect
github.com/nkovacs/streamquote v1.0.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/onsi/gomega v1.16.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
Expand Down Expand Up @@ -541,6 +542,7 @@ github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
github.com/go-redis/redis/v8 v8.11.4 h1:kHoYkfZP6+pe04aFTnhDH6GDROa5yJdHJVNxV3F46Tg=
github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
Expand Down
9 changes: 4 additions & 5 deletions pkg/db/ent/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions pkg/db/ent/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

203 changes: 203 additions & 0 deletions pkg/db/ent/entql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fe7e3a5

Please sign in to comment.