Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: remove sheet payload type issueId issueName (#7808)
p0ny782d14cbc9c0
diff --git a/backend/migrator/migration/prod/2.7/0002##remove_sheet_used_by_issues.sql b/backend/migrator/migration/prod/2.7/0002##remove_sheet_used_by_issues.sqlnew file mode 100644index 0000000000..1785bb7e03--- /dev/null+++ b/backend/migrator/migration/prod/2.7/0002##remove_sheet_used_by_issues.sql@@ -0,0 +1,6 @@+ALTER TABLE sheet DISABLE TRIGGER update_sheet_updated_ts;++UPDATE sheet+SET payload = payload - 'type' - 'issueId' - 'issueName';++ALTER TABLE sheet ENABLE TRIGGER update_sheet_updated_ts;diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 1282149f21..f713f9bea4 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -241,5 +241,5 @@ func TestMigrationCompatibility(t *testing.T) {func TestGetCutoffVersion(t *testing.T) {releaseVersion, err := getProdCutoffVersion()require.NoError(t, err)- require.Equal(t, semver.MustParse("2.7.1"), releaseVersion)+ require.Equal(t, semver.MustParse("2.7.2"), releaseVersion)}diff --git a/frontend/src/components/Issue/IssueTaskStatementPanel.vue b/frontend/src/components/Issue/IssueTaskStatementPanel.vueindex ad963f8762..57b4db04b6 100644--- a/frontend/src/components/Issue/IssueTaskStatementPanel.vue+++ b/frontend/src/components/Issue/IssueTaskStatementPanel.vue@@ -162,7 +162,6 @@ import {} from "@/types/proto/v1/sheet_service";import {extractSheetUID,- getBacktracePayloadWithIssue,sheetNameOfTask,useInstanceV1EditorLanguage,} from "@/utils";@@ -510,10 +509,6 @@ const handleUploadAndOverwrite = async (event: Event) => {100);const projectName = selectedDatabase.value.project;- let payload = {};- if (!create.value) {- payload = getBacktracePayloadWithIssue(issue.value as Issue);- }// TODO: upload processconst sheet = await sheetV1Store.createSheet(projectName, {title: filename,@@ -521,7 +516,6 @@ const handleUploadAndOverwrite = async (event: Event) => {visibility: Sheet_Visibility.VISIBILITY_PROJECT,source: Sheet_Source.SOURCE_BYTEBASE_ARTIFACT,type: Sheet_Type.TYPE_SQL,- payload: JSON.stringify(payload),});resetTempEditState();diff --git a/frontend/src/components/Issue/logic/TenantModeProvider.ts b/frontend/src/components/Issue/logic/TenantModeProvider.tsindex e3d57e20d9..80185f83ae 100644--- a/frontend/src/components/Issue/logic/TenantModeProvider.ts+++ b/frontend/src/components/Issue/logic/TenantModeProvider.ts@@ -29,7 +29,6 @@ import {import {extractSheetUID,extractUserUID,- getBacktracePayloadWithIssue,hasWorkspacePermissionV1,sheetIdOfTask,} from "@/utils";@@ -136,9 +135,6 @@ export default defineComponent({visibility: Sheet_Visibility.VISIBILITY_PROJECT,source: Sheet_Source.SOURCE_BYTEBASE_ARTIFACT,type: Sheet_Type.TYPE_SQL,- payload: JSON.stringify(- getBacktracePayloadWithIssue(issue.value as Issue)- ),});updateSheetId(Number(extractSheetUID(sheet.name)));diff --git a/frontend/src/components/Issue/logic/base.ts b/frontend/src/components/Issue/logic/base.tsindex c78740182b..64044a96c3 100644--- a/frontend/src/components/Issue/logic/base.ts+++ b/frontend/src/components/Issue/logic/base.ts@@ -34,7 +34,6 @@ import {idFromSlug,indexFromSlug,issueSlug,- maybeSetSheetBacktracePayloadByIssue,sheetIdOfTask,stageSlug,taskSlug,@@ -70,7 +69,6 @@ export const useBaseIssueLogic = (params: {const createdIssue = await issueStore.createIssue(issue);await maybeCreateBackTraceComments(createdIssue);- await maybeSetSheetBacktracePayloadByIssue(createdIssue);// Use replace to omit the new issue url in the navigation history.router.replace(`/issue/${issueSlug(createdIssue.name, createdIssue.id)}`);diff --git a/frontend/src/components/Issue/logic/common.ts b/frontend/src/components/Issue/logic/common.tsindex 55cf5f13bb..64aa2b2b73 100644--- a/frontend/src/components/Issue/logic/common.ts+++ b/frontend/src/components/Issue/logic/common.ts@@ -42,7 +42,6 @@ import {defer,extractSheetUID,extractUserUID,- getBacktracePayloadWithIssue,hasWorkspacePermissionV1,isDev,isTaskTriggeredByVCS,@@ -244,9 +243,6 @@ export const useCommonLogic = () => {visibility: Sheet_Visibility.VISIBILITY_PROJECT,source: Sheet_Source.SOURCE_BYTEBASE_ARTIFACT,type: Sheet_Type.TYPE_SQL,- payload: JSON.stringify(- getBacktracePayloadWithIssue(issue.value as Issue)- ),});const patchRequestList = patchingTaskList.map((task) => {diff --git a/frontend/src/types/sheet.ts b/frontend/src/types/sheet.tsindex d5dd07e199..de759a0b4c 100644--- a/frontend/src/types/sheet.ts+++ b/frontend/src/types/sheet.ts@@ -1,5 +1,4 @@import { Sheet_Visibility } from "@/types/proto/v1/sheet_service";-import { IssueId } from ".";interface SheetVCSPayload {fileName: string;@@ -10,23 +9,10 @@ interface SheetVCSPayload {lastSyncTs: number;}-/**- * Mark a link from sheets to issues if a sheet is created in an issue via- * "Upload SQL"- */-export type SheetIssueBacktracePayload = {- type: "bb.sheet.issue-backtrace";- issueId: IssueId;- issueName: string;-};-// eslint-disable-next-line @typescript-eslint/ban-typestype SheetEmptyPayload = {};-export type SheetPayload =- | SheetVCSPayload- | SheetIssueBacktracePayload- | SheetEmptyPayload;+export type SheetPayload = SheetVCSPayload | SheetEmptyPayload;export type AccessOption = {label: string;diff --git a/frontend/src/utils/sheet.ts b/frontend/src/utils/sheet.tsindex f77119b702..428caff20c 100644--- a/frontend/src/utils/sheet.ts+++ b/frontend/src/utils/sheet.ts@@ -1,18 +1,10 @@-import { uniq } from "lodash-es";-import { flattenTaskList } from "@/components/Issue/logic";-import { useSheetV1Store } from "@/store";-import { getSheetPathByLegacyProject } from "@/store/modules/v1/common";import {- Issue,- SheetId,- SheetIssueBacktracePayload,Task,TaskDatabaseCreatePayload,TaskDatabaseDataUpdatePayload,TaskDatabaseSchemaUpdateGhostSyncPayload,TaskDatabaseSchemaUpdatePayload,TaskDatabaseSchemaUpdateSDLPayload,- UNKNOWN_ID,} from "@/types";export const sheetIdOfTask = (task: Task) => {@@ -46,48 +38,3 @@ export const sheetIdOfTask = (task: Task) => {return undefined;}};--/**- * If the created issue contains SQL files uploaded as sheets- * we should patch the sheets' payloads with issueID and taskID- * to make a sheet backtrace-able to the issue/task it belongs to.- * Then we can display the backtrace issue link in the sheet list.- */-export const maybeSetSheetBacktracePayloadByIssue = async (issue: Issue) => {- const sheetIdList: SheetId[] = [];-- flattenTaskList(issue).forEach((task) => {- const sheetId = sheetIdOfTask(task as Task);- if (sheetId && sheetId !== UNKNOWN_ID) {- sheetIdList.push(sheetId);- }- });-- const sheetV1Store = useSheetV1Store();- const requests = uniq(sheetIdList).map((sheetId) => {- const payload: SheetIssueBacktracePayload = {- type: "bb.sheet.issue-backtrace",- issueId: issue.id,- issueName: issue.name,- };-- return sheetV1Store.patchSheet({- name: getSheetPathByLegacyProject(issue.project, sheetId),- payload: JSON.stringify(payload),- });- });-- try {- await Promise.all(requests);- } catch {- // nothing- }-};--export const getBacktracePayloadWithIssue = (issue: Issue) => {- return {- type: "bb.sheet.issue-backtrace",- issueId: issue.id,- issueName: issue.name,- };-};diff --git a/frontend/src/utils/v1/sheet.ts b/frontend/src/utils/v1/sheet.tsindex ce6fb89891..6b9a917cae 100644--- a/frontend/src/utils/v1/sheet.ts+++ b/frontend/src/utils/v1/sheet.ts@@ -1,4 +1,3 @@-import { isUndefined } from "lodash-es";import { useCurrentUserV1, useProjectV1Store } from "@/store";import {getUserEmailFromIdentifier,@@ -7,7 +6,6 @@ import {} from "@/store/modules/v1/common";import {Task,- SheetIssueBacktracePayload,TaskDatabaseCreatePayload,TaskDatabaseDataUpdatePayload,TaskDatabaseSchemaUpdateGhostSyncPayload,@@ -66,11 +64,6 @@ export const isSheetReadableV1 = (sheet: Sheet) => {};export const isSheetWritableV1 = (sheet: Sheet) => {- // If the sheet is linked to an issue, it's NOT writable- if (getSheetIssueBacktracePayloadV1(sheet)) {- return false;- }-const currentUserV1 = useCurrentUserV1();// writable to@@ -113,21 +106,6 @@ export const isSheetWritableV1 = (sheet: Sheet) => {return false;};-export const getSheetIssueBacktracePayloadV1 = (sheet: Sheet) => {- const maybePayload = JSON.parse(- sheet.payload ?? "{}"- ) as SheetIssueBacktracePayload;- if (- maybePayload.type === "bb.sheet.issue-backtrace" &&- !isUndefined(maybePayload.issueId) &&- !isUndefined(maybePayload.issueName)- ) {- return maybePayload;- }-- return undefined;-};-export const sheetNameOfTask = (task: Task) => {const project = task.database?.project;if (!project) {diff --git a/frontend/src/views/SheetDashboard.vue b/frontend/src/views/SheetDashboard.vueindex bda1a69249..1305b1f0ee 100644--- a/frontend/src/views/SheetDashboard.vue+++ b/frontend/src/views/SheetDashboard.vue@@ -97,7 +97,6 @@ import {} from "@/store";import { Workflow } from "@/types/proto/v1/project_service";import { Sheet } from "@/types/proto/v1/sheet_service";-import { getSheetIssueBacktracePayloadV1 } from "@/utils";import {type SheetViewMode,SheetTable,@@ -220,10 +219,7 @@ const fetchSheetData = async () => {sheetList = await sheetV1Store.fetchSharedSheetList();}- // Hide those sheets from issue.- state.sheetList = sheetList.filter((sheet) => {- return !getSheetIssueBacktracePayloadV1(sheet);- });+ state.sheetList = sheetList;};onMounted(async () => {diff --git a/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vue b/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vueindex a3df225ea5..6cf506f16a 100644--- a/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vue+++ b/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vue@@ -1,38 +1,13 @@<template><div- v-if="payload || isSheetOversize"+ v-if="isSheetOversize"class="w-full p-4 flex items-center bg-yellow-50 gap-x-3"><div class="flex-shrink-0"><heroicons-solid:information-circle class="h-5 w-5 text-yellow-400" /></div><div class="flex-1 text-sm font-medium text-yellow-800">- <i18n-t v-if="payload" tag="h3" keypath="sheet.from-issue-warning">- <template #issue>- <NTooltip :disabled="loading || !issue">- <template #trigger>- <a- v-if="issue"- class="normal-link"- href="`/issue/${issueSlug(issue.name, issue.id)}`"- >- #{{ payload.issueId }}- </a>- <span v-else>#{{ payload.issueId }}</span>- </template>-- <div class="max-w-[20rem]">- {{ issue?.name }}- </div>- </NTooltip>- </template>- <template v-if="isSheetOversize" #oversize>- {{ $t("sheet.content-oversize-warning") }}- </template>- </i18n-t>- <div v-else-if="isSheetOversize">- {{ $t("sheet.content-oversize-warning") }}- </div>+ {{ $t("sheet.content-oversize-warning") }}</div><DownloadSheetButtonv-if="tab.sheetName"@@ -43,19 +18,13 @@</template><script lang="ts" setup>-import { NTooltip } from "naive-ui";-import { shallowRef, computed, ref, watch } from "vue";+import { computed } from "vue";import DownloadSheetButton from "@/components/Sheet/DownloadSheetButton.vue";-import { useIssueStore, useSheetV1Store, useTabStore } from "@/store";-import { Issue } from "@/types";-import { getSheetIssueBacktracePayloadV1 } from "@/utils";+import { useSheetV1Store, useTabStore } from "@/store";const tabStore = useTabStore();const sheetV1Store = useSheetV1Store();-const issueStore = useIssueStore();const tab = computed(() => tabStore.currentTab);-const loading = ref(true);-const issue = shallowRef<Issue>();const sheet = computed(() => {const { sheetName } = tab.value;@@ -63,33 +32,6 @@ const sheet = computed(() => {return sheetV1Store.getSheetByName(sheetName);});-const payload = computed(() => {- if (!sheet.value) return undefined;- return getSheetIssueBacktracePayloadV1(sheet.value);-});--watch(- payload,- (payload) => {- loading.value = true;- const finish = (_issue: Issue | undefined) => {- loading.value = false;- issue.value = _issue;- };-- if (!payload) {- return finish(undefined);- }- const { issueId } = payload;- issueStore.getOrFetchIssueById(issueId).then((_issue) => {- if (_issue.id === issueId) {- return finish(_issue);- }- });- },- { immediate: true }-);-const isSheetOversize = computed(() => {if (!sheet.value) {return false;