Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add feature gate to store module to better track ongoing features (#3575)
Tianzhou (天舟)06ae64b99c89
diff --git a/store/feature_flag.go b/store/feature_flag.gonew file mode 100644index 0000000000..c6f4d797f9--- /dev/null+++ b/store/feature_flag.go@@ -0,0 +1,25 @@+package store++// Have a single place to track all ongoing feature development that requires code to work with both+// old and new schecma. We need to gate the feature to make the code be compatible with both dev+// schema (having the schema change) and prod schema (not having the schema change yet).+//+// Step 1: Declare a feature+//+// Step 2: Gate the feature when the relevant schema hasn't been applied to prod yet+//+// if common.FeatureFlag(common.FeatureFlagNoop) {+// <<New feature code work with the new schema>>+// } else {+// <<Old code work with the old schema>>+// }+//+// Step 3: Remove the feature and gate++// FeatureFlagType is the feature flag type.+type FeatureFlagType string++const (+ // FeatureFlagNoop is a noop feature flag for demonstration purpose.+ FeatureFlagNoop FeatureFlagType = "bb.feature-flag.noop"+)diff --git a/store/feature_flag_dev.go b/store/feature_flag_dev.gonew file mode 100644index 0000000000..09039aad86--- /dev/null+++ b/store/feature_flag_dev.go@@ -0,0 +1,10 @@+//go:build !release+// +build !release++package store++// FeatureFlag in dev build always returns true.+// Because dev schema always has the latest change and is compatible with the new feature code.+func FeatureFlag(_ FeatureFlagType) bool {+ return true+}diff --git a/store/feature_flag_prod.go b/store/feature_flag_prod.gonew file mode 100644index 0000000000..cd1036885c--- /dev/null+++ b/store/feature_flag_prod.go@@ -0,0 +1,11 @@+//go:build release+// +build release++package store++// FeatureFlag in release build always returns false.+// Because we would remove the FeatureFlag check entirely after the schema change for the feature+// is rolled out to prod.+func FeatureFlag(_ FeatureFlagType) bool {+ return false+}