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: UI support for change data issue (DML) (#424)
tianzhoub4435414b7df
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex 18793a7532..802c63f3d3 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -27,26 +27,37 @@</template></template><template v-else>- <NTabs v-model:value="state.tab" type="line">- <NTabPane :tab="$t('project.mode.standard')" name="standard">- <!-- a simple table -->- <DatabaseTable- mode="ALL_SHORT"- :bordered="true"- :custom-click="true"- :database-list="standardProjectDatabaseList"- @select-database="selectDatabase"- />- </NTabPane>- <NTabPane :tab="$t('project.mode.tenant')" name="tenant">- <CommonTenantView- :state="state"- :database-list="databaseList"- :environment-list="environmentList"- @dismiss="cancel"- />- </NTabPane>- </NTabs>+ <template v-if="isAlterSchema">+ <NTabs v-model:value="state.tab" type="line">+ <NTabPane :tab="$t('project.mode.standard')" name="standard">+ <!-- a simple table -->+ <DatabaseTable+ mode="ALL_SHORT"+ :bordered="true"+ :custom-click="true"+ :database-list="standardProjectDatabaseList"+ @select-database="selectDatabase"+ />+ </NTabPane>+ <NTabPane :tab="$t('project.mode.tenant')" name="tenant">+ <CommonTenantView+ :state="state"+ :database-list="databaseList"+ :environment-list="environmentList"+ @dismiss="cancel"+ />+ </NTabPane>+ </NTabs>+ </template>+ <template v-else>+ <DatabaseTable+ mode="ALL_SHORT"+ :bordered="true"+ :custom-click="true"+ :database-list="standardProjectDatabaseList"+ @select-database="selectDatabase"+ />+ </template></template></div></div>@@ -57,26 +68,20 @@type="button"class="btn-normal py-2 px-4"@click.prevent="cancel"- >- {{ $t("common.cancel") }}- </button>+ >{{ $t("common.cancel") }}</button><buttonv-if="state.alterType == 'MULTI_DB'"class="btn-primary ml-3 inline-flex justify-center py-2 px-4":disabled="!allowGenerateMultiDb"@click.prevent="generateMultDb"- >- {{ $t("common.next") }}- </button>+ >{{ $t("common.next") }}</button><buttonv-if="isTenantProject || (!projectId && state.tab === 'tenant')"class="btn-primary ml-3 inline-flex justify-center py-2 px-4":disabled="!allowGenerateTenant"@click.prevent="generateTenant"- >- {{ $t("common.next") }}- </button>+ >{{ $t("common.next") }}</button></div></div></template>@@ -134,6 +139,9 @@ export default defineComponent({type: Number as PropType<ProjectId>,default: undefined,},+ type: {+ type: String as PropType<"bb.issue.database.schema.update" | "bb.issue.database.data.update">,+ }},emits: ["dismiss"],setup(props, { emit }) {@@ -162,6 +170,11 @@ export default defineComponent({deployingTenantDatabaseList: [],});+ // Returns true if alter schema, false if change data.+ const isAlterSchema = computed((): boolean => {+ return props.type === "bb.issue.database.schema.update"+ })+const isTenantProject = computed((): boolean => {return state.project?.tenantMode === "TENANT";});@@ -222,8 +235,8 @@ export default defineComponent({issueSlug: "new",},query: {- template: "bb.issue.database.schema.update",- name: `Alter schema`,+ template: props.type,+ name: isAlterSchema.value ? `Alter schema` : `Change data`,project: props.projectId,databaseList: databaseIdList.join(","),},@@ -259,8 +272,8 @@ export default defineComponent({issueSlug: "new",},query: {- template: "bb.issue.database.schema.update",- name: `[${state.selectedDatabaseName}] Alter schema`,+ template: props.type,+ name: `[${state.selectedDatabaseName}] ${isAlterSchema.value ? `Alter schema` : `Change data`}`,project: project.id,databaseName: state.selectedDatabaseName,mode: "tenant",@@ -285,8 +298,8 @@ export default defineComponent({issueSlug: "new",},query: {- template: "bb.issue.database.schema.update",- name: `[${database.name}] Alter schema`,+ template: props.type,+ name: `[${database.name}] ${isAlterSchema.value ? `Alter schema` : `Change data`}`,project: database.project.id,databaseList: database.id,},@@ -321,6 +334,7 @@ export default defineComponent({return {wrapperClass,state,+ isAlterSchema,isTenantProject,environmentList,databaseList,diff --git a/frontend/src/components/Issue/IssueDetailLayout.vue b/frontend/src/components/Issue/IssueDetailLayout.vueindex 602415c690..9206fae2c1 100644--- a/frontend/src/components/Issue/IssueDetailLayout.vue+++ b/frontend/src/components/Issue/IssueDetailLayout.vue@@ -1,9 +1,5 @@<template>- <div- id="issue-detail-top"- class="flex-1 overflow-auto focus:outline-none"- tabindex="0"- >+ <div id="issue-detail-top" class="flex-1 overflow-auto focus:outline-none" tabindex="0"><IssueBanner v-if="!create" :issue="issue" /><!-- Highlight Panel -->@@ -86,9 +82,7 @@><div class="flex max-w-3xl mx-auto px-6 lg:max-w-full"><div class="flex flex-col flex-1 lg:flex-row-reverse lg:col-span-2">- <div- class="py-6 lg:pl-4 lg:w-96 xl:w-112 lg:border-l lg:border-block-border"- >+ <div class="py-6 lg:pl-4 lg:w-96 xl:w-112 lg:border-l lg:border-block-border"><IssueSidebar:issue="issue":database="database"@@ -111,10 +105,7 @@<div class="w-full py-4 pr-4"><section v-if="showIssueTaskStatementPanel" class="border-b mb-4"><div v-if="!create" class="mb-4">- <TaskCheckBar- :task="selectedTask"- @run-checks="runTaskChecks"- />+ <TaskCheckBar :task="selectedTask" @run-checks="runTaskChecks" /></div><template v-if="isTenantDeployMode"><!--@@ -138,7 +129,7 @@The statement panel is in non-edit mode when not creating the issue, and we use v-highlightto apply syntax highlighting when the panel is in non-edit mode. However, the v-highlightdoesn't seem to work well with the reactivity. So for non-edit mode when !props.create, we- list every IssueTaskStatementPanel for each stage and use v-if to show the active one. -->+ list every IssueTaskStatementPanel for each stage and use v-if to show the active one.--><template v-if="create"><IssueTaskStatementPanel:sql-hint="sqlHint(false)"@@ -153,11 +144,7 @@"/></template>- <template- v-for="(stage, index) in issue.pipeline.stageList"- v-else- :key="index"- >+ <template v-for="(stage, index) in issue.pipeline.stageList" v-else :key="index"><template v-if="selectedStage.id == stage.id"><IssueTaskStatementPanel:sql-hint="sqlHint(false)"@@ -172,10 +159,7 @@</template></template></section>- <section- v-if="showIssueTaskRollbackStatementPanel"- class="border-b mb-4"- >+ <section v-if="showIssueTaskRollbackStatementPanel" class="border-b mb-4"><template v-if="create"><IssueTaskStatementPanel:sql-hint="sqlHint(true)"@@ -190,11 +174,7 @@"/></template>- <template- v-for="(stage, index) in issue.pipeline.stageList"- v-else- :key="index"- >+ <template v-for="(stage, index) in issue.pipeline.stageList" v-else :key="index"><template v-if="selectedStage.id == stage.id"><IssueTaskStatementPanel:sql-hint="sqlHint(true)"@@ -214,11 +194,7 @@:allow-edit="allowEditNameAndDescription"@update-description="updateDescription"/>- <section- v-if="!create"- aria-labelledby="activity-title"- class="mt-4"- >+ <section v-if="!create" aria-labelledby="activity-title" class="mt-4"><IssueActivityPanel:issue="issue":issue-template="issueTemplate"@@ -285,6 +261,7 @@ import {IssueStatusPatch,Task,TaskDatabaseSchemaUpdatePayload,+ TaskDatabaseDataUpdatePayload,StageCreate,TaskCreate,TaskDatabaseCreatePayload,@@ -423,7 +400,8 @@ export default defineComponent({if (task.type == "bb.task.general" ||task.type == "bb.task.database.create" ||- task.type == "bb.task.database.schema.update"+ task.type == "bb.task.database.schema.update" ||+ task.type == "bb.task.database.data.update") {task.statement = newStatement;}@@ -439,7 +417,7 @@ export default defineComponent({const applyRollbackStatementToOtherStages = (newStatement: string) => {for (const stage of (props.issue as IssueCreate).pipeline!.stageList) {for (const task of stage.taskList) {- if (task.type == "bb.task.database.schema.update") {+ if (task.type == "bb.task.database.schema.update" || task.type == "bb.task.database.data.update") {task.rollbackStatement = newStatement;}}@@ -534,7 +512,7 @@ export default defineComponent({issueSlug: "new",},query: {- template: "bb.issue.database.schema.update",+ template: props.issue.type,rollbackIssue: (props.issue as Issue).id,},});@@ -748,6 +726,11 @@ export default defineComponent({((task as Task).payload as TaskDatabaseSchemaUpdatePayload).statement || "");+ case "bb.task.database.data.update":+ return (+ ((task as Task).payload as TaskDatabaseDataUpdatePayload)+ .statement || ""+ );case "bb.task.database.restore":return "";}@@ -755,10 +738,21 @@ export default defineComponent({const rollbackStatement = (stage: Stage): string => {const task = stage.taskList[0];- return (- (task.payload as TaskDatabaseSchemaUpdatePayload).rollbackStatement ||- ""- );+ switch (task.type) {+ case "bb.task.database.schema.update":+ return (+ (task.payload as TaskDatabaseSchemaUpdatePayload).rollbackStatement ||+ ""+ );+ case "bb.task.database.data.update":+ return (+ (task.payload as TaskDatabaseDataUpdatePayload).rollbackStatement ||+ ""+ );+ default:+ return ""+ }+};const isTenantDeployMode = computed((): boolean => {@@ -907,22 +901,30 @@ export default defineComponent({return false;}if (!props.create) {- if (props.issue.type == "bb.issue.database.schema.update") {+ if (props.issue.type == "bb.issue.database.schema.update" || props.issue.type == "bb.issue.database.data.update") {if ((props.issue as Issue).status == "DONE" ||(props.issue as Issue).status == "CANCELED") {for (const stage of (props.issue as Issue).pipeline.stageList) {for (const task of stage.taskList) {- if (- task.status == "DONE" &&- task.type == "bb.task.database.schema.update" &&- !isEmpty(- (task.payload as TaskDatabaseSchemaUpdatePayload)- .rollbackStatement- )- ) {- return true;+ if (task.status == "DONE") {+ if (task.type == "bb.task.database.schema.update" &&+ !isEmpty(+ (task.payload as TaskDatabaseSchemaUpdatePayload)+ .rollbackStatement+ )+ ) {+ return true+ }+ else if (task.type == "bb.task.database.data.update" &&+ !isEmpty(+ (task.payload as TaskDatabaseDataUpdatePayload)+ .rollbackStatement+ )+ ) {+ return true+ }}}}@@ -962,14 +964,15 @@ export default defineComponent({return (task.type == "bb.task.general" ||task.type == "bb.task.database.create" ||- task.type == "bb.task.database.schema.update"+ task.type == "bb.task.database.schema.update" ||+ task.type == "bb.task.database.data.update");});const showIssueTaskRollbackStatementPanel = computed(() => {if (isTenantDeployMode.value) return false;if (project.value.workflowType == "UI") {- if (props.issue.type == "bb.issue.database.schema.update") {+ if (props.issue.type == "bb.issue.database.schema.update" || props.issue.type == "bb.issue.database.data.update") {return true;}}@@ -989,7 +992,8 @@ export default defineComponent({if (task.type == "bb.task.general" ||task.type == "bb.task.database.create" ||- task.type == "bb.task.database.schema.update"+ task.type == "bb.task.database.schema.update" ||+ task.type == "bb.task.database.data.update") {count++;}diff --git a/frontend/src/components/Issue/IssueHighlightPanel.vue b/frontend/src/components/Issue/IssueHighlightPanel.vueindex b2a76161e0..110156e443 100644--- a/frontend/src/components/Issue/IssueHighlightPanel.vue+++ b/frontend/src/components/Issue/IssueHighlightPanel.vue@@ -74,6 +74,7 @@ import IssueStatusIcon from "./IssueStatusIcon.vue";import { activeTask } from "../../utils";import {TaskDatabaseSchemaUpdatePayload,+ TaskDatabaseDataUpdatePayload,Issue,VCSPushEvent,} from "../../types";@@ -119,6 +120,10 @@ export default defineComponent({const payload = activeTask(props.issue.pipeline).payload as TaskDatabaseSchemaUpdatePayload;return payload?.pushEvent;+ } else if (props.issue.type == "bb.issue.database.data.update") {+ const payload = activeTask(props.issue.pipeline)+ .payload as TaskDatabaseDataUpdatePayload;+ return payload?.pushEvent;}return undefined;});diff --git a/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vue b/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vueindex c331353427..ee0a6d4aae 100644--- a/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vue+++ b/frontend/src/components/Issue/IssueStatusTransitionButtonGroup.vue@@ -5,26 +5,16 @@class="btn-primary px-4 py-2":disabled="!allowCreate"@click.prevent="doCreate"- >- {{ $t("common.create") }}- </button>+ >{{ $t("common.create") }}</button></template><template v-else>- <div- v-if="applicableTaskStatusTransitionList.length > 0"- class="flex space-x-2"- >- <template- v-for="(transition, index) in applicableTaskStatusTransitionList"- :key="index"- >+ <div v-if="applicableTaskStatusTransitionList.length > 0" class="flex space-x-2">+ <template v-for="(transition, index) in applicableTaskStatusTransitionList" :key="index"><buttontype="button":class="transition.buttonClass"@click.prevent="tryStartTaskStatusTransition(transition)"- >- {{ $t(transition.buttonName) }}- </button>+ >{{ $t(transition.buttonName) }}</button></template><template v-if="applicableIssueStatusTransitionList.length > 0"><button@@ -39,43 +29,32 @@<heroicons-solid:dots-vertical class="w-6 h-6" /></button><BBContextMenu ref="menu" class="origin-top-right mt-10 w-42">- <template- v-for="(transition, index) in applicableIssueStatusTransitionList"- :key="index"- >+ <template v-for="(transition, index) in applicableIssueStatusTransitionList" :key="index"><divclass="menu-item"role="menuitem"@click.prevent="tryStartIssueStatusTransition(transition)"- >- {{ $t(transition.buttonName) }}- </div>+ >{{ $t(transition.buttonName) }}</div></template></BBContextMenu></template></div><template v-else>- <div- if="applicableIssueStatusTransitionList.length > 0"- class="flex space-x-2"- >- <template- v-for="(transition, index) in applicableIssueStatusTransitionList"- :key="index"- >+ <div if="applicableIssueStatusTransitionList.length > 0" class="flex space-x-2">+ <template v-for="(transition, index) in applicableIssueStatusTransitionList" :key="index"><buttontype="button":class="transition.buttonClass":disabled="!allowIssueStatusTransition(transition)"@click.prevent="tryStartIssueStatusTransition(transition)"- >- {{ $t(transition.buttonName) }}- </button>+ >{{ $t(transition.buttonName) }}</button></template><template v-if="allowRollback">- <button type="button" class="btn-primary" @click.prevent="doRollback">- {{ $t("common.rollback") }}- </button>+ <button+ type="button"+ class="btn-primary"+ @click.prevent="doRollback"+ >{{ $t("common.rollback") }}</button></template></div></template>@@ -250,9 +229,8 @@ export default defineComponent({break;case "APPROVE":updateStatusModalState.style = "INFO";- updateStatusModalState.title = `${t("common.approve")} '${- task.name- }'?`;+ updateStatusModalState.title = `${t("common.approve")} '${task.name+ }'?`;break;case "RETRY":updateStatusModalState.style = "INFO";@@ -260,9 +238,8 @@ export default defineComponent({break;case "CANCEL":updateStatusModalState.style = "INFO";- updateStatusModalState.title = `${t("common.cancel")} '${- task.name- }'?`;+ updateStatusModalState.title = `${t("common.cancel")} '${task.name+ }'?`;break;case "SKIP":updateStatusModalState.style = "INFO";@@ -407,13 +384,15 @@ export default defineComponent({if (newIssue.type == "bb.issue.database.create" ||- newIssue.type == "bb.issue.database.schema.update"+ newIssue.type == "bb.issue.database.schema.update" ||+ newIssue.type == "bb.issue.database.data.update") {for (const stage of newIssue.pipeline.stageList) {for (const task of stage.taskList) {if (task.type == "bb.task.database.create" ||- task.type == "bb.task.database.schema.update"+ task.type == "bb.task.database.schema.update" ||+ task.type == "bb.task.database.data.update") {if (isEmpty(task.statement)) {return false;diff --git a/frontend/src/components/Issue/PipelineSimpleFlow.vue b/frontend/src/components/Issue/PipelineSimpleFlow.vueindex d2243ce16b..28d285fefe 100644--- a/frontend/src/components/Issue/PipelineSimpleFlow.vue+++ b/frontend/src/components/Issue/PipelineSimpleFlow.vue@@ -3,14 +3,8 @@<olclass="border-t border-b border-block-border divide-y divide-gray-300 lg:flex lg:divide-y-0">- <li- v-for="(item, index) in itemList"- :key="index"- class="relative md:flex-1 md:flex"- >- <div- class="cursor-default group flex items-center justify-between w-full"- >+ <li v-for="(item, index) in itemList" :key="index" class="relative md:flex-1 md:flex">+ <div class="cursor-default group flex items-center justify-between w-full"><span class="pl-4 py-2 flex items-center text-sm font-medium"><divclass="relative w-6 h-6 flex flex-shrink-0 items-center justify-center rounded-full select-none"@@ -22,11 +16,7 @@class="h-2 w-2 bg-info rounded-full"aria-hidden="true"></span>- <span- v-else- class="h-1.5 w-1.5 bg-control rounded-full"- aria-hidden="true"- ></span>+ <span v-else class="h-1.5 w-1.5 bg-control rounded-full" aria-hidden="true"></span></template><template v-else-if="item.taskStatus === 'PENDING_APPROVAL'"><heroicons-outline:user class="w-4 h-4" />@@ -47,8 +37,7 @@<spanclass="h-2.5 w-2.5 rounded-full text-center pb-6 font-medium text-base"aria-hidden="true"- >!</span- >+ >!</span></template></div><div@@ -56,9 +45,7 @@:class="flowItemTextClass(item)"@click.prevent="clickItem(item)">- <span class="text-xs">- {{ item.stageName }}- </span>+ <span class="text-xs">{{ item.stageName }}</span><span class="text-sm">{{ item.taskName }}</span></div><div@@ -66,7 +53,7 @@:class="flowItemTextClass(item)"@click.prevent="clickItem(item)">- <span class="col-span-1 text-sm w-32">{{ item.stageName }} </span>+ <span class="col-span-1 text-sm w-32">{{ item.stageName }}</span><span class="col-span-1 text-sm">{{ item.taskName }}</span></div><div class="tooltip-wrapper" @click.prevent="clickItem(item)">@@ -75,9 +62,7 @@v-if="!item.valid"class="ml-2 w-5 h-5 flex justify-center rounded-full select-none bg-error text-white hover:bg-error-hover">- <span class="text-center font-normal" aria-hidden="true"- >!</span- >+ <span class="text-center font-normal" aria-hidden="true">!</span></span></div></span>@@ -160,7 +145,8 @@ export default defineComponent({for (const task of stage.taskList) {if (task.type == "bb.task.database.create" ||- task.type == "bb.task.database.schema.update"+ task.type == "bb.task.database.schema.update" ||+ task.type == "bb.task.database.data.update") {if (isEmpty((task as TaskCreate).statement)) {valid = false;@@ -173,9 +159,8 @@ export default defineComponent({if (stage.taskList.length > 1) {for (let i = 0; i < stage.taskList.length; i++) {if ((stage.taskList[i] as Task).id == (activeTask as Task).id) {- taskName = `${activeTask.name} (${i + 1}/${- stage.taskList.length- })`;+ taskName = `${activeTask.name} (${i + 1}/${stage.taskList.length+ })`;break;}}@@ -223,7 +208,7 @@ export default defineComponent({const flowItemTextClass = (item: FlowItem) => {let textClass =!props.create &&- activeTask(props.pipeline as Pipeline).id === item.taskId+ activeTask(props.pipeline as Pipeline).id === item.taskId? "font-bold ": "font-normal ";// For create, since we don't have stage id yet, we just compare name instead.diff --git a/frontend/src/components/Issue/PipelineTenantFlow.vue b/frontend/src/components/Issue/PipelineTenantFlow.vueindex 0f4bf6033b..ab7aa2785b 100644--- a/frontend/src/components/Issue/PipelineTenantFlow.vue+++ b/frontend/src/components/Issue/PipelineTenantFlow.vue@@ -17,29 +17,23 @@class="text cursor-pointer hover:underline hidden lg:ml-4 lg:flex lg:flex-col"@click.prevent="clickItem(item)">- <span class="text-xs">- {{ item.stageName }}- </span>+ <span class="text-xs">{{ item.stageName }}</span><span class="text-sm">{{ item.taskName }}</span></div><divclass="text ml-4 cursor-pointer flex items-center space-x-2 lg:hidden"@click.prevent="clickItem(item)">- <span class="text-sm min-w-32">{{ item.stageName }} </span>+ <span class="text-sm min-w-32">{{ item.stageName }}</span><span class="text-sm flex-1">{{ item.taskName }}</span></div><div class="tooltip-wrapper" @click.prevent="clickItem(item)">- <span class="tooltip whitespace-nowrap"- >Missing SQL statement</span- >+ <span class="tooltip whitespace-nowrap">Missing SQL statement</span><spanv-if="!item.valid"class="ml-2 w-5 h-5 flex justify-center rounded-full select-none bg-error text-white hover:bg-error-hover">- <span class="text-center font-normal" aria-hidden="true"- >!</span- >+ <span class="text-center font-normal" aria-hidden="true">!</span></span></div></span>@@ -83,19 +77,14 @@:status="task.status"class="transform scale-75"/>- <heroicons-solid:arrow-narrow-right- v-if="isActiveTask(task)"- class="name w-5 h-5"- />+ <heroicons-solid:arrow-narrow-right v-if="isActiveTask(task)" class="name w-5 h-5" /><div class="name">{{ j + 1 }} - {{ databaseForTask(task).name }}</div></div><div class="flex items-center px-1 py-1 whitespace-pre-wrap"><InstanceEngineIcon :instance="databaseForTask(task).instance" /><spanclass="flex-1 ml-2 overflow-x-hidden whitespace-nowrap overflow-ellipsis"- >- {{ instanceName(databaseForTask(task).instance) }}- </span>+ >{{ instanceName(databaseForTask(task).instance) }}</span></div></div></div>@@ -216,7 +205,8 @@ export default defineComponent({for (const task of stage.taskList) {if (task.type == "bb.task.database.create" ||- task.type == "bb.task.database.schema.update"+ task.type == "bb.task.database.schema.update" ||+ task.type == "bb.task.database.data.update") {if (isEmpty((task as TaskCreate).statement)) {valid = false;@@ -229,9 +219,8 @@ export default defineComponent({if (stage.taskList.length > 1) {for (let i = 0; i < stage.taskList.length; i++) {if ((stage.taskList[i] as Task).id == (activeTask as Task).id) {- taskName = `${activeTask.name} (${i + 1}/${- stage.taskList.length- })`;+ taskName = `${activeTask.name} (${i + 1}/${stage.taskList.length+ })`;break;}}diff --git a/frontend/src/components/Issue/TaskCheckBar.vue b/frontend/src/components/Issue/TaskCheckBar.vueindex e8c5abca19..ac29a137f7 100644--- a/frontend/src/components/Issue/TaskCheckBar.vue+++ b/frontend/src/components/Issue/TaskCheckBar.vue@@ -6,9 +6,7 @@class="btn-small py-0.5":disabled="hasRunningTaskCheck"@click.prevent="runChecks"- >- {{ hasRunningTaskCheck ? $t("task.checking") : $t("task.run-task") }}- </button>+ >{{ hasRunningTaskCheck ? $t("task.checking") : $t("task.run-task") }}</button><TaskCheckBadgeBar:task-check-run-list="task.taskCheckRunList"@select-task-check-run="@@ -53,9 +51,7 @@type="button"class="btn-primary py-2 px-4"@click.prevent="dismissDialog"- >- {{ $t("common.close") }}- </button>+ >{{ $t("common.close") }}</button></div></div></BBModal>@@ -130,7 +126,7 @@ export default defineComponent({const showRunCheckButton = computed((): boolean => {if (!props.allowRunTask) return false;return (- props.task.type == "bb.task.database.schema.update" &&+ (props.task.type == "bb.task.database.schema.update" || props.task.type == "bb.task.database.data.update") &&(props.task.status == "PENDING" ||props.task.status == "PENDING_APPROVAL" ||props.task.status == "RUNNING" ||diff --git a/frontend/src/components/Issue/TaskRunTable.vue b/frontend/src/components/Issue/TaskRunTable.vueindex f1ca41548e..e57cde03e4 100644--- a/frontend/src/components/Issue/TaskRunTable.vue+++ b/frontend/src/components/Issue/TaskRunTable.vue@@ -27,9 +27,7 @@<heroicons-outline:check class="w-5 h-5" /></template><template v-else-if="taskRun.status == 'FAILED'">- <span class="text-white font-medium text-base" aria-hidden="true">- !- </span>+ <span class="text-white font-medium text-base" aria-hidden="true">!</span></template><template v-else-if="taskRun.status == 'CANCELED'"><heroicons-outline:minus-sm class="w-5 h-5" />@@ -43,8 +41,7 @@<router-linkclass="ml-1 normal-link":to="commentLink(taskRun).link"- >{{ commentLink(taskRun).title }}</router-link- >+ >{{ commentLink(taskRun).title }}</router-link></template></BBTableCell><BBTableCell class="table-cell w-12">@@ -52,19 +49,13 @@<PrincipalAvatar :principal="taskRun.creator" :size="'SMALL'" /><div class="flex flex-col"><div class="flex flex-row items-center space-x-2">- <router-link :to="`/u/${taskRun.creator.id}`"- >{{ taskRun.creator.name }}- </router-link>+ <router-link :to="`/u/${taskRun.creator.id}`">{{ taskRun.creator.name }}</router-link></div></div></div></BBTableCell>- <BBTableCell class="table-cell w-12">- {{ humanizeTs(taskRun.createdTs) }}- </BBTableCell>- <BBTableCell class="table-cell w-12">- {{ humanizeTs(taskRun.updatedTs) }}- </BBTableCell>+ <BBTableCell class="table-cell w-12">{{ humanizeTs(taskRun.createdTs) }}</BBTableCell>+ <BBTableCell class="table-cell w-12">{{ humanizeTs(taskRun.updatedTs) }}</BBTableCell></template></BBTable></template>@@ -136,7 +127,8 @@ export default defineComponent({const commentLink = (taskRun: TaskRun): CommentLink => {if (taskRun.status == "DONE") {switch (taskRun.type) {- case "bb.task.database.schema.update": {+ case "bb.task.database.schema.update":+ case "bb.task.database.data.update": {return {title: t("task.view-migration"),link: `/db/${databaseSlug(diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex 45bb4eef41..2554ac5d73 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -1,7 +1,5 @@<template>- <div- class="pt-1 overflow-hidden grid grid-cols-4 gap-x-2 gap-y-4 md:inline-flex md:gap-x-0"- >+ <div class="pt-1 overflow-hidden grid grid-cols-4 gap-x-2 gap-y-4 md:inline-flex md:gap-x-0"><template v-for="(quickAction, index) in quickActionList" :key="index"><divv-if="quickAction == 'quickaction.bb.instance.create'"@@ -10,9 +8,9 @@<button class="btn-icon-primary p-3" @click.prevent="createInstance"><heroicons-outline:plus-sm class="w-6 h-6" /></button>- <h3 class="mt-1 text-base font-normal text-main tracking-tight">- {{ $t("quick-action.add-instance") }}- </h3>+ <h3+ class="mt-1 text-base font-normal text-main tracking-tight"+ >{{ $t("quick-action.add-instance") }}</h3></div><div@@ -24,9 +22,7 @@</router-link><h3class="mt-1 text-center text-base font-normal text-main tracking-tight"- >- {{ $t("quick-action.manage-user") }}- </h3>+ >{{ $t("quick-action.manage-user") }}</h3></div><div@@ -38,9 +34,7 @@</button><h3class="mt-1 text-center text-base font-normal text-main tracking-tight"- >- {{ $t("common.query") }}- </h3>+ >{{ $t("common.query") }}</h3></div><div@@ -52,9 +46,7 @@</button><h3class="mt-1 text-center text-base font-normal text-main tracking-tight"- >- {{ $t("quick-action.edit-data") }}- </h3>+ >{{ $t("quick-action.edit-data") }}</h3></div><div@@ -66,9 +58,7 @@</button><h3class="mt-1 text-base text-center font-normal text-main tracking-tight"- >- {{ $t("quick-action.new-db") }}- </h3>+ >{{ $t("quick-action.new-db") }}</h3></div><div@@ -80,9 +70,7 @@</button><h3class="mt-1 text-base text-center font-normal text-main tracking-tight"- >- {{ $t("quick-action.request-db") }}- </h3>+ >{{ $t("quick-action.request-db") }}</h3></div><div@@ -92,9 +80,21 @@<button class="btn-icon-primary p-3" @click.prevent="alterSchema"><heroicons-outline:pencil-alt class="w-6 h-6" /></button>- <h3 class="mt-1 text-center text-base font-normal text-main">- {{ $t("quick-action.alter-schema") }}- </h3>+ <h3+ class="mt-1 text-center text-base font-normal text-main"+ >{{ $t("database.alter-schema") }}</h3>+ </div>++ <div+ v-if="quickAction == 'quickaction.bb.database.data.update'"+ class="flex flex-col items-center w-28"+ >+ <button class="btn-icon-primary p-3" @click.prevent="changeData">+ <heroicons-outline:pencil class="w-6 h-6" />+ </button>+ <h3+ class="mt-1 text-center text-base font-normal text-main"+ >{{ $t("database.change-data") }}</h3></div><div@@ -104,9 +104,9 @@<router-link to="/issue/new" class="btn-icon-primary p-3"><heroicons-outline:hand class="w-6 h-6" /></router-link>- <h3 class="mt-1 text-center text-base font-normal text-main">- {{ $t("quick-action.troubleshoot") }}- </h3>+ <h3+ class="mt-1 text-center text-base font-normal text-main"+ >{{ $t("quick-action.troubleshoot") }}</h3></div><div@@ -116,24 +116,17 @@<button class="btn-icon-primary p-3" @click.prevent="createEnvironment"><heroicons-outline:plus-sm class="w-6 h-6" /></button>- <h3 class="mt-1 text-center text-base font-normal text-main">- {{ $t("environment.create") }}- </h3>+ <h3 class="mt-1 text-center text-base font-normal text-main">{{ $t("environment.create") }}</h3></div><divv-if="quickAction == 'quickaction.bb.environment.reorder'"class="flex flex-col items-center w-28">- <button- class="btn-icon-primary p-3"- @click.prevent="reorderEnvironment"- >+ <button class="btn-icon-primary p-3" @click.prevent="reorderEnvironment"><heroicons-outline:selector class="transform rotate-90 w-6 h-6" /></button>- <h3 class="mt-1 text-center text-base font-normal text-main">- {{ $t("common.reorder") }}- </h3>+ <h3 class="mt-1 text-center text-base font-normal text-main">{{ $t("common.reorder") }}</h3></div><div@@ -143,9 +136,9 @@<button class="btn-icon-primary p-3" @click.prevent="createProject"><heroicons-outline:template class="w-6 h-6" /></button>- <h3 class="mt-1 text-center text-base font-normal text-main">- {{ $t("quick-action.new-project") }}- </h3>+ <h3+ class="mt-1 text-center text-base font-normal text-main"+ >{{ $t("quick-action.new-project") }}</h3></div><div@@ -155,9 +148,9 @@<button class="btn-icon-primary p-3" @click.prevent="goDefaultProject"><heroicons-outline:cube class="w-6 h-6" /></button>- <h3 class="mt-1 text-center text-base font-normal text-main">- {{ $t("quick-action.default-project") }}- </h3>+ <h3+ class="mt-1 text-center text-base font-normal text-main"+ >{{ $t("quick-action.default-project") }}</h3></div><div@@ -167,9 +160,9 @@<button class="btn-icon-primary p-3" @click.prevent="transferDatabase"><heroicons-outline:chevron-double-down class="w-6 h-6" /></button>- <h3 class="mt-1 text-center text-base font-normal text-main">- {{ $t("quick-action.transfer-in-db") }}- </h3>+ <h3+ class="mt-1 text-center text-base font-normal text-main"+ >{{ $t("quick-action.transfer-in-db") }}</h3></div></template></div>@@ -182,9 +175,7 @@<template v-if="state.quickActionType == 'quickaction.bb.project.create'"><ProjectCreate @dismiss="state.showModal = false" /></template>- <template- v-else-if="state.quickActionType == 'quickaction.bb.instance.create'"- >+ <template v-else-if="state.quickActionType == 'quickaction.bb.instance.create'"><InstanceForm :create="true" @dismiss="state.showModal = false" /></template><template@@ -195,21 +186,27 @@<!-- eslint-disable vue/attribute-hyphenation --><AlterSchemaPrepForm:projectId="projectId"+ :type="'bb.issue.database.schema.update'"@dismiss="state.showModal = false"/></template><template- v-else-if="state.quickActionType == 'quickaction.bb.database.create'"+ v-else-if="+ state.quickActionType == 'quickaction.bb.database.data.update'+ "><!-- eslint-disable vue/attribute-hyphenation -->- <CreateDatabasePrepForm+ <AlterSchemaPrepForm:projectId="projectId"+ :type="'bb.issue.database.data.update'"@dismiss="state.showModal = false"/></template>- <template- v-else-if="state.quickActionType == 'quickaction.bb.database.request'"- >+ <template v-else-if="state.quickActionType == 'quickaction.bb.database.create'">+ <!-- eslint-disable vue/attribute-hyphenation -->+ <CreateDatabasePrepForm :projectId="projectId" @dismiss="state.showModal = false" />+ </template>+ <template v-else-if="state.quickActionType == 'quickaction.bb.database.request'"><RequestDatabasePrepForm @dismiss="state.showModal = false" /></template><template@@ -218,10 +215,7 @@"><!-- eslint-disable vue/attribute-hyphenation -->- <TransferDatabaseForm- :projectId="projectId"- @dismiss="state.showModal = false"- />+ <TransferDatabaseForm :projectId="projectId" @dismiss="state.showModal = false" /></template></BBModal></template>@@ -315,12 +309,19 @@ export default defineComponent({};const alterSchema = () => {- state.modalTitle = t("quick-action.alter-schema");+ state.modalTitle = t("database.alter-schema");state.modalSubtitle = t("quick-action.choose-db");state.quickActionType = "quickaction.bb.database.schema.update";state.showModal = true;};+ const changeData = () => {+ state.modalTitle = t("database.change-data");+ state.modalSubtitle = t("quick-action.choose-db");+ state.quickActionType = "quickaction.bb.database.data.update";+ state.showModal = true;+ };+const createDatabase = () => {state.modalTitle = t("quick-action.create-db");state.modalSubtitle = "";@@ -361,7 +362,7 @@ export default defineComponent({perform: () => requestDatabase(),},"quickaction.bb.database.schema.update": {- name: t("quick-action.alter-schema"),+ name: t("database.alter-schema"),perform: () => alterSchema(),},"quickaction.bb.database.troubleshoot": {@@ -416,6 +417,7 @@ export default defineComponent({transferDatabase,createInstance,alterSchema,+ changeData,createDatabase,requestDatabase,createEnvironment,diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.ymlindex d11cbccaa4..78614fb1cc 100644--- a/frontend/src/locales/en.yml+++ b/frontend/src/locales/en.yml@@ -379,20 +379,18 @@ issue:alter-schema:vcs-enabled: >-This project has enabled VCS based version control and selecting database- below will navigate you to the corresponding Git repository to create schema- change.+ below will navigate you to the corresponding Git repository to initiate the change process.vcs-info: >-indicates the project has enabled VCS based version control. Selectingdatabase belonging to such project will navigate you to the corresponding- Git repository to create schema change.+ Git repository to initiate the change process.alter-single-db: Alter single databasealter-multiple-db: Alter multiple databasesalter-multiple-db-info: >-For each environment, you can select a database to alter its schema or justskip that environment. This allows you to compose a single pipeline to- propagate schema changes across multiple environments.+ propagate changes across multiple environments.quick-action:- alter-schema: Alter Schemacreate-db: Create databasechoose-db: Choose databasenew-db: New DB@@ -672,7 +670,10 @@ database:database-name-is-restored-from-another-database-backup: '{0} is restored from another database backup'database-backup: database backuptransfer-project: Transfer Project+ alter-schema: Alter Schemaalter-schema-in-vcs: Alter Schema in VCS+ change-data: Change Data+ change-data-in-vcs: Change Data in VCSsuccessfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name: Successfully transferred '{0}' to project '{1}'.backup-name: Backup namecreate-backup: Create backupdiff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.ymlindex 57dd6eeb63..bc73f01f25 100644--- a/frontend/src/locales/zh-CN.yml+++ b/frontend/src/locales/zh-CN.yml@@ -371,13 +371,12 @@ issue:stage-select:active: '{name}(活动中)'alter-schema:- vcs-enabled: 该项目开启了基于 VCS 的版本管理,选择下面的数据库会将您导航到相应的 Git 仓库以创建 schema 变更。- vcs-info: 代表项目开启了基于 VCS 的版本管理。选择该类项目下的数据库会将您导航到对应的 Git 仓库以创建 schema 变更。+ vcs-enabled: 该项目开启了基于 VCS 的版本管理,选择下面的数据库会将您导航到相应的 Git 仓库以发起变更流程。+ vcs-info: 代表项目开启了基于 VCS 的版本管理。选择该类项目下的数据库会将您导航到对应的 Git 仓库以发起变更流程。alter-single-db: 变更单个数据库alter-multiple-db: 变更多个数据库- alter-multiple-db-info: 针对每个环境,您可以选择一个数据库进行变更或者直接跳过该环境,这样您就可以在一条流水线上把 schema 变更逐步作用到多个环境。+ alter-multiple-db-info: 针对每个环境,您可以选择一个数据库进行变更或者直接跳过该环境,这样您就可以在一条流水线上把变更逐步作用到多个环境。quick-action:- alter-schema: 变更 Schemacreate-db: 创建数据库choose-db: 选择数据库new-db: 创建数据库@@ -609,7 +608,10 @@ database:restored-from: 恢复于database-name-is-restored-from-another-database-backup: '{0}恢复于另一个数据库备份'transfer-project: 转移项目- alter-schema-in-vcs: 变更 Schema(VCS)+ alter-schema: 变更 Schema+ alter-schema-in-vcs: 变更 Schema (VCS)+ change-data: 变更数据+ change-data-in-vcs: 变更数据 (VCS)successfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name: 成功将'{0}'转移到项目'{1}'。database-backup: 数据库备份backup-name: 备份名称diff --git a/frontend/src/plugins/issue/DatabaseDataUpdateTemplate.ts b/frontend/src/plugins/issue/DatabaseDataUpdateTemplate.tsnew file mode 100644index 0000000000..2b64a54142--- /dev/null+++ b/frontend/src/plugins/issue/DatabaseDataUpdateTemplate.ts@@ -0,0 +1,66 @@+import {+ IssueCreate,+ PipelineApporvalPolicyPayload,+ StageCreate,+ UNKNOWN_ID,+} from "../../types";+import { IssueTemplate, TemplateContext } from "../types";++const template: IssueTemplate = {+ type: "bb.issue.database.data.update",+ buildIssue: (+ ctx: TemplateContext+ ): Omit<IssueCreate, "projectId" | "creatorId"> => {+ const payload: any = {};+ const stageList: StageCreate[] = [];+ for (let i = 0; i < ctx.databaseList.length; i++) {+ stageList.push({+ name: `[${ctx.environmentList[i].name}] ${ctx.databaseList[i].name}`,+ environmentId: ctx.environmentList[i].id,+ taskList: [+ {+ name: `Change ${ctx.databaseList[i].name} data`,+ status:+ (+ ctx.approvalPolicyList[i]+ .payload as PipelineApporvalPolicyPayload+ ).value == "MANUAL_APPROVAL_ALWAYS"+ ? "PENDING_APPROVAL"+ : "PENDING",+ type: "bb.task.database.data.update",+ instanceId: ctx.databaseList[i].instance.id,+ databaseId: ctx.databaseList[i].id,+ statement: ctx.statementList ? ctx.statementList[i] : "",+ rollbackStatement: ctx.rollbackStatementList+ ? ctx.rollbackStatementList[i]+ : "",+ migrationType: "MIGRATE",+ earliestAllowedTs: 0,+ },+ ],+ });+ }+ return {+ name:+ ctx.databaseList.length == 1+ ? `[${ctx.databaseList[0].name}] Change data`+ : "Change database data",+ type: "bb.issue.database.data.update",+ description: "",+ assigneeId: UNKNOWN_ID,+ pipeline: {+ stageList,+ name:+ ctx.databaseList.length == 1+ ? `[${ctx.databaseList[0].name}] Change data pipeline`+ : "Update database data pipeline",+ },+ createContext: {},+ payload,+ };+ },+ inputFieldList: [],+ outputFieldList: [],+};++export default template;diff --git a/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.ts b/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.tsindex 9f9fe9a5b8..dc129d8dae 100644--- a/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.ts+++ b/frontend/src/plugins/issue/DatabaseSchemaBaselineTemplate.ts@@ -33,6 +33,7 @@ const template: IssueTemplate = {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.tsindex 587a3d8708..0cfea708ae 100644--- a/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts+++ b/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts@@ -35,6 +35,7 @@ const template: IssueTemplate = {? ctx.rollbackStatementList[i]: "",migrationType: "MIGRATE",+ earliestAllowedTs: 0,},],});diff --git a/frontend/src/plugins/issue/template.ts b/frontend/src/plugins/issue/template.tsindex f47cf179e1..7a7428e56b 100644--- a/frontend/src/plugins/issue/template.ts+++ b/frontend/src/plugins/issue/template.ts@@ -4,6 +4,7 @@ import DatabaseCreateTemplate from "./DatabaseCreateTemplate";import DatabaseGrantTemplate from "./DatabaseGrantTemplate";import DatabaseSchemaBaselineTemplate from "./DatabaseSchemaBaselineTemplate";import DatabaseSchemaUpdateTemplate from "./DatabaseSchemaUpdateTemplate";+import DatabaseDataUpdateTemplate from "./DatabaseDataUpdateTemplate";import DefaultTemplate from "./DefaultTemplate";type TemplateType = IssueType | "bb.issue.database.schema.baseline";@@ -13,6 +14,7 @@ const allIssueTemplateList: IssueTemplate[] = [DatabaseCreateTemplate,DatabaseGrantTemplate,DatabaseSchemaUpdateTemplate,+ DatabaseDataUpdateTemplate,DatabaseSchemaBaselineTemplate,];diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex 5da91716fa..ba7f1e1e15 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -96,50 +96,56 @@ const routes: Array<RouteRecordRaw> = ["plan/feature"]("bb.dba-workflow")? [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.database.troubleshoot",- "quickaction.bb.instance.create",- "quickaction.bb.project.create",- "quickaction.bb.user.manage",- ]+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.database.troubleshoot",+ "quickaction.bb.instance.create",+ "quickaction.bb.project.create",+ "quickaction.bb.user.manage",+ ]: [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.instance.create",- "quickaction.bb.project.create",- "quickaction.bb.user.manage",- ];+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.instance.create",+ "quickaction.bb.project.create",+ "quickaction.bb.user.manage",+ ];const dbaList: QuickActionType[] = store.getters["plan/feature"]("bb.dba-workflow")? [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.database.troubleshoot",- "quickaction.bb.instance.create",- "quickaction.bb.project.create",- ]+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.database.troubleshoot",+ "quickaction.bb.instance.create",+ "quickaction.bb.project.create",+ ]: [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.instance.create",- "quickaction.bb.project.create",- ];+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.instance.create",+ "quickaction.bb.project.create",+ ];const developerList: QuickActionType[] = store.getters["plan/feature"]("bb.dba-workflow")? [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.request",- "quickaction.bb.database.troubleshoot",- "quickaction.bb.project.create",- ]+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.request",+ "quickaction.bb.database.troubleshoot",+ "quickaction.bb.project.create",+ ]: [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.project.create",- ];+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.project.create",+ ];return new Map([["OWNER", ownerList],["DBA", dbaList],@@ -467,12 +473,19 @@ const routes: Array<RouteRecordRaw> = [}}++const actionList: string[] = allowEditProject- ? [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.project.database.transfer",- ]+ ? project.tenantMode == 'DISABLED' ? [+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.project.database.transfer",+ ] : [+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.create",+ "quickaction.bb.project.database.transfer",+ ]: [];return new Map([["OWNER", actionList],@@ -517,12 +530,11 @@ const routes: Array<RouteRecordRaw> = [const projectSlug = route.params.projectSlug as string;const projectWebhookSlug = route.params.projectWebhookSlug as string;- return `${t("common.webhook")} - ${- store.getters["projectWebhook/projectWebhookById"](- idFromSlug(projectSlug),- idFromSlug(projectWebhookSlug)- ).name- }`;+ return `${t("common.webhook")} - ${store.getters["projectWebhook/projectWebhookById"](+ idFromSlug(projectSlug),+ idFromSlug(projectWebhookSlug)+ ).name+ }`;},allowBookmark: true,},@@ -559,38 +571,44 @@ const routes: Array<RouteRecordRaw> = ["plan/feature"]("bb.dba-workflow")? [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.database.troubleshoot",- ]+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.database.troubleshoot",+ ]: [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- ];+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ ];const dbaList: QuickActionType[] = store.getters["plan/feature"]("bb.dba-workflow")? [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- "quickaction.bb.database.troubleshoot",- ]+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ "quickaction.bb.database.troubleshoot",+ ]: [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- ];+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ ];const developerList: QuickActionType[] = store.getters["plan/feature"]("bb.dba-workflow")? [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.request",- "quickaction.bb.database.troubleshoot",- ]+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.request",+ "quickaction.bb.database.troubleshoot",+ ]: [- "quickaction.bb.database.schema.update",- "quickaction.bb.database.create",- ];+ "quickaction.bb.database.schema.update",+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.create",+ ];return new Map([["OWNER", ownerList],["DBA", dbaList],@@ -663,11 +681,10 @@ const routes: Array<RouteRecordRaw> = [if (slug.toLowerCase() == "new") {return t("common.new");}- return `${t("common.data-source")} - ${- store.getters["dataSource/dataSourceById"](- idFromSlug(slug)- ).name- }`;+ return `${t("common.data-source")} - ${store.getters["dataSource/dataSourceById"](+ idFromSlug(slug)+ ).name+ }`;},allowBookmark: true,},diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex ee2dbbe9b0..2f4fe59db1 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -87,6 +87,7 @@ export type DatabaseQuickActionType =| "quickaction.bb.database.create" // Used by DBA and Owner| "quickaction.bb.database.request" // Used by Developer| "quickaction.bb.database.schema.update"+ | "quickaction.bb.database.data.update"| "quickaction.bb.database.troubleshoot";export type QuickActionType =diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.tsindex 9ccf7b7342..85fa6a759c 100644--- a/frontend/src/types/issue.ts+++ b/frontend/src/types/issue.ts@@ -16,7 +16,8 @@ type IssueTypeGeneral = "bb.issue.general";type IssueTypeDatabase =| "bb.issue.database.create"| "bb.issue.database.grant"- | "bb.issue.database.schema.update";+ | "bb.issue.database.schema.update"+ | "bb.issue.database.data.update";type IssueTypeDataSource = "bb.issue.data-source.request";diff --git a/frontend/src/types/pipeline/task.ts b/frontend/src/types/pipeline/task.tsindex 9070d3e9c1..c01aea26a4 100644--- a/frontend/src/types/pipeline/task.ts+++ b/frontend/src/types/pipeline/task.ts@@ -18,6 +18,7 @@ export type TaskType =| "bb.task.general"| "bb.task.database.create"| "bb.task.database.schema.update"+ | "bb.task.database.data.update"| "bb.task.database.restore";export type TaskStatus =@@ -51,6 +52,12 @@ export type TaskDatabaseSchemaUpdatePayload = {pushEvent?: VCSPushEvent;};+export type TaskDatabaseDataUpdatePayload = {+ statement: string;+ rollbackStatement: string;+ pushEvent?: VCSPushEvent;+};+export type TaskDatabaseRestorePayload = {databaseName: string;backupId: BackupId;@@ -60,6 +67,7 @@ export type TaskPayload =| TaskGeneralPayload| TaskDatabaseCreatePayload| TaskDatabaseSchemaUpdatePayload+ | TaskDatabaseDataUpdatePayload| TaskDatabaseRestorePayload| TaskEarliestAllowedTimePayload;diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex 3586000de9..8d24350239 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -2,9 +2,7 @@<div class="flex-1 overflow-auto focus:outline-none" tabindex="0"><main class="flex-1 relative overflow-y-auto"><!-- Highlight Panel -->- <div- class="px-4 pb-4 space-y-2 md:space-y-0 md:flex md:items-center md:justify-between"- >+ <div class="px-4 pb-4 space-y-2 md:space-y-0 md:flex md:items-center md:justify-between"><div class="flex-1 min-w-0"><!-- Summary --><div class="flex items-center">@@ -12,63 +10,47 @@<div class="flex items-center"><h1class="pt-2 pb-2.5 text-xl font-bold leading-6 text-main truncate"- >- {{ database.name }}- </h1>+ >{{ database.name }}</h1></div></div></div>- <dl- class="flex flex-col space-y-1 md:space-y-0 md:flex-row md:flex-wrap"- >+ <dl class="flex flex-col space-y-1 md:space-y-0 md:flex-row md:flex-wrap"><dt class="sr-only">{{ $t("common.environment") }}</dt><dd class="flex items-center text-sm md:mr-4">- <span class="textlabel"- >{{ $t("common.environment") }} - </span- >+ <span class="textlabel">{{ $t("common.environment") }} - </span><router-link:to="`/environment/${environmentSlug(database.instance.environment)}`"class="normal-link"- >{{- environmentName(database.instance.environment)- }}</router-link>+ {{+ environmentName(database.instance.environment)+ }}+ </router-link></dd><dt class="sr-only">{{ $t("common.instance") }}</dt><dd class="flex items-center text-sm md:mr-4"><InstanceEngineIcon :instance="database.instance" />- <span class="ml-1 textlabel"- >{{ $t("common.instance") }} - </span- >+ <span class="ml-1 textlabel">{{ $t("common.instance") }} - </span><router-link:to="`/instance/${instanceSlug(database.instance)}`"class="normal-link"- >{{ instanceName(database.instance) }}</router-link- >+ >{{ instanceName(database.instance) }}</router-link></dd><dt class="sr-only">{{ $t("common.project") }}</dt><dd class="flex items-center text-sm md:mr-4">- <span class="textlabel"- >{{ $t("common.project") }} - </span- >+ <span class="textlabel">{{ $t("common.project") }} - </span><router-link:to="`/project/${projectSlug(database.project)}`"class="normal-link"- >{{ projectName(database.project) }}</router-link- >+ >{{ projectName(database.project) }}</router-link></dd><template v-if="database.sourceBackup"><dt class="sr-only">{{ $t("db.parent") }}</dt><dd class="flex items-center text-sm md:mr-4 tooltip-wrapper">- <span class="textlabel">- {{ $t("database.restored-from") }}- </span>- <router-link- :to="`/db/${database.sourceBackup.databaseId}`"- class="normal-link"- >+ <span class="textlabel">{{ $t("database.restored-from") }}</span>+ <router-link :to="`/db/${database.sourceBackup.databaseId}`" class="normal-link"><!-- Do not display the name of the backup's database because that requires a fetch --><span class="tooltip">{{@@ -90,9 +72,7 @@</dd></dl><div v-if="isTenantProject" class="flex items-center mt-2 h-7">- <label class="textlabel">- {{ $t("common.labels") }} - - </label>+ <label class="textlabel">{{ $t("common.labels") }} - </label><DatabaseLabelsEditor:label-list="database.labels":allow-edit="allowAdmin"@@ -108,16 +88,16 @@@click.prevent="tryTransferProject"><span>{{ $t("database.transfer-project") }}</span>- <heroicons-outline:switch-horizontal+ <heroicons-outline:switch-horizontal class="-mr-1 ml-2 h-5 w-5 text-control-light" />+ </button>+ <button v-if="allowEdit" type="button" class="btn-normal" @click.prevent="changeData">+ <span>{{ changeDataText }}</span>+ <heroicons-outline:external-link+ v-if="database.project.workflowType == 'VCS'"class="-mr-1 ml-2 h-5 w-5 text-control-light"/></button>- <button- v-if="allowEdit"- type="button"- class="btn-normal"- @click.prevent="alterSchema"- >+ <button v-if="allowEdit" type="button" class="btn-normal" @click.prevent="alterSchema"><span>{{ alterSchemaText }}</span><heroicons-outline:external-linkv-if="database.project.workflowType == 'VCS'"@@ -156,20 +136,16 @@type="button"class="btn-normal py-2 px-4"@click.prevent="state.showModal = false"- >- {{ $t("common.cancel") }}- </button>+ >{{ $t("common.cancel") }}</button><buttontype="button"class="btn-primary ml-3 inline-flex justify-center py-2 px-4":disabled="state.editingProjectId == database.project.id"@click.prevent="- updateProject(state.editingProjectId);- state.showModal = false;+ updateProject(state.editingProjectId);+state.showModal = false;"- >- {{ $t("common.transfer") }}- </button>+ >{{ $t("common.transfer") }}</button></div></BBModal><BBTabFilter@@ -188,10 +164,7 @@<DatabaseOverviewPanel :database="database" /></template><template v-if="state.selectedIndex == MIGRATION_HISTORY_TAB">- <DatabaseMigrationHistoryPanel- :database="database"- :allow-edit="allowEdit"- />+ <DatabaseMigrationHistoryPanel :database="database" :allow-edit="allowEdit" /></template><template v-if="state.selectedIndex == BACKUP_TAB"><DatabaseBackupPanel@@ -362,7 +335,14 @@ export default defineComponent({if (database.value.project.workflowType == "VCS") {return t("database.alter-schema-in-vcs");}- return t("quick-action.alter-schema");+ return t("database.alter-schema");+ });++ const changeDataText = computed(() => {+ if (database.value.project.workflowType == "VCS") {+ return t("database.change-data-in-vcs");+ }+ return t("database.change-data");});const tabItemList = computed((): BBTabFilterItem[] => {@@ -402,6 +382,32 @@ export default defineComponent({}};+ const changeData = () => {+ if (database.value.project.workflowType == "UI") {+ router.push({+ name: "workspace.issue.detail",+ params: {+ issueSlug: "new",+ },+ query: {+ template: "bb.issue.database.data.update",+ name: `[${database.value.name}] Change data`,+ project: database.value.project.id,+ databaseList: database.value.id,+ },+ });+ } else if (database.value.project.workflowType == "VCS") {+ store+ .dispatch(+ "repository/fetchRepositoryByProjectId",+ database.value.project.id+ )+ .then((repository: Repository) => {+ window.open(baseDirectoryWebUrl(repository), "_blank");+ });+ }+ };+const updateProject = (newProjectId: ProjectId) => {store.dispatch("database/transferProject", {@@ -486,7 +492,9 @@ export default defineComponent({tabItemList,tryTransferProject,alterSchema,+ changeData,alterSchemaText,+ changeDataText,updateProject,updateLabels,selectTab,diff --git a/frontend/src/views/IssueDetail.vue b/frontend/src/views/IssueDetail.vueindex 8da19c0d1c..4e35268a28 100644--- a/frontend/src/views/IssueDetail.vue+++ b/frontend/src/views/IssueDetail.vue@@ -33,6 +33,7 @@ import {Database,Environment,TaskDatabaseSchemaUpdatePayload,+ TaskDatabaseDataUpdatePayload,NORMAL_POLL_INTERVAL,POLL_JITTER,POST_CHANGE_POLL_INTERVAL,@@ -227,9 +228,9 @@ export default defineComponent({title ="INVALID STATE, please create rollback from the original issue.";} else {- if (rollbackIssue.type != "bb.issue.database.schema.update") {+ if (rollbackIssue.type != "bb.issue.database.schema.update" && rollbackIssue.type != "bb.issue.database.data.update") {title =- "INVALID STATE, only support to rollback update schema issue.";+ "INVALID STATE, only support to rollback update schema or change data issue.";} else if (rollbackIssue.status != "DONE" &&rollbackIssue.status != "CANCELED"@@ -240,17 +241,25 @@ export default defineComponent({for (const stage of rollbackIssue.pipeline.stageList) {for (const task of stage.taskList) {if (- task.status == "DONE" &&- task.type == "bb.task.database.schema.update" &&- !isEmpty(- (task.payload as TaskDatabaseSchemaUpdatePayload)- .rollbackStatement- )- ) {- validState = true;- break;+ task.status == "DONE") {+ if (task.type == "bb.task.database.schema.update" &&+ !isEmpty(+ (task.payload as TaskDatabaseSchemaUpdatePayload)+ .rollbackStatement+ )) {+ validState = true;+ break;+ } else if (task.type == "bb.task.database.data.update" &&+ !isEmpty(+ (task.payload as TaskDatabaseDataUpdatePayload)+ .rollbackStatement+ )) {+ validState = true;+ break;+ }}}+if (validState) {break;}@@ -277,14 +286,25 @@ export default defineComponent({const stage = rollbackIssue.pipeline.stageList[i];for (let j = stage.taskList.length - 1; j >= 0; j--) {const task = stage.taskList[j];- if (- task.status == "DONE" &&- task.type == "bb.task.database.schema.update" &&- !isEmpty(- (task.payload as TaskDatabaseSchemaUpdatePayload)- .rollbackStatement- )- ) {+ let allowRollback = false++ if (task.status == "DONE") {+ if (task.type == "bb.task.database.schema.update" &&+ !isEmpty(+ (task.payload as TaskDatabaseSchemaUpdatePayload)+ .rollbackStatement+ )) {+ allowRollback = true+ } else if (task.type == "bb.task.database.data.update" &&+ !isEmpty(+ (task.payload as TaskDatabaseDataUpdatePayload)+ .rollbackStatement+ )) {+ allowRollback = true+ }+ }++ if (allowRollback) {environmentList.push(stage.environment);approvalPolicyList.push(store.getters["policy/policyByEnvironmentIdAndType"](@@ -450,7 +470,8 @@ export default defineComponent({// 2. Update the database schema, will do connection and syntax check.if ((issue.value.type == "bb.issue.database.create" ||- issue.value.type == "bb.issue.database.schema.update") &&+ issue.value.type == "bb.issue.database.schema.update" ||+ issue.value.type == "bb.issue.database.data.update") &&Date.now() - (issue.value as Issue).updatedTs * 1000 < 5000) {interval = POST_CHANGE_POLL_INTERVAL;diff --git a/frontend/src/views/SqlEditor/AsidePanel/TableSchema.vue b/frontend/src/views/SqlEditor/AsidePanel/TableSchema.vueindex e654314fca..84fe2a4cfe 100644--- a/frontend/src/views/SqlEditor/AsidePanel/TableSchema.vue+++ b/frontend/src/views/SqlEditor/AsidePanel/TableSchema.vue@@ -5,9 +5,7 @@<heroicons-outline:table class="h-4 w-4 mr-1" /><span class="font-semibold">{{ tableInfo.name }}</span></div>- <div- class="table-schema--header-actions flex-1 flex justify-end space-x-2"- >+ <div class="table-schema--header-actions flex-1 flex justify-end space-x-2"><div class="action-edit flex items-center"><NTooltip trigger="hover"><template #trigger>@@ -15,7 +13,7 @@<heroicons-outline:pencil-alt class="w-4 h-4" /></NButton></template>- {{ $t("quick-action.alter-schema") }}+ {{ $t("database.alter-schema") }}</NTooltip></div><div class="action-close flex items-center">@@ -58,9 +56,10 @@</div></div></div>- <div v-else class="h-full flex justify-center items-center">- {{ $t("sql-editor.table-schema-placeholder") }}- </div>+ <div+ v-else+ class="h-full flex justify-center items-center"+ >{{ $t("sql-editor.table-schema-placeholder") }}</div></template><script lang="ts" setup>diff --git a/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vue b/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vueindex 40dc0224c7..06e4ab18c4 100644--- a/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vue+++ b/frontend/src/views/SqlEditor/EditorPanel/ExecuteHint.vue@@ -12,16 +12,18 @@<p><i18n-t keypath="sql-editor.want-to-change-schema"><template #changeschema>- <NButton text :href="docLink" type="primary" target="_blank">{{+ <NButton text :href="docLink" type="primary" target="_blank">+ {{$t("sql-editor.change-schema")- }}</NButton>+ }}+ </NButton></template></i18n-t></p><p><i18n-t keypath="sql-editor.go-to-alter-schema"><template #alterschema>- <strong>{{ $t("quick-action.alter-schema") }}</strong>+ <strong>{{ $t("database.alter-schema") }}</strong></template></i18n-t></p>@@ -30,9 +32,11 @@<div class="execute-hint-content mt-4 flex justify-end space-x-2"><NButton @click="handleColse">{{ $t("common.close") }}</NButton>- <NButton type="primary" @click="gotoAlterSchema">{{- $t("quick-action.alter-schema")- }}</NButton>+ <NButton type="primary" @click="gotoAlterSchema">+ {{+ $t("database.alter-schema")+ }}+ </NButton></div></div></template>