Skip to content

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

chore: clean up rollback SQL related code (#771)

Danny Xu5e9f31244332
diff --git a/api/activity.go b/api/activity.go
index 55b4012f94..3d03385cae 100644
--- a/api/activity.go
+++ b/api/activity.go
@@ -132,8 +132,6 @@ func (e ActivityLevel) String() string {
type ActivityIssueCreatePayload struct {
// Used by inbox to display info without paying the join cost
IssueName string `json:"issueName"`
- // If we create a rollback issue, this field records the issue id to be rolled back.
- RollbackIssueID int `json:"rollbackIssueId,omitempty"`
}
// ActivityIssueCommentCreatePayload is the API message payloads for creating issue comments.
diff --git a/api/issue.go b/api/issue.go
index ceb23df03d..a766f16f7a 100644
--- a/api/issue.go
+++ b/api/issue.go
@@ -56,8 +56,6 @@ const (
IssueFieldSubscriberList IssueFieldID = "6"
// IssueFieldSQL is the field ID for SQL.
IssueFieldSQL IssueFieldID = "7"
- // IssueFieldRollbackSQL is the field ID for rollback SQL.
- IssueFieldRollbackSQL IssueFieldID = "8"
)
// Issue is the API message for an issue.
@@ -106,7 +104,6 @@ type IssueCreate struct {
Description string `jsonapi:"attr,description"`
AssigneeID int `jsonapi:"attr,assigneeId"`
SubscriberIDList []int `jsonapi:"attr,subscriberIdList"`
- RollbackIssueID *int `jsonapi:"attr,rollbackIssueId"`
Payload string `jsonapi:"attr,payload"`
// CreateContext is used to create the issue pipeline and not persisted.
// The context format depends on the issue type. For example, create database issue corresponds to CreateDatabaseContext.
@@ -144,8 +141,6 @@ type UpdateSchemaDetail struct {
DatabaseName string `json:"databaseName"`
// Statement is the statement to update database schema.
Statement string `json:"statement"`
- // RollbackStatement is the rollback statement of the statement.
- RollbackStatement string `json:"rollbackStatement"`
// EarliestAllowedTs the earliest execution time of the change at system local Unix timestamp in seconds.
EarliestAllowedTs int64 `jsonapi:"attr,earliestAllowedTs"`
}
diff --git a/api/task.go b/api/task.go
index f36c4be25d..231e7fe6fa 100644
--- a/api/task.go
+++ b/api/task.go
@@ -89,19 +89,17 @@ type TaskDatabaseCreatePayload struct {
// TaskDatabaseSchemaUpdatePayload is the task payload for database schema update (DDL).
type TaskDatabaseSchemaUpdatePayload struct {
- MigrationType db.MigrationType `json:"migrationType,omitempty"`
- Statement string `json:"statement,omitempty"`
- RollbackStatement string `json:"rollbackStatement,omitempty"`
- SchemaVersion string `json:"schemaVersion,omitempty"`
- VCSPushEvent *vcs.PushEvent `json:"pushEvent,omitempty"`
+ MigrationType db.MigrationType `json:"migrationType,omitempty"`
+ Statement string `json:"statement,omitempty"`
+ SchemaVersion string `json:"schemaVersion,omitempty"`
+ VCSPushEvent *vcs.PushEvent `json:"pushEvent,omitempty"`
}
// TaskDatabaseDataUpdatePayload is the task payload for database data update (DML).
type TaskDatabaseDataUpdatePayload struct {
- Statement string `json:"statement,omitempty"`
- RollbackStatement string `json:"rollbackStatement,omitempty"`
- SchemaVersion string `json:"schemaVersion,omitempty"`
- VCSPushEvent *vcs.PushEvent `json:"pushEvent,omitempty"`
+ Statement string `json:"statement,omitempty"`
+ SchemaVersion string `json:"schemaVersion,omitempty"`
+ VCSPushEvent *vcs.PushEvent `json:"pushEvent,omitempty"`
}
// TaskDatabaseBackupPayload is the task payload for database backup.
@@ -170,7 +168,6 @@ type TaskCreate struct {
Payload string
EarliestAllowedTs int64 `jsonapi:"attr,earliestAllowedTs"`
Statement string `jsonapi:"attr,statement"`
- RollbackStatement string `jsonapi:"attr,rollbackStatement"`
DatabaseName string `jsonapi:"attr,databaseName"`
CharacterSet string `jsonapi:"attr,characterSet"`
Collation string `jsonapi:"attr,collation"`
diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vue
index cb3f530afc..e30938b891 100644
--- a/frontend/src/components/Issue/IssueActivityPanel.vue
+++ b/frontend/src/components/Issue/IssueActivityPanel.vue
@@ -148,20 +148,6 @@
{{ humanizeTs(activity.createdTs) }})
</template>
</a>
- <span
- v-if="
- activity.type == 'bb.issue.create' &&
- activity.payload.rollbackIssueId
- "
- >
- (rollback
- <router-link
- :to="`/issue/${activity.payload.rollbackIssueId}`"
- class="normal-link"
- >{{ `issue/${activity.payload.rollbackIssueId}` }}
- </router-link>
- )
- </span>
</div>
<div
v-if="currentUser.id == activity.creator.id"
diff --git a/frontend/src/components/Issue/IssueDetailLayout.vue b/frontend/src/components/Issue/IssueDetailLayout.vue
index 8a97f84b52..f53f76a429 100644
--- a/frontend/src/components/Issue/IssueDetailLayout.vue
+++ b/frontend/src/components/Issue/IssueDetailLayout.vue
@@ -484,7 +484,6 @@ export default defineComponent({
databaseId: task.databaseId!,
databaseName: task.databaseName!,
statement: task.statement,
- rollbackStatement: "",
earliestAllowedTs: task.earliestAllowedTs,
};
});
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index e87610c898..16b80b7b8b 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -56,7 +56,6 @@ common:
approve: Approve
done: Done
create: Create
- rollback: Rollback
run: Run
retry: Retry
skip: Skip
@@ -381,8 +380,6 @@ issue:
apply-to-other-stages: Apply to other stages
add-sql-statement: Add SQL statement...
optional-add-sql-statement: (Optional) Add SQL statement...
- rollback-sql: Rollback SQL
- add-rollback-sql-statement: Add rollback SQL statement...
edit-description: Edit description
add-some-description: Add some description...
add-a-comment: Add a comment
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index 704bbbc37b..eaaf033a08 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -56,7 +56,6 @@ common:
approve: 批准
done: 完成
create: 创建
- rollback: 回滚
run: 运行
retry: 重试
skip: 跳过
@@ -369,8 +368,6 @@ issue:
apply-to-other-stages: "@:{'common.apply'}到其他@:{'common.stage'}"
add-sql-statement: 添加 SQL @:{'common.statement'}…
optional-add-sql-statement: (可选)添加 SQL @:{'common.statement'}…
- rollback-sql: "@:{'common.rollback'} SQL"
- add-rollback-sql-statement: 添加 @:{'common.rollback'} SQL @:{'common.statement'}…
edit-description: 编辑描述
add-some-description: 添加一些描述…
add-a-comment: 添加评论
diff --git a/frontend/src/plugins/issue/DatabaseDataUpdateTemplate.ts b/frontend/src/plugins/issue/DatabaseDataUpdateTemplate.ts
index 4665494c63..1cf4d13df3 100644
--- a/frontend/src/plugins/issue/DatabaseDataUpdateTemplate.ts
+++ b/frontend/src/plugins/issue/DatabaseDataUpdateTemplate.ts
@@ -31,7 +31,6 @@ const template: IssueTemplate = {
instanceId: ctx.databaseList[i].instance.id,
databaseId: ctx.databaseList[i].id,
statement: ctx.statementList ? ctx.statementList[i] : "",
- rollbackStatement: "",
migrationType: "MIGRATE",
earliestAllowedTs: 0,
},
diff --git a/frontend/src/plugins/issue/DatabaseGrantTemplate.ts b/frontend/src/plugins/issue/DatabaseGrantTemplate.ts
index 6f241ebc8f..095b16c0aa 100644
--- a/frontend/src/plugins/issue/DatabaseGrantTemplate.ts
+++ b/frontend/src/plugins/issue/DatabaseGrantTemplate.ts
@@ -36,7 +36,7 @@ const template: IssueTemplate = {
instanceId: ctx.databaseList[0].instance.id,
databaseId: ctx.databaseList[0].id,
statement: "",
- rollbackStatement: "",
+ earliestAllowedTs: 0,
},
],
},
diff --git a/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.ts b/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.ts
index dc129d8dae..40e42eb82b 100644
--- a/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.ts
+++ b/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.ts
@@ -31,7 +31,6 @@ const template: IssueTemplate = {
instanceId: ctx.databaseList[i].instance.id,
databaseId: ctx.databaseList[i].id,
statement: "/* Establish baseline using current schema */",
- rollbackStatement: "",
migrationType: "BASELINE",
earliestAllowedTs: 0,
},
diff --git a/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts b/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts
index a944a1218b..8f2bd90236 100644
--- a/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts
+++ b/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts
@@ -31,7 +31,6 @@ const template: IssueTemplate = {
instanceId: ctx.databaseList[i].instance.id,
databaseId: ctx.databaseList[i].id,
statement: ctx.statementList ? ctx.statementList[i] : "",
- rollbackStatement: "",
migrationType: "MIGRATE",
earliestAllowedTs: 0,
},
diff --git a/frontend/src/plugins/issue/DefaultTemplate.ts b/frontend/src/plugins/issue/DefaultTemplate.ts
index d9c5b47506..1ee718f56b 100644
--- a/frontend/src/plugins/issue/DefaultTemplate.ts
+++ b/frontend/src/plugins/issue/DefaultTemplate.ts
@@ -25,7 +25,7 @@ const template: IssueTemplate = {
instanceId: UNKNOWN_ID,
databaseId: UNKNOWN_ID,
statement: "",
- rollbackStatement: "",
+ earliestAllowedTs: 0,
},
],
},
diff --git a/frontend/src/plugins/types.ts b/frontend/src/plugins/types.ts
index 64e15d29a7..2836fed9ed 100644
--- a/frontend/src/plugins/types.ts
+++ b/frontend/src/plugins/types.ts
@@ -20,7 +20,6 @@ export enum IssueBuiltinFieldId {
PROJECT = "5",
SUBSCRIBER_LIST = "6",
SQL = "7",
- ROLLBACK_SQL = "8",
}
export const INPUT_CUSTOM_FIELD_ID_BEGIN = "100";
@@ -95,7 +94,6 @@ export type TemplateContext = {
approvalPolicyList: Policy[];
currentUser: Principal;
statementList?: string[];
- rollbackStatementList?: string[];
};
export type IssueTemplate = {
diff --git a/frontend/src/store/modules/issue.ts b/frontend/src/store/modules/issue.ts
index 477fd2d007..e008e2deb9 100644
--- a/frontend/src/store/modules/issue.ts
+++ b/frontend/src/store/modules/issue.ts
@@ -155,8 +155,6 @@ const actions = {
// so that we should also update instance/database store, otherwise, we may get
// unknown instance/database when navigating to other UI from the issue detail page
// since other UIs are getting instance/database by id from the store.
- // An example is if user navigates to an issue and do a rollback, the constructed rollback
- // issue requires the instance/database exist in the store.
for (const stage of issue.pipeline.stageList) {
for (const task of stage.taskList) {
commit(
diff --git a/frontend/src/types/activity.ts b/frontend/src/types/activity.ts
index c56c4008e8..0067e4cf23 100644
--- a/frontend/src/types/activity.ts
+++ b/frontend/src/types/activity.ts
@@ -78,7 +78,6 @@ export type ActivityLevel = "INFO" | "WARN" | "ERROR";
export type ActivityIssueCreatePayload = {
issueName: string;
- rollbackIssueId?: IssueId;
};
export type ActivityIssueCommentCreatePayload = {
diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts
index 26ceae694a..23acd53993 100644
--- a/frontend/src/types/issue.ts
+++ b/frontend/src/types/issue.ts
@@ -42,7 +42,6 @@ export type UpdateSchemaDetail = {
databaseId: DatabaseId;
databaseName: string;
statement: string;
- rollbackStatement: string;
earliestAllowedTs: number;
};
@@ -94,7 +93,6 @@ export type IssueCreate = {
type: IssueType;
description: string;
assigneeId: PrincipalId;
- rollbackIssueId?: IssueId;
createContext: IssueCreateContext;
payload: IssuePayload;
};
diff --git a/frontend/src/types/pipeline/task.ts b/frontend/src/types/pipeline/task.ts
index f0a9101d0e..a28364f30c 100644
--- a/frontend/src/types/pipeline/task.ts
+++ b/frontend/src/types/pipeline/task.ts
@@ -48,13 +48,11 @@ export type TaskDatabaseCreatePayload = {
export type TaskDatabaseSchemaUpdatePayload = {
migrationType: MigrationType;
statement: string;
- rollbackStatement: string;
pushEvent?: VCSPushEvent;
};
export type TaskDatabaseDataUpdatePayload = {
statement: string;
- rollbackStatement: string;
pushEvent?: VCSPushEvent;
};
@@ -105,7 +103,6 @@ export type TaskCreate = {
instanceId: InstanceId;
databaseId?: DatabaseId;
statement: string;
- rollbackStatement?: string;
databaseName?: string;
characterSet?: string;
collation?: string;
diff --git a/frontend/src/utils/activity.ts b/frontend/src/utils/activity.ts
index 2d9388a72f..aabd5f70ef 100644
--- a/frontend/src/utils/activity.ts
+++ b/frontend/src/utils/activity.ts
@@ -23,9 +23,9 @@ export function issueActivityActionSentence(
case "bb.issue.field.update": {
const update = activity.payload as ActivityIssueFieldUpdatePayload;
- let name = "Unknown Field";
- let oldValue = undefined;
- let newValue = undefined;
+ const name = "Unknown Field";
+ const oldValue = undefined;
+ const newValue = undefined;
switch (update.fieldId) {
case IssueBuiltinFieldId.ASSIGNEE: {
@@ -77,51 +77,6 @@ export function issueActivityActionSentence(
case IssueBuiltinFieldId.NAME:
case IssueBuiltinFieldId.PROJECT:
case IssueBuiltinFieldId.SQL:
- case IssueBuiltinFieldId.ROLLBACK_SQL: {
- if (update.fieldId == IssueBuiltinFieldId.NAME) {
- name = "name";
- } else if (update.fieldId == IssueBuiltinFieldId.SQL) {
- name = "SQL";
- } else if (update.fieldId == IssueBuiltinFieldId.ROLLBACK_SQL) {
- name = "Rollback SQL";
- }
-
- oldValue = update.oldValue;
- newValue = update.newValue;
- if (oldValue && newValue) {
- return [
- "activity.sentence.changed-from-to",
- {
- name,
- oldValue,
- newValue,
- },
- ];
- } else if (oldValue) {
- return [
- "activity.sentence.unset-from",
- {
- name,
- oldValue,
- },
- ];
- } else if (newValue) {
- return [
- "activity.sentence.set-to",
- {
- name,
- newValue,
- },
- ];
- } else {
- return [
- "activity.sentence.changed-update",
- {
- name,
- },
- ];
- }
- }
}
return ["activity.sentence.updated", {}];
diff --git a/server/issue.go b/server/issue.go
index 2a93a9ea05..107044422c 100644
--- a/server/issue.go
+++ b/server/issue.go
@@ -396,9 +396,6 @@ func (s *Server) createIssue(ctx context.Context, issueCreate *api.IssueCreate,
createActivityPayload := api.ActivityIssueCreatePayload{
IssueName: issue.Name,
}
- if issueCreate.RollbackIssueID != nil {
- createActivityPayload.RollbackIssueID = *issueCreate.RollbackIssueID
- }
bytes, err := json.Marshal(createActivityPayload)
if err != nil {
@@ -417,40 +414,6 @@ func (s *Server) createIssue(ctx context.Context, issueCreate *api.IssueCreate,
if err != nil {
return nil, fmt.Errorf("failed to create activity after creating the issue: %v. Error %w", issue.Name, err)
}
-
- // If we are creating a rollback issue, then we will also post a comment on the original issue
- if issueCreate.RollbackIssueID != nil {
- issueFind := &api.IssueFind{
- ID: issueCreate.RollbackIssueID,
- }
- rollbackIssue, err := s.IssueService.FindIssue(ctx, issueFind)
- if err != nil {
- return nil, fmt.Errorf("failed to create activity after creating the rollback issue: %v. Error %w", issue.Name, err)
- }
- if rollbackIssue == nil {
- return nil, fmt.Errorf("Rollback issue not found for ID %v", issueCreate.RollbackIssueID)
- }
- bytes, err := json.Marshal(api.ActivityIssueCommentCreatePayload{
- IssueName: rollbackIssue.Name,
- })
- if err != nil {
- return nil, fmt.Errorf("failed to create activity after creating the rollback issue: %v. Error %w", issue.Name, err)
- }
- activityCreate := &api.ActivityCreate{
- CreatorID: creatorID,
- ContainerID: *issueCreate.RollbackIssueID,
- Type: api.ActivityIssueCommentCreate,
- Level: api.ActivityInfo,
- Comment: fmt.Sprintf("Created rollback issue %q", issue.Name),
- Payload: string(bytes),
- }
- _, err = s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{
- issue: rollbackIssue,
- })
- if err != nil {
- return nil, fmt.Errorf("failed to create activity after creating the rollback issue: %v. Error %w", issue.Name, err)
- }
- }
return issue, nil
}
@@ -878,9 +841,6 @@ func getUpdateTask(database *api.Database, migrationType db.MigrationType, vcsPu
payload.MigrationType = migrationType
payload.Statement = d.Statement
payload.SchemaVersion = schemaVersion
- if d.RollbackStatement != "" {
- payload.RollbackStatement = d.RollbackStatement
- }
if vcsPushEvent != nil {
payload.VCSPushEvent = vcsPushEvent
}
@@ -904,7 +864,6 @@ func getUpdateTask(database *api.Database, migrationType db.MigrationType, vcsPu
Status: taskStatus,
Type: taskType,
Statement: d.Statement,
- RollbackStatement: d.RollbackStatement,
EarliestAllowedTs: d.EarliestAllowedTs,
MigrationType: migrationType,
Payload: string(bytes),
diff --git a/store/seed/test/10110__task.sql b/store/seed/test/10110__task.sql
index 5e4cb0ecf7..c0dde9ca79 100644
--- a/store/seed/test/10110__task.sql
+++ b/store/seed/test/10110__task.sql
@@ -193,7 +193,7 @@ VALUES
'Update testdb_dev',
'bb.task.database.schema.update',
'FAILED',
- '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_dev.tbl1 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_dev.tbl1;"}'
+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_dev.tbl1 (name TEXT);"}'
);
-- Task for stage 10003 "Integration" to update database 7006 'testdb_integration'
@@ -223,7 +223,7 @@ VALUES
'Update testdb_integration',
'bb.task.database.schema.update',
'PENDING',
- '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_integration.tbl1 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_integration.tbl1;"}'
+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_integration.tbl1 (name TEXT);"}'
);
-- Task for stage 10008 simulating webhook push event
@@ -424,7 +424,7 @@ VALUES
'Update testdb_dev',
'bb.task.database.schema.update',
'DONE',
- '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_dev.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_dev.tbl2;"}'
+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_dev.tbl2 (name TEXT);"}'
);
-- Task for stage 10014 "Integration" to create table in database 7006 'testdb_integration'
@@ -454,7 +454,7 @@ VALUES
'Update testdb_integration',
'bb.task.database.schema.update',
'DONE',
- '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_integration.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_integration.tbl2;"}'
+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_integration.tbl2 (name TEXT);"}'
);
@@ -485,7 +485,7 @@ VALUES
'Update testdb_staging',
'bb.task.database.schema.update',
'FAILED',
- '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_staging.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_staging.tbl2;"}'
+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_staging.tbl2 (name TEXT);"}'
);
-- Task for stage 10016 "prod" to create table in database 7014 'testdb_prod'
@@ -515,7 +515,7 @@ VALUES
'Update testdb_prod',
'bb.task.database.schema.update',
'PENDING_APPROVAL',
- '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_prod.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_prod.tbl2;"}'
+ '{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_prod.tbl2 (name TEXT);"}'
);
ALTER SEQUENCE task_id_seq RESTART WITH 11017;