write feature version on TableEditSession.flush()

This commit is contained in:
Andy Arthur
2021-02-06 17:04:40 -08:00
parent efd7d2f8ca
commit bf081d6f55
3 changed files with 19 additions and 4 deletions
-4
View File
@@ -44,13 +44,9 @@ const (
MasterBranch = "master"
CommitStructName = "Commit"
FeatureVersion featureVersion = 0
defaultChunksPerTF = 256 * 1024
)
type featureVersion int64
// LocalDirDoltDB stores the db in the current directory
var LocalDirDoltDB = "file://./" + dbfactory.DoltDataDir
+14
View File
@@ -34,8 +34,12 @@ const (
superSchemasKey = "super_schemas"
foreignKeyKey = "foreign_key"
featureVersKey = "feature_ver"
FeatureVersion featureVersion = 0
)
type featureVersion int64
// RootValue defines the structure used inside all Dolthub noms dbs
type RootValue struct {
vrw types.ValueReadWriter
@@ -133,6 +137,16 @@ func (root *RootValue) GetFeatureVersion(ctx context.Context) (ver int64, ok boo
return ver, ok, err
}
func (root *RootValue) SetFeatureVersion(ctx context.Context) (*RootValue, error) {
st, err := root.valueSt.Set(featureVersKey, types.Int(FeatureVersion))
if err != nil {
return nil, err
}
return newRootValue(root.vrw, st), nil
}
func (root *RootValue) HasTable(ctx context.Context, tName string) (bool, error) {
val, found, err := root.valueSt.MaybeGet(tablesKey)
@@ -192,6 +192,11 @@ func (tes *TableEditSession) flush(ctx context.Context) (*doltdb.RootValue, erro
return nil, rootErr
}
newRoot, rootErr = newRoot.SetFeatureVersion(ctx)
if rootErr != nil {
return nil, rootErr
}
tes.root = newRoot
return newRoot, nil
}