Skip to content

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

chore: release enable_sql_review_ci feature (#3094)

ecmadao43d60a177f0d
diff --git a/api/plan.go b/api/plan.go
index a25a60975b..2b11be0b0c 100644
--- a/api/plan.go
+++ b/api/plan.go
@@ -210,9 +210,7 @@ var FeatureMatrix = map[FeatureType][3]bool{
// FeatureFlight is the flight map for features.
// We can disable the hidden feature here. After the feature is released, we can set the bool to true to enable the feature.
-var FeatureFlight = map[FeatureType]bool{
- FeatureVCSSQLReviewWorkflow: false,
-}
+var FeatureFlight = map[FeatureType]bool{}
// Plan is the API message for a plan.
type Plan struct {
diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vue
index fbd1f22c02..86c6da3bd3 100644
--- a/frontend/src/components/RepositoryForm.vue
+++ b/frontend/src/components/RepositoryForm.vue
@@ -228,7 +228,7 @@
</template>
</div>
</div>
- <div v-if="isDev">
+ <div>
<div class="textlabel flex gap-x-1">
{{ $t("repository.sql-review-ci") }}
<FeatureBadge feature="bb.feature.vcs-sql-review" class="text-accent" />
diff --git a/server/flight.go b/server/flight.go
index c7603fb6a0..1663e4a1de 100644
--- a/server/flight.go
+++ b/server/flight.go
@@ -8,5 +8,9 @@ import (
// flight returns if the feature is enabled.
// By default, the feature is always enabled in dev mode, and you can decide if is available in the release mode.
func (s *Server) flight(feature api.FeatureType) bool {
- return api.FeatureFlight[feature] || s.profile.Mode == common.ReleaseModeDev
+ isEnabled, ok := api.FeatureFlight[feature]
+ if !ok {
+ return true
+ }
+ return isEnabled || s.profile.Mode == common.ReleaseModeDev
}
diff --git a/store/migration/dev/20221012000000##add_repository_enable_sql_review_ci.sql b/store/migration/prod/1.7/0000##add_repository_enable_sql_review_ci.sql
similarity index 100%
rename from store/migration/dev/20221012000000##add_repository_enable_sql_review_ci.sql
rename to store/migration/prod/1.7/0000##add_repository_enable_sql_review_ci.sql
diff --git a/store/migration/prod/LATEST.sql b/store/migration/prod/LATEST.sql
index 5e66efdb14..e01744c95e 100644
--- a/store/migration/prod/LATEST.sql
+++ b/store/migration/prod/LATEST.sql
@@ -923,6 +923,8 @@ CREATE TABLE repository (
base_directory TEXT NOT NULL DEFAULT '',
-- The file path template for matching the committed migration script.
file_path_template TEXT NOT NULL DEFAULT '',
+ -- If enable the SQL review CI in VCS repository.
+ enable_sql_review_ci BOOLEAN NOT NULL DEFAULT false,
-- The file path template for storing the latest schema auto-generated by Bytebase after migration.
-- If empty, then Bytebase won't auto generate it.
schema_path_template TEXT NOT NULL DEFAULT '',
diff --git a/store/pg_engine_test.go b/store/pg_engine_test.go
index 08c6a52f56..a5a064d308 100644
--- a/store/pg_engine_test.go
+++ b/store/pg_engine_test.go
@@ -219,5 +219,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("1.6.1"), releaseVersion)
+ require.Equal(t, semver.MustParse("1.7.0"), releaseVersion)
}
diff --git a/store/repository.go b/store/repository.go
index 363522cd7f..ebc4650e0b 100644
--- a/store/repository.go
+++ b/store/repository.go
@@ -449,7 +449,7 @@ func (s *Store) createRepositoryImpl(ctx context.Context, tx *Tx, create *api.Re
return &repository, nil
}
-func (s *Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.RepositoryFind) ([]*repositoryRaw, error) {
+func (*Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.RepositoryFind) ([]*repositoryRaw, error) {
// Build WHERE clause.
where, args := []string{"1 = 1"}, []interface{}{}
if v := find.ID; v != nil {
@@ -468,84 +468,6 @@ func (s *Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.Reposi
where, args = append(where, fmt.Sprintf("web_url = $%d", len(args)+1)), append(args, *v)
}
- if s.db.mode == common.ReleaseModeDev {
- rows, err := tx.QueryContext(ctx, `
- SELECT
- id,
- creator_id,
- created_ts,
- updater_id,
- updated_ts,
- vcs_id,
- project_id,
- name,
- full_path,
- web_url,
- branch_filter,
- base_directory,
- file_path_template,
- schema_path_template,
- sheet_path_template,
- enable_sql_review_ci,
- external_id,
- external_webhook_id,
- webhook_url_host,
- webhook_endpoint_id,
- webhook_secret_token,
- access_token,
- expires_ts,
- refresh_token
- FROM repository
- WHERE `+strings.Join(where, " AND "),
- args...,
- )
- if err != nil {
- return nil, FormatError(err)
- }
- defer rows.Close()
-
- // Iterate over result set and deserialize rows into repoRawList.
- var repoRawList []*repositoryRaw
- for rows.Next() {
- var repository repositoryRaw
- if err := rows.Scan(
- &repository.ID,
- &repository.CreatorID,
- &repository.CreatedTs,
- &repository.UpdaterID,
- &repository.UpdatedTs,
- &repository.VCSID,
- &repository.ProjectID,
- &repository.Name,
- &repository.FullPath,
- &repository.WebURL,
- &repository.BranchFilter,
- &repository.BaseDirectory,
- &repository.FilePathTemplate,
- &repository.SchemaPathTemplate,
- &repository.SheetPathTemplate,
- &repository.EnableSQLReviewCI,
- &repository.ExternalID,
- &repository.ExternalWebhookID,
- &repository.WebhookURLHost,
- &repository.WebhookEndpointID,
- &repository.WebhookSecretToken,
- &repository.AccessToken,
- &repository.ExpiresTs,
- &repository.RefreshToken,
- ); err != nil {
- return nil, FormatError(err)
- }
-
- repoRawList = append(repoRawList, &repository)
- }
- if err := rows.Err(); err != nil {
- return nil, FormatError(err)
- }
-
- return repoRawList, nil
- }
-
rows, err := tx.QueryContext(ctx, `
SELECT
id,
@@ -563,6 +485,7 @@ func (s *Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.Reposi
file_path_template,
schema_path_template,
sheet_path_template,
+ enable_sql_review_ci,
external_id,
external_webhook_id,
webhook_url_host,
@@ -600,6 +523,7 @@ func (s *Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.Reposi
&repository.FilePathTemplate,
&repository.SchemaPathTemplate,
&repository.SheetPathTemplate,
+ &repository.EnableSQLReviewCI,
&repository.ExternalID,
&repository.ExternalWebhookID,
&repository.WebhookURLHost,
@@ -622,7 +546,7 @@ func (s *Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.Reposi
}
// patchRepositoryImpl updates a repository by ID. Returns the new state of the repository after update.
-func (s *Store) patchRepositoryImpl(ctx context.Context, tx *Tx, patch *api.RepositoryPatch) (*repositoryRaw, error) {
+func (*Store) patchRepositoryImpl(ctx context.Context, tx *Tx, patch *api.RepositoryPatch) (*repositoryRaw, error) {
// Build UPDATE clause.
set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
if v := patch.BranchFilter; v != nil {
@@ -659,53 +583,8 @@ func (s *Store) patchRepositoryImpl(ctx context.Context, tx *Tx, patch *api.Repo
if len(where) == 0 {
return nil, common.Errorf(common.Invalid, "missing predicate in where clause for patching repository")
}
-
- if s.db.mode == common.ReleaseModeDev {
- if v := patch.EnableSQLReviewCI; v != nil {
- set, args = append(set, fmt.Sprintf("enable_sql_review_ci = $%d", len(args)+1)), append(args, *v)
- }
-
- var repository repositoryRaw
- // Execute update query with RETURNING.
- if err := tx.QueryRowContext(ctx, `
- UPDATE repository
- SET `+strings.Join(set, ", ")+`
- WHERE `+strings.Join(where, " AND ")+`
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, vcs_id, project_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token
- `,
- args...,
- ).Scan(
- &repository.ID,
- &repository.CreatorID,
- &repository.CreatedTs,
- &repository.UpdaterID,
- &repository.UpdatedTs,
- &repository.VCSID,
- &repository.ProjectID,
- &repository.Name,
- &repository.FullPath,
- &repository.WebURL,
- &repository.BranchFilter,
- &repository.BaseDirectory,
- &repository.FilePathTemplate,
- &repository.SchemaPathTemplate,
- &repository.SheetPathTemplate,
- &repository.EnableSQLReviewCI,
- &repository.ExternalID,
- &repository.ExternalWebhookID,
- &repository.WebhookURLHost,
- &repository.WebhookEndpointID,
- &repository.WebhookSecretToken,
- &repository.AccessToken,
- &repository.ExpiresTs,
- &repository.RefreshToken,
- ); err != nil {
- if err == sql.ErrNoRows {
- return nil, &common.Error{Code: common.NotFound, Err: errors.Errorf("repository ID not found: %d", patch.ID)}
- }
- return nil, FormatError(err)
- }
- return &repository, nil
+ if v := patch.EnableSQLReviewCI; v != nil {
+ set, args = append(set, fmt.Sprintf("enable_sql_review_ci = $%d", len(args)+1)), append(args, *v)
}
var repository repositoryRaw
@@ -714,7 +593,7 @@ func (s *Store) patchRepositoryImpl(ctx context.Context, tx *Tx, patch *api.Repo
UPDATE repository
SET `+strings.Join(set, ", ")+`
WHERE `+strings.Join(where, " AND ")+`
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, vcs_id, project_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, vcs_id, project_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token
`,
args...,
).Scan(
@@ -733,6 +612,7 @@ func (s *Store) patchRepositoryImpl(ctx context.Context, tx *Tx, patch *api.Repo
&repository.FilePathTemplate,
&repository.SchemaPathTemplate,
&repository.SheetPathTemplate,
+ &repository.EnableSQLReviewCI,
&repository.ExternalID,
&repository.ExternalWebhookID,
&repository.WebhookURLHost,