Skip to content

Commit

Permalink
feat(internal/database): modify db method CreateRevision
Browse files Browse the repository at this point in the history
  • Loading branch information
jinghancc committed Nov 8, 2021
1 parent cbaf4a1 commit 833dff3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/database/metadata/postgres/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func (db *DB) ListRevision(ctx context.Context, opt metadata.ListRevisionOpt) ([]*types.Revision, error) {
revisions := []*types.Revision{}
var revisions []*types.Revision
query := "SELECT * FROM feature_group_revision"
cond, args, err := buildListRevisionCond(opt)
if err != nil {
Expand Down Expand Up @@ -73,8 +73,8 @@ func (db *DB) GetRevision(ctx context.Context, opt metadata.GetRevisionOpt) (*ty
}

func (db *DB) CreateRevision(ctx context.Context, opt metadata.CreateRevisionOpt) error {
query := "INSERT INTO feature_group_revision(group_name, revision, data_table, description) VALUES ($1, $2, $3, $4)"
_, err := db.ExecContext(ctx, query, opt.GroupName, opt.Revision, opt.DataTable, opt.Description)
query := "INSERT INTO feature_group_revision(group_name, revision, data_table, anchored, description) VALUES ($1, $2, $3, $4, $5)"
_, err := db.ExecContext(ctx, query, opt.GroupName, opt.Revision, opt.DataTable, opt.Anchored, opt.Description)
if err != nil {
if e2, ok := err.(*pq.Error); ok {
if e2.Code == pgerrcode.UniqueViolation {
Expand Down
1 change: 1 addition & 0 deletions internal/database/metadata/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type CreateRevisionOpt struct {
GroupName string
DataTable string
Description string
Anchored bool
}

type GetRevisionOpt struct {
Expand Down

0 comments on commit 833dff3

Please sign in to comment.