Skip to content

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

chore: enable cd setting with default true (#9791)

Danny Xu5411a62adbd0
diff --git a/backend/api/v1/sheet_service.go b/backend/api/v1/sheet_service.go
index 84db4f4604..c02fc830e0 100644
--- a/backend/api/v1/sheet_service.go
+++ b/backend/api/v1/sheet_service.go
@@ -645,7 +645,6 @@ func (s *SheetService) convertToAPISheetMessage(ctx context.Context, sheet *stor
}
if payload.DatabaseConfig != nil && payload.BaselineDatabaseConfig != nil {
v1SheetPayload = &v1pb.SheetPayload{
- Type: v1pb.SheetPayload_Type(payload.Type),
DatabaseConfig: convertStoreDatabaseConfig(payload.DatabaseConfig, nil /* filter */),
BaselineDatabaseConfig: convertStoreDatabaseConfig(payload.BaselineDatabaseConfig, nil /* filter */),
}
diff --git a/backend/migrator/migration/dev/LATEST.sql b/backend/migrator/migration/dev/LATEST.sql
index 28ccd52955..2e97756b21 100644
--- a/backend/migrator/migration/dev/LATEST.sql
+++ b/backend/migrator/migration/dev/LATEST.sql
@@ -963,6 +963,8 @@ CREATE TABLE repository (
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,
+ -- If enabled, create an issue on commits.
+ enable_cd 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/backend/migrator/migration/prod/2.12/0003##repo_enable_cd.sql b/backend/migrator/migration/prod/2.12/0003##repo_enable_cd.sql
new file mode 100644
index 0000000000..3f790ae5ad
--- /dev/null
+++ b/backend/migrator/migration/prod/2.12/0003##repo_enable_cd.sql
@@ -0,0 +1,2 @@
+ALTER TABLE repository ADD COLUMN enable_cd BOOLEAN NOT NULL DEFAULT false;
+UPDATE repository SET enable_cd = true;
\ No newline at end of file
diff --git a/backend/migrator/migration/prod/LATEST.sql b/backend/migrator/migration/prod/LATEST.sql
index 2e56e01b57..2a05ba0c6d 100644
--- a/backend/migrator/migration/prod/LATEST.sql
+++ b/backend/migrator/migration/prod/LATEST.sql
@@ -962,6 +962,8 @@ CREATE TABLE repository (
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,
+ -- If enabled, create an issue on commits.
+ enable_cd 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/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index d7215d048d..3e2411aa36 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -231,5 +231,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("2.12.2"), releaseVersion)
+ require.Equal(t, semver.MustParse("2.12.3"), releaseVersion)
}
diff --git a/backend/store/repository.go b/backend/store/repository.go
index 3049c78f5b..9e70a481cc 100644
--- a/backend/store/repository.go
+++ b/backend/store/repository.go
@@ -31,6 +31,7 @@ type RepositoryMessage struct {
SchemaPathTemplate string
SheetPathTemplate string
EnableSQLReviewCI bool
+ EnableCD bool
ExternalID string
ExternalWebhookID string
WebhookURLHost string
@@ -62,6 +63,7 @@ type PatchRepositoryMessage struct {
SchemaPathTemplate *string
SheetPathTemplate *string
EnableSQLReviewCI *bool
+ EnableCD *bool
AccessToken *string
ExpiresTs *int64
RefreshToken *string
@@ -213,6 +215,7 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repo
schema_path_template,
sheet_path_template,
enable_sql_review_ci,
+ enable_cd,
external_id,
external_webhook_id,
webhook_url_host,
@@ -222,8 +225,8 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repo
expires_ts,
refresh_token
)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)
- RETURNING id, vcs_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
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22)
+ RETURNING id, vcs_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, enable_cd, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token
`
if err := tx.QueryRowContext(ctx, query,
creatorID,
@@ -239,6 +242,7 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repo
create.SchemaPathTemplate,
create.SheetPathTemplate,
false, /* EnableSQLReviewCI */
+ true, /* EnableCD */
create.ExternalID,
create.ExternalWebhookID,
create.WebhookURLHost,
@@ -259,6 +263,7 @@ func (s *Store) createRepositoryImplV2(ctx context.Context, tx *Tx, create *Repo
&repository.SchemaPathTemplate,
&repository.SheetPathTemplate,
&repository.EnableSQLReviewCI,
+ &repository.EnableCD,
&repository.ExternalID,
&repository.ExternalWebhookID,
&repository.WebhookURLHost,
@@ -309,6 +314,7 @@ func (*Store) listRepositoryImplV2(ctx context.Context, tx *Tx, find *FindReposi
schema_path_template,
sheet_path_template,
enable_sql_review_ci,
+ enable_cd,
external_id,
external_webhook_id,
webhook_url_host,
@@ -344,6 +350,7 @@ func (*Store) listRepositoryImplV2(ctx context.Context, tx *Tx, find *FindReposi
&repository.SchemaPathTemplate,
&repository.SheetPathTemplate,
&repository.EnableSQLReviewCI,
+ &repository.EnableCD,
&repository.ExternalID,
&repository.ExternalWebhookID,
&repository.WebhookURLHost,
@@ -397,6 +404,9 @@ func (*Store) patchRepositoryImplV2(ctx context.Context, tx *Tx, patch *PatchRep
if v := patch.EnableSQLReviewCI; v != nil {
set, args = append(set, fmt.Sprintf("enable_sql_review_ci = $%d", len(args)+1)), append(args, *v)
}
+ if v := patch.EnableCD; v != nil {
+ set, args = append(set, fmt.Sprintf("enable_cd = $%d", len(args)+1)), append(args, *v)
+ }
where := []string{}
if v := patch.UID; v != nil {