Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Create dedicate migration history tab for database detail
天舟07233596d4a4
diff --git a/frontend/src/components/DatabaseMigrationHistoryPanel.vue b/frontend/src/components/DatabaseMigrationHistoryPanel.vuenew file mode 100644index 0000000000..5dd53f6cd0--- /dev/null+++ b/frontend/src/components/DatabaseMigrationHistoryPanel.vue@@ -0,0 +1,114 @@+<template>+ <div class="flex flex-col space-y-4">+ <div class="text-lg leading-6 font-medium text-main">Migration History</div>+ <MigrationHistoryTable+ v-if="state.migrationSetupStatus == 'OK'"+ :databaseSectionList="[database]"+ :historySectionList="migrationHistorySectionList"+ />+ <BBAttention+ v-else+ :title="attentionTitle"+ :actionText="allowConfigInstance ? 'Config instance' : ''"+ @click-action="configInstance"+ />+ </div>+</template>++<script lang="ts">+import { computed, PropType, reactive, watchEffect } from "@vue/runtime-core";+import { useStore } from "vuex";+import MigrationHistoryTable from "../components/MigrationHistoryTable.vue";+import {+ Database,+ InstanceMigration,+ MigrationHistory,+ MigrationSchemaStatus,+} from "../types";+import { useRouter } from "vue-router";+import { BBTableSectionDataSource } from "../bbkit/types";+import { instanceSlug, isDBAOrOwner } from "../utils";++interface LocalState {+ migrationSetupStatus: MigrationSchemaStatus;+}++export default {+ name: "DatabaseMigrationHistoryPanel",+ components: { MigrationHistoryTable },+ props: {+ database: {+ required: true,+ type: Object as PropType<Database>,+ },+ },+ setup(props, ctx) {+ const store = useStore();+ const router = useRouter();++ const state = reactive<LocalState>({+ migrationSetupStatus: "OK",+ });++ const currentUser = computed(() => store.getters["auth/currentUser"]());++ const prepareMigrationHistoryList = () => {+ store+ .dispatch("instance/checkMigrationSetup", props.database.instance.id)+ .then((migration: InstanceMigration) => {+ state.migrationSetupStatus = migration.status;+ if (state.migrationSetupStatus == "OK") {+ store.dispatch("instance/fetchMigrationHistory", {+ instanceId: props.database.instance.id,+ databaseName: props.database.name,+ });+ }+ });+ };++ watchEffect(prepareMigrationHistoryList);++ const isCurrentUserDBAOrOwner = computed((): boolean => {+ return isDBAOrOwner(currentUser.value.role);+ });++ const allowConfigInstance = computed(() => {+ return isCurrentUserDBAOrOwner.value;+ });++ const attentionTitle = computed((): string => {+ if (state.migrationSetupStatus == "NOT_EXIST") {+ return `Missing migration history schema on instance "${props.database.instance.name}"`;+ } else if (state.migrationSetupStatus == "UNKNOWN") {+ return `Unable to connect instance "${props.database.instance.name}" to retrieve migration history`;+ }+ return "";+ });++ const migrationHistorySectionList = computed(+ (): BBTableSectionDataSource<MigrationHistory>[] => {+ return [+ {+ title: "",+ list: store.getters[+ "instance/migrationHistoryListByInstanceIdAndDatabaseName"+ ](props.database.instance.id, props.database.name),+ },+ ];+ }+ );++ const configInstance = () => {+ router.push(`/instance/${instanceSlug(props.database.instance)}`);+ };++ return {+ state,+ allowConfigInstance,+ attentionTitle,+ migrationHistorySectionList,+ configInstance,+ };+ },+};+</script>diff --git a/frontend/src/components/DatabaseOverviewPanel.vue b/frontend/src/components/DatabaseOverviewPanel.vueindex 5e44d6f533..25a3d2b784 100644--- a/frontend/src/components/DatabaseOverviewPanel.vue+++ b/frontend/src/components/DatabaseOverviewPanel.vue@@ -59,20 +59,6 @@:mode="'VIEW'":tableList="tableList.filter((item) => item.type == 'VIEW')"/>- <div class="mt-6 text-lg leading-6 font-medium text-main mb-4">- Migration History- </div>- <MigrationHistoryTable- v-if="state.migrationSetupStatus == 'OK'"- :databaseSectionList="[database]"- :historySectionList="migrationHistorySectionList"- />- <BBAttention- v-else- :title="attentionTitle"- :actionText="allowConfigInstance ? 'Config instance' : ''"- @click-action="configInstance"- /></div><!-- Hide data source list for now, as we don't allow adding new data source after creating the database. -->@@ -187,22 +173,12 @@ import { useRouter } from "vue-router";import DataSourceTable from "../components/DataSourceTable.vue";import DataSourceConnectionPanel from "../components/DataSourceConnectionPanel.vue";import TableTable from "../components/TableTable.vue";-import MigrationHistoryTable from "../components/MigrationHistoryTable.vue";import { timezoneString, instanceSlug, isDBAOrOwner } from "../utils";-import {- Database,- DataSource,- DataSourcePatch,- MigrationSchemaStatus,- InstanceMigration,- MigrationHistory,-} from "../types";-import { cloneDeep, isEmpty, isEqual } from "lodash";-import { BBTableSectionDataSource } from "../bbkit/types";+import { Database, DataSource, DataSourcePatch } from "../types";+import { cloneDeep, isEqual } from "lodash";interface LocalState {editingDataSource?: DataSource;- migrationSetupStatus: MigrationSchemaStatus;}export default {@@ -217,15 +193,12 @@ export default {DataSourceConnectionPanel,DataSourceTable,TableTable,- MigrationHistoryTable,},setup(props, ctx) {const store = useStore();const router = useRouter();- const state = reactive<LocalState>({- migrationSetupStatus: "OK",- });+ const state = reactive<LocalState>({});const currentUser = computed(() => store.getters["auth/currentUser"]());@@ -235,22 +208,6 @@ export default {watchEffect(prepareTableList);- const prepareMigrationHistoryList = () => {- store- .dispatch("instance/checkMigrationSetup", props.database.instance.id)- .then((migration: InstanceMigration) => {- state.migrationSetupStatus = migration.status;- if (state.migrationSetupStatus == "OK") {- store.dispatch("instance/fetchMigrationHistory", {- instanceId: props.database.instance.id,- databaseName: props.database.name,- });- }- });- };-- watchEffect(prepareMigrationHistoryList);-const hasDataSourceFeature = computed(() =>store.getters["plan/feature"]("bb.data-source"));@@ -259,28 +216,6 @@ export default {return store.getters["table/tableListByDatabaseId"](props.database.id);});- const attentionTitle = computed((): string => {- if (state.migrationSetupStatus == "NOT_EXIST") {- return `Missing migration history schema on instance "${props.database.instance.name}"`;- } else if (state.migrationSetupStatus == "UNKNOWN") {- return `Unable to connect instance "${props.database.instance.name}" to retrieve migration history`;- }- return "";- });-- const migrationHistorySectionList = computed(- (): BBTableSectionDataSource<MigrationHistory>[] => {- return [- {- title: "",- list: store.getters[- "instance/migrationHistoryListByInstanceIdAndDatabaseName"- ](props.database.instance.id, props.database.name),- },- ];- }- );-const isCurrentUserDBAOrOwner = computed((): boolean => {return isDBAOrOwner(currentUser.value.role);});@@ -370,8 +305,6 @@ export default {timezoneString,state,tableList,- attentionTitle,- migrationHistorySectionList,hasDataSourceFeature,allowConfigInstance,allowViewDataSource,diff --git a/frontend/src/components/ProjectMigrationHistoryPanel.vue b/frontend/src/components/ProjectMigrationHistoryPanel.vueindex 7a14f3d5a2..8de281af0b 100644--- a/frontend/src/components/ProjectMigrationHistoryPanel.vue+++ b/frontend/src/components/ProjectMigrationHistoryPanel.vue@@ -111,7 +111,7 @@ export default {);const newItem = {title: title,- link: fullDatabasePath(database),+ link: `${fullDatabasePath(database)}#migration-history`,list: migrationHistoryList,};if (index >= 0) {diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex efeaac09c7..974b842de0 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -208,7 +208,10 @@/><div class="py-6 px-6"><template v-if="state.selectedIndex == OVERVIEW_TAB">- <DatabaseOverviewPanel id="overview" :database="database" />+ <DatabaseOverviewPanel :database="database" />+ </template>+ <template v-if="state.selectedIndex == MIGRAITON_HISTORY_TAB">+ <DatabaseMigrationHistoryPanel :database="database" /></template><template v-if="state.selectedIndex == BACKUP_TAB"><DatabaseBackupPanel@@ -228,8 +231,9 @@ import { useRouter } from "vue-router";import MemberSelect from "../components/MemberSelect.vue";import ProjectSelect from "../components/ProjectSelect.vue";import DatabaseBackupPanel from "../components/DatabaseBackupPanel.vue";+import DatabaseMigrationHistoryPanel from "../components/DatabaseMigrationHistoryPanel.vue";import DatabaseOverviewPanel from "../components/DatabaseOverviewPanel.vue";-import { consoleLink, idFromSlug, instanceSlug, isDBAOrOwner } from "../utils";+import { consoleLink, idFromSlug, isDBAOrOwner } from "../utils";import {ProjectId,UNKNOWN_ID,@@ -240,7 +244,8 @@ import {import { isEmpty } from "lodash";const OVERVIEW_TAB = 0;-const BACKUP_TAB = 1;+const MIGRAITON_HISTORY_TAB = 1;+const BACKUP_TAB = 2;type DatabaseTabItem = {name: string;@@ -249,6 +254,7 @@ type DatabaseTabItem = {const databaseTabItemList: DatabaseTabItem[] = [{ name: "Overview", hash: "overview" },+ { name: "Migration History", hash: "migration-history" },{ name: "Backups", hash: "backup" },];@@ -270,6 +276,7 @@ export default {MemberSelect,ProjectSelect,DatabaseOverviewPanel,+ DatabaseMigrationHistoryPanel,DatabaseBackupPanel,},setup(props, ctx) {@@ -463,6 +470,7 @@ export default {return {OVERVIEW_TAB,+ MIGRAITON_HISTORY_TAB,BACKUP_TAB,state,database,