Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: remove has_issue Plan filter (#20805)
p0ny6d4cb2b927dc
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yamlindex a5c806018d..fff6a2260a 100644--- a/backend/api/mcp/gen/openapi.yaml+++ b/backend/api/mcp/gen/openapi.yaml@@ -13726,14 +13726,12 @@ components:- creator: the plan creator full name in "users/{email or id}" format, support "==" operator.- create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.- has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".- - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".- title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.- spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".- state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".For example:creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"- has_rollout == false && has_issue == truetitle == "My Plan"title.contains("database migration")spec_type == "change_database_config"diff --git a/backend/api/v1/plan_service_test.go b/backend/api/v1/plan_service_test.goindex ca8f7b99da..151e4bee4c 100644--- a/backend/api/v1/plan_service_test.go+++ b/backend/api/v1/plan_service_test.go@@ -5,15 +5,16 @@ import ("fmt""testing"+ "connectrpc.com/connect""github.com/stretchr/testify/assert""github.com/stretchr/testify/require"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/testcontainer"storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ v1pb "github.com/bytebase/bytebase/backend/generated-go/v1""github.com/bytebase/bytebase/backend/migrator""github.com/bytebase/bytebase/backend/store"-- _ "github.com/bytebase/bytebase/backend/plugin/db/pg")func cdcSpec(id, sheet string, targets []string, priorBackup bool) *storepb.PlanConfig_Spec {@@ -149,6 +150,78 @@ func TestUpdateIssueApprovalResetSkipsStalePlanApprovalInputVersion(t *testing.Trequire.EqualValues(t, 2, updatedIssue.Payload.GetApproval().GetApprovalInputVersion())}+func TestPlanServiceListPlansKeepsIssueLessDraftsVisible(t *testing.T) {+ ctx := context.Background()+ stores := setupPlanServiceTestStore(ctx, t)+ service := NewPlanService(stores, nil, nil, nil, nil)++ changeDraft, err := stores.CreatePlan(ctx, &store.PlanMessage{+ ProjectID: "project-a",+ Name: "change draft",+ Config: &storepb.PlanConfig{Specs: []*storepb.PlanConfig_Spec{{+ Id: "change",+ Config: &storepb.PlanConfig_Spec_ChangeDatabaseConfig{+ ChangeDatabaseConfig: &storepb.PlanConfig_ChangeDatabaseConfig{},+ },+ }}},+ }, "[email protected]")+ require.NoError(t, err)+ createDraft, err := stores.CreatePlan(ctx, &store.PlanMessage{+ ProjectID: "project-a",+ Name: "create draft",+ Config: &storepb.PlanConfig{Specs: []*storepb.PlanConfig_Spec{{+ Id: "create",+ Config: &storepb.PlanConfig_Spec_CreateDatabaseConfig{+ CreateDatabaseConfig: &storepb.PlanConfig_CreateDatabaseConfig{},+ },+ }}},+ }, "[email protected]")+ require.NoError(t, err)++ response, err := service.ListPlans(ctx, connect.NewRequest(&v1pb.ListPlansRequest{+ Parent: "projects/project-a",+ PageSize: 100,+ }))+ require.NoError(t, err)+ var got []string+ for _, plan := range response.Msg.Plans {+ got = append(got, plan.Title)+ }+ require.ElementsMatch(t, []string{changeDraft.Name, createDraft.Name}, got)+}++func TestPlanServiceCreatePlanRejectsMixedDatabaseSpecs(t *testing.T) {+ ctx := context.WithValue(context.Background(), common.WorkspaceIDContextKey, "default")+ ctx = context.WithValue(ctx, common.UserContextKey, &store.UserMessage{+ Email: "[email protected]",+ Name: "creator",+ })+ stores := setupPlanServiceTestStore(ctx, t)+ service := NewPlanService(stores, nil, nil, nil, nil)++ _, err := service.CreatePlan(ctx, connect.NewRequest(&v1pb.CreatePlanRequest{+ Parent: "projects/project-a",+ Plan: &v1pb.Plan{+ Specs: []*v1pb.Plan_Spec{+ {+ Id: "create",+ Config: &v1pb.Plan_Spec_CreateDatabaseConfig{+ CreateDatabaseConfig: &v1pb.Plan_CreateDatabaseConfig{},+ },+ },+ {+ Id: "change",+ Config: &v1pb.Plan_Spec_ChangeDatabaseConfig{+ ChangeDatabaseConfig: &v1pb.Plan_ChangeDatabaseConfig{},+ },+ },+ },+ },+ }))+ require.Equal(t, connect.CodeInvalidArgument, connect.CodeOf(err))+ require.ErrorContains(t, err, "each plan must contain only one type")+}+func setupPlanServiceTestStore(ctx context.Context, t *testing.T) *store.Store {t.Helper()diff --git a/backend/generated-go/v1/plan_service.pb.go b/backend/generated-go/v1/plan_service.pb.goindex b42cc5651a..8078ae0f09 100644--- a/backend/generated-go/v1/plan_service.pb.go+++ b/backend/generated-go/v1/plan_service.pb.go@@ -202,14 +202,12 @@ type ListPlansRequest struct {// - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.// - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.// - has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".- // - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".// - title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.// - spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".// - state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".//// For example:// creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"- // has_rollout == false && has_issue == true// title == "My Plan"// title.contains("database migration")// spec_type == "change_database_config"diff --git a/backend/store/plan.go b/backend/store/plan.goindex b14e34dc55..c90e9f68cc 100644--- a/backend/store/plan.go+++ b/backend/store/plan.go@@ -153,7 +153,6 @@ func (s *Store) ListPlans(ctx context.Context, find *FindPlanMessage) ([]*PlanMeplan.config,plan.deletedFROM plan- LEFT JOIN issue on plan.project = issue.project AND plan.id = issue.plan_idWHERE plan.project = ?`, find.ProjectID)@@ -341,15 +340,6 @@ func GetListPlanFilter(filter string) (*qb.Query, error) {return qb.Q().Space("(plan.config->>'hasRollout' IS NULL OR plan.config->>'hasRollout' = ?)", "false"), nil}return qb.Q().Space("plan.config->>'hasRollout' = ?", "true"), nil- case "has_issue":- hasIssue, ok := value.(bool)- if !ok {- return nil, errors.Errorf(`"has_issue" should be bool`)- }- if !hasIssue {- return qb.Q().Space("issue.id IS NULL"), nil- }- return qb.Q().Space("issue.id IS NOT NULL"), nilcase "title":return qb.Q().Space("plan.name = ?", value), nilcase "spec_type":diff --git a/backend/store/plan_filter_test.go b/backend/store/plan_filter_test.goindex 088d093ad9..c5d376ec59 100644--- a/backend/store/plan_filter_test.go+++ b/backend/store/plan_filter_test.go@@ -39,18 +39,10 @@ func TestGetListPlanFilter(t *testing.T) {wantErr: false,},{- name: "has_issue filter - true",- filter: `has_issue == true`,- wantSQL: "(issue.id IS NOT NULL)",- wantArgs: []any{},- wantErr: false,- },- {- name: "has_issue filter - false",- filter: `has_issue == false`,- wantSQL: "(issue.id IS NULL)",- wantArgs: []any{},- wantErr: false,+ name: "has_issue filter is unsupported",+ filter: `has_issue == true`,+ wantErr: true,+ errContains: `unsupported variable "has_issue"`,},{name: "title filter",@@ -127,13 +119,6 @@ func TestGetListPlanFilter(t *testing.T) {}()},wantErr: false,},- {- name: "AND condition with has_rollout and has_issue",- filter: `has_rollout == true && has_issue == true`,- wantSQL: "((plan.config->>'hasRollout' = $1 AND issue.id IS NOT NULL))",- wantArgs: []any{"true"},- wantErr: false,- },{name: "complex AND condition",filter: `title == "Test Plan" && state == "STATE_ACTIVE" && has_rollout == true`,@@ -178,12 +163,6 @@ func TestGetListPlanFilter(t *testing.T) {wantErr: true,errContains: `"has_rollout" should be bool`,},- {- name: "has_issue with non-bool value",- filter: `has_issue == "true"`,- wantErr: true,- errContains: `"has_issue" should be bool`,- },{name: "invalid time format",filter: `create_time >= "invalid-time"`,diff --git a/frontend/src/plugins/agent/logic/tools/gen/openapi-index.ts b/frontend/src/plugins/agent/logic/tools/gen/openapi-index.tsindex 7fbd98d9bf..6ead00b6d3 100644--- a/frontend/src/plugins/agent/logic/tools/gen/openapi-index.ts+++ b/frontend/src/plugins/agent/logic/tools/gen/openapi-index.ts@@ -7744,7 +7744,7 @@ export const schemas: Record<string, SchemaInfo> = {name: "filter",type: "string",description:- 'Filter is used to filter plans returned in the list.\n The syntax and semantics of CEL are documented at https://github.com/google/cel-spec\n\n Supported filters:\n - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.\n - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.\n - has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".\n - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".\n - title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.\n - spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".\n - state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".\n\n For example:\n creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"\n has_rollout == false && has_issue == true\n title == "My Plan"\n title.contains("database migration")\n spec_type == "change_database_config"\n state == "ACTIVE"',+ 'Filter is used to filter plans returned in the list.\n The syntax and semantics of CEL are documented at https://github.com/google/cel-spec\n\n Supported filters:\n - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.\n - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.\n - has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".\n - title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.\n - spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".\n - state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".\n\n For example:\n creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"\n title == "My Plan"\n title.contains("database migration")\n spec_type == "change_database_config"\n state == "ACTIVE"',},{name: "pageSize",diff --git a/frontend/src/react/stores/app/plan.ts b/frontend/src/react/stores/app/plan.tsindex 882319ab0e..1a602f2122 100644--- a/frontend/src/react/stores/app/plan.ts+++ b/frontend/src/react/stores/app/plan.ts@@ -31,9 +31,6 @@ export const buildPlanFilter = (find: PlanFind): string => {`create_time <= "${dayjs(find.createdTsBefore).utc().format()}"`);}- if (find.hasIssue !== undefined) {- filter.push(`has_issue == ${find.hasIssue}`);- }if (find.hasRollout !== undefined) {filter.push(`has_rollout == ${find.hasRollout}`);}diff --git a/frontend/src/react/stores/app/types.ts b/frontend/src/react/stores/app/types.tsindex df1357cc2d..77645fc38e 100644--- a/frontend/src/react/stores/app/types.ts+++ b/frontend/src/react/stores/app/types.ts@@ -1040,7 +1040,6 @@ export interface PlanFind {creator?: string;createdTsAfter?: number;createdTsBefore?: number;- hasIssue?: boolean;hasRollout?: boolean;specType?: string;state?: "ACTIVE" | "DELETED";diff --git a/frontend/src/types/proto-es/v1/plan_service_pb.d.ts b/frontend/src/types/proto-es/v1/plan_service_pb.d.tsindex ceb78b0c2e..bc62678ee1 100644--- a/frontend/src/types/proto-es/v1/plan_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/plan_service_pb.d.ts@@ -75,14 +75,12 @@ export declare type ListPlansRequest = Message<"bytebase.v1.ListPlansRequest"> &* - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.* - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.* - has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".- * - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".* - title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.* - spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".* - state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".** For example:* creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"- * has_rollout == false && has_issue == true* title == "My Plan"* title.contains("database migration")* spec_type == "change_database_config"diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex c5953e8d5d..68d407c647 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -8407,14 +8407,12 @@ paths:- creator: the plan creator full name in "users/{email or id}" format, support "==" operator.- create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.- has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".- - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".- title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.- spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".- state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".For example:creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"- has_rollout == false && has_issue == truetitle == "My Plan"title.contains("database migration")spec_type == "change_database_config"@@ -21859,14 +21857,12 @@ components:- creator: the plan creator full name in "users/{email or id}" format, support "==" operator.- create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.- has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".- - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".- title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.- spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".- state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".For example:creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"- has_rollout == false && has_issue == truetitle == "My Plan"title.contains("database migration")spec_type == "change_database_config"diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex e0bcea2ad1..8dd4f45e38 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -5078,9 +5078,9 @@ SQLService executes SQL queries and manages query operations.When paginating, all other parameters provided to `ListPlans` must match the call that provided the page token. || filter | [string](#string) | | Filter is used to filter plans returned in the list. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec-Supported filters: - creator: the plan creator full name in "users/{email or id}" format, support "==" operator. - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator. - has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false". - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false". - title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match. - spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config". - state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".+Supported filters: - creator: the plan creator full name in "users/{email or id}" format, support "==" operator. - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator. - has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false". - title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match. - spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config". - state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".-For example: creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00" has_rollout == false && has_issue == true title == "My Plan" title.contains("database migration") spec_type == "change_database_config" state == "ACTIVE" |+For example: creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00" title == "My Plan" title.contains("database migration") spec_type == "change_database_config" state == "ACTIVE" |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex abb9bd71cd..56c996f1c4 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -15247,14 +15247,12 @@ Supported filters:- creator: the plan creator full name in "users/{email or id}" format, support "==" operator.- create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.- has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".-- has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".- title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.- spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".- state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".For example:creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"-has_rollout == false && has_issue == truetitle == "My Plan"title.contains("database migration")spec_type == "change_database_config"diff --git a/proto/v1/v1/plan_service.proto b/proto/v1/v1/plan_service.protoindex 5f45d451fe..c677adb5f7 100644--- a/proto/v1/v1/plan_service.proto+++ b/proto/v1/v1/plan_service.proto@@ -135,14 +135,12 @@ message ListPlansRequest {// - creator: the plan creator full name in "users/{email or id}" format, support "==" operator.// - create_time: the plan create time in "2006-01-02T15:04:05Z07:00" format, support ">=" or "<=" operator.// - has_rollout: whether the plan has rollout, support "==" operator, the value should be "true" or "false".- // - has_issue: the plan has issue or not, support "==" operator, the value should be "true" or "false".// - title: the plan title, support "==" operator for exact match and ".contains()" operator for case-insensitive substring match.// - spec_type: the plan spec config type, support "==" operator, the value should be "create_database_config", "change_database_config", or "export_data_config".// - state: the plan state, support "==" operator, the value should be "ACTIVE" or "DELETED".//// For example:// creator == "users/[email protected]" && create_time >= "2025-01-02T15:04:05Z07:00"- // has_rollout == false && has_issue == true// title == "My Plan"// title.contains("database migration")// spec_type == "change_database_config"