Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Remove uuid from vcs table

天舟ef795920e4c2
diff --git a/backend/api/vcs.go b/backend/api/vcs.go
index 0883b72404..f22cf559ea 100644
--- a/backend/api/vcs.go
+++ b/backend/api/vcs.go
@@ -31,9 +31,7 @@ type VCS struct {
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
// Domain specific fields
- Name string `jsonapi:"attr,name"`
- // Identify oauth callback endpoint
- Uuid string `jsonapi:"attr,uuid"`
+ Name string `jsonapi:"attr,name"`
Type VCSType `jsonapi:"attr,type"`
InstanceURL string `jsonapi:"attr,instanceURL"`
ApiURL string `jsonapi:"attr,apiURL"`
@@ -59,9 +57,6 @@ type VCSCreate struct {
type VCSFind struct {
ID *int
-
- // Domain specific fields
- Uuid *string
}
func (find *VCSFind) String() string {
diff --git a/backend/go.mod b/backend/go.mod
index 8a73e5e7d3..09acdcc579 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -11,7 +11,6 @@ require (
github.com/labstack/echo/v4 v4.2.2
github.com/mattn/go-sqlite3 v1.14.7
github.com/qiangmzsx/string-adapter/v2 v2.1.0
- github.com/satori/go.uuid v1.2.0
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.17.0
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf
diff --git a/backend/go.sum b/backend/go.sum
index f310fcd794..48d9206f1f 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -203,11 +203,9 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
-github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
-github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
github.com/labstack/echo/v4 v4.2.2 h1:bq2fdZCionY1jck8rzUpQEu2YSmI8QbX6LHrCa60IVs=
@@ -261,7 +259,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
-github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
@@ -593,7 +590,6 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
diff --git a/backend/server/vcs.go b/backend/server/vcs.go
index babbbce653..16c8781fed 100644
--- a/backend/server/vcs.go
+++ b/backend/server/vcs.go
@@ -13,7 +13,6 @@ import (
"github.com/bytebase/bytebase/api"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
- uuid "github.com/satori/go.uuid"
)
const (
@@ -48,14 +47,6 @@ func (s *Server) registerVCSRoutes(g *echo.Group) {
g.GET("/vcs", func(c echo.Context) error {
vcsFind := &api.VCSFind{}
- uuidStr := c.QueryParams().Get("uuid")
- if uuidStr != "" {
- _, err := uuid.FromString(uuidStr)
- if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid uuid string: %s", uuidStr)).SetInternal(err)
- }
- vcsFind.Uuid = &uuidStr
- }
list, err := s.VCSService.FindVCSList(context.Background(), vcsFind)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch vcs list").SetInternal(err)
diff --git a/backend/store/migration/0001_init_schema.up.sql b/backend/store/migration/0001_init_schema.up.sql
index 6f4669619d..b854f82d28 100644
--- a/backend/store/migration/0001_init_schema.up.sql
+++ b/backend/store/migration/0001_init_schema.up.sql
@@ -643,8 +643,6 @@ CREATE TABLE vcs (
updater_id INTEGER NOT NULL REFERENCES principal (id),
updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
name TEXT NOT NULL,
- -- Identify the oauth callback endpoint
- uuid TEXT NOT NULL UNIQUE,
`type` TEXT NOT NULL CHECK (`type` IN ('GITLAB_SELF_HOST')),
instance_url TEXT NOT NULL CHECK (
instance_url LIKE 'http:/%'
diff --git a/backend/store/vcs.go b/backend/store/vcs.go
index 5fca39acb2..deee40bdbc 100644
--- a/backend/store/vcs.go
+++ b/backend/store/vcs.go
@@ -7,7 +7,6 @@ import (
"github.com/bytebase/bytebase"
"github.com/bytebase/bytebase/api"
- uuid "github.com/satori/go.uuid"
"go.uber.org/zap"
)
@@ -133,20 +132,18 @@ func createVCS(ctx context.Context, tx *Tx, create *api.VCSCreate) (*api.VCS, er
creator_id,
updater_id,
name,
- uuid,
`+"`type`,"+`
instance_url,
api_url,
application_id,
secret
)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, uuid, `+"`type`, instance_url, api_url, application_id, secret, access_token"+`
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, `+"`type`, instance_url, api_url, application_id, secret, access_token"+`
`,
create.CreatorId,
create.CreatorId,
create.Name,
- uuid.NewV4(),
create.Type,
create.InstanceURL,
create.ApiURL,
@@ -168,7 +165,6 @@ func createVCS(ctx context.Context, tx *Tx, create *api.VCSCreate) (*api.VCS, er
&vcs.UpdaterId,
&vcs.UpdatedTs,
&vcs.Name,
- &vcs.Uuid,
&vcs.Type,
&vcs.InstanceURL,
&vcs.ApiURL,
@@ -188,9 +184,6 @@ func findVCSList(ctx context.Context, tx *Tx, find *api.VCSFind) (_ []*api.VCS,
if v := find.ID; v != nil {
where, args = append(where, "id = ?"), append(args, *v)
}
- if v := find.Uuid; v != nil {
- where, args = append(where, "uuid = ?"), append(args, *v)
- }
rows, err := tx.QueryContext(ctx, `
SELECT
@@ -200,7 +193,6 @@ func findVCSList(ctx context.Context, tx *Tx, find *api.VCSFind) (_ []*api.VCS,
updater_id,
updated_ts,
name,
- uuid,
`+"`type`,"+`
instance_url,
api_url,
@@ -227,7 +219,6 @@ func findVCSList(ctx context.Context, tx *Tx, find *api.VCSFind) (_ []*api.VCS,
&vcs.UpdaterId,
&vcs.UpdatedTs,
&vcs.Name,
- &vcs.Uuid,
&vcs.Type,
&vcs.InstanceURL,
&vcs.ApiURL,
@@ -268,7 +259,7 @@ func patchVCS(ctx context.Context, tx *Tx, patch *api.VCSPatch) (*api.VCS, error
UPDATE vcs
SET `+strings.Join(set, ", ")+`
WHERE id = ?
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, uuid, `+"`type`, instance_url, api_url, application_id, secret, access_token"+`
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, `+"`type`, instance_url, api_url, application_id, secret, access_token"+`
`,
args...,
)
@@ -286,7 +277,6 @@ func patchVCS(ctx context.Context, tx *Tx, patch *api.VCSPatch) (*api.VCS, error
&vcs.UpdaterId,
&vcs.UpdatedTs,
&vcs.Name,
- &vcs.Uuid,
&vcs.Type,
&vcs.InstanceURL,
&vcs.ApiURL,
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index 8c88428085..8d77003ecc 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -307,7 +307,6 @@ export const unknown = (
createdTs: 0,
updatedTs: 0,
name: "",
- uuid: "",
type: "GITLAB_SELF_HOST",
instanceURL: "",
apiURL: "",
@@ -566,7 +565,6 @@ export const empty = (
createdTs: 0,
updatedTs: 0,
name: "",
- uuid: "",
type: "GITLAB_SELF_HOST",
instanceURL: "",
apiURL: "",
diff --git a/frontend/src/types/vcs.ts b/frontend/src/types/vcs.ts
index a1e463300a..9eb818fd3d 100644
--- a/frontend/src/types/vcs.ts
+++ b/frontend/src/types/vcs.ts
@@ -22,7 +22,6 @@ export type VCS = {
// Domain specific fields
name: string;
- uuid: string;
type: VCSType;
instanceURL: string;
apiURL: string;