Skip to content

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

feat: remove has_issue Plan filter (#20805)

p0ny6d4cb2b927dc
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index 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 == true
title == "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.go
index 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.T
require.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{},
+ },
+ }}},
+ 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{},
+ },
+ }}},
+ 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.go
index 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.go
index 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) ([]*PlanMe
plan.config,
plan.deleted
FROM plan
- LEFT JOIN issue on plan.project = issue.project AND plan.id = issue.plan_id
WHERE 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"), nil
case "title":
return qb.Q().Space("plan.name = ?", value), nil
case "spec_type":
diff --git a/backend/store/plan_filter_test.go b/backend/store/plan_filter_test.go
index 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.ts
index 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.ts
index 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.ts
index 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.ts
index 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.yaml
index 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 == true
title == "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 == true
title == "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.md
index 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 &#34;users/{email or id}&#34; format, support &#34;==&#34; operator. - create_time: the plan create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator. - has_rollout: whether the plan has rollout, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;. - has_issue: the plan has issue or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;. - title: the plan title, support &#34;==&#34; operator for exact match and &#34;.contains()&#34; operator for case-insensitive substring match. - spec_type: the plan spec config type, support &#34;==&#34; operator, the value should be &#34;create_database_config&#34;, &#34;change_database_config&#34;, or &#34;export_data_config&#34;. - state: the plan state, support &#34;==&#34; operator, the value should be &#34;ACTIVE&#34; or &#34;DELETED&#34;.
+Supported filters: - creator: the plan creator full name in &#34;users/{email or id}&#34; format, support &#34;==&#34; operator. - create_time: the plan create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator. - has_rollout: whether the plan has rollout, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;. - title: the plan title, support &#34;==&#34; operator for exact match and &#34;.contains()&#34; operator for case-insensitive substring match. - spec_type: the plan spec config type, support &#34;==&#34; operator, the value should be &#34;create_database_config&#34;, &#34;change_database_config&#34;, or &#34;export_data_config&#34;. - state: the plan state, support &#34;==&#34; operator, the value should be &#34;ACTIVE&#34; or &#34;DELETED&#34;.
-For example: creator == &#34;users/[email protected]&#34; &amp;&amp; create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34; has_rollout == false &amp;&amp; has_issue == true title == &#34;My Plan&#34; title.contains(&#34;database migration&#34;) spec_type == &#34;change_database_config&#34; state == &#34;ACTIVE&#34; |
+For example: creator == &#34;users/[email protected]&#34; &amp;&amp; create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34; title == &#34;My Plan&#34; title.contains(&#34;database migration&#34;) spec_type == &#34;change_database_config&#34; state == &#34;ACTIVE&#34; |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 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 &#34;users/{email or id}&#34; format, support &#34;==&#34; operator.
- create_time: the plan create time in &#34;2006-01-02T15:04:05Z07:00&#34; format, support &#34;&gt;=&#34; or &#34;&lt;=&#34; operator.
- has_rollout: whether the plan has rollout, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;.
-- has_issue: the plan has issue or not, support &#34;==&#34; operator, the value should be &#34;true&#34; or &#34;false&#34;.
- title: the plan title, support &#34;==&#34; operator for exact match and &#34;.contains()&#34; operator for case-insensitive substring match.
- spec_type: the plan spec config type, support &#34;==&#34; operator, the value should be &#34;create_database_config&#34;, &#34;change_database_config&#34;, or &#34;export_data_config&#34;.
- state: the plan state, support &#34;==&#34; operator, the value should be &#34;ACTIVE&#34; or &#34;DELETED&#34;.
For example:
creator == &#34;users/[email protected]&#34; &amp;&amp; create_time &gt;= &#34;2025-01-02T15:04:05Z07:00&#34;
-has_rollout == false &amp;&amp; has_issue == true
title == &#34;My Plan&#34;
title.contains(&#34;database migration&#34;)
spec_type == &#34;change_database_config&#34;
diff --git a/proto/v1/v1/plan_service.proto b/proto/v1/v1/plan_service.proto
index 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"