Skip to content

Commit

Permalink
[ENH] Add LogPosition and CollectionVersion to Segment database model
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishiihara committed Apr 26, 2024
1 parent 46b770f commit 2ff4cc4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w=
github.com/alecthomas/kong v0.7.1 h1:azoTh0IOfwlAX3qN9sHWTxACE2oV8Bg2gAwBsMwDQY4=
github.com/alecthomas/kong v0.7.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down
2 changes: 2 additions & 0 deletions go/migrations/20240426222943.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "segments" table
ALTER TABLE "public"."segments" ADD COLUMN "log_position" bigint NULL DEFAULT 0, ADD COLUMN "collection_version" integer NULL DEFAULT 0;
3 changes: 2 additions & 1 deletion go/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
h1:0fWoYRU+wWRTteHvXVV8mOc+AJYEJzDFuH4c5hLWKR0=
h1:Fq5rdlL+h4BCs0kve7IgO5G+iO4gV/WFAvyTc7cnF64=
20240313233558.sql h1:Gv0TiSYsqGoOZ2T2IWvX4BOasauxool8PrBOIjmmIdg=
20240321194713.sql h1:kVkNpqSFhrXGVGFFvL7JdK3Bw31twFcEhI6A0oCFCkg=
20240327075032.sql h1:nlr2J74XRU8erzHnKJgMr/tKqJxw9+R6RiiEBuvuzgo=
20240327172649.sql h1:UUGo6AzWXKLcpYVd5qH6Hv9jpHNV86z42o6ft5OR0zU=
20240411201006.sql h1:jjzYJPzDVTxQAvOI7gRtNTiZJHy1Hpw5urP8EzqxgUk=
20240426222943.sql h1:RF3cBbL9jNePJOMXjLUOgZsvVsNZMKFvi3lWQq2PcUI=
20 changes: 11 additions & 9 deletions go/pkg/metastore/db/dbmodel/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ type Segment struct {
This requires us to push down CollectionID from the caller. We don't think there is
need to modify CollectionID in the near future. Each Segment should always have a
collection as a parent and cannot be modified. */
CollectionID *string `gorm:"collection_id;primaryKey"`
ID string `gorm:"id;primaryKey"`
Type string `gorm:"type;type:string;not null"`
Scope string `gorm:"scope"`
Ts types.Timestamp `gorm:"ts;type:bigint;default:0"`
IsDeleted bool `gorm:"is_deleted;type:bool;default:false"`
CreatedAt time.Time `gorm:"created_at;type:timestamp;not null;default:current_timestamp"`
UpdatedAt time.Time `gorm:"updated_at;type:timestamp;not null;default:current_timestamp"`
FilePaths map[string][]string `gorm:"file_paths;serializer:json;default:'{}'"`
CollectionID *string `gorm:"collection_id;primaryKey"`
ID string `gorm:"id;primaryKey"`
Type string `gorm:"type;type:string;not null"`
Scope string `gorm:"scope"`
Ts types.Timestamp `gorm:"ts;type:bigint;default:0"`
IsDeleted bool `gorm:"is_deleted;type:bool;default:false"`
CreatedAt time.Time `gorm:"created_at;type:timestamp;not null;default:current_timestamp"`
UpdatedAt time.Time `gorm:"updated_at;type:timestamp;not null;default:current_timestamp"`
FilePaths map[string][]string `gorm:"file_paths;serializer:json;default:'{}'"`
LogPosition int64 `gorm:"log_position;default:0"`
CollectionVersion int32 `gorm:"collection_version;default:0"`
}

func (s Segment) TableName() string {
Expand Down

0 comments on commit 2ff4cc4

Please sign in to comment.