Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Repurpose the backup comment field to record the error message if backup fails
天舟871d7a07445e
diff --git a/api/backup.go b/api/backup.goindex df7d1d5ffb..371dc90a6e 100644--- a/api/backup.go+++ b/api/backup.go@@ -106,7 +106,6 @@ type BackupCreate struct {StorageBackend BackupStorageBackend `jsonapi:"attr,storageBackend"`MigrationHistoryVersion string `jsonapi:"attr,migrationHistoryVersion"`Path string `jsonapi:"attr,path"`- Comment string `jsonapi:"attr,comment"`}type BackupFind struct {@@ -135,7 +134,8 @@ type BackupPatch struct {UpdaterId int// Domain specific fields- Status string+ Status string+ Comment string}// BackupSetting is the backup setting for a database.diff --git a/frontend/src/components/DatabaseBackupCreateForm.vue b/frontend/src/components/DatabaseBackupCreateForm.vueindex bd7a4307e5..f178e3ddb8 100644--- a/frontend/src/components/DatabaseBackupCreateForm.vue+++ b/frontend/src/components/DatabaseBackupCreateForm.vue@@ -1,7 +1,7 @@<template><formclass="space-y-6 divide-y divide-block-border"- @submit.prevent="$emit('create', state.backupName, state.comment)"+ @submit.prevent="$emit('create', state.backupName)"><div class="space-y-4"><div class="grid grid-cols-3 gap-y-6 gap-x-4">@@ -19,38 +19,6 @@/></div></div>-- <div class="sm:col-span-4 w-112 min-w-full">- <label for="comment" class="textlabel"> Comment </label>- <div class="mt-1">- <textarea- ref="commentTextArea"- rows="3"- class="- textarea- block- w-full- resize-none- mt-1- text-sm text-control- rounded-md- whitespace-pre-wrap- "- placeholder="(Optional) Add a note..."- v-model="state.comment"- @input="- (e) => {- sizeToFit(e.target);- }- "- @focus="- (e) => {- sizeToFit(e.target);- }- "- ></textarea>- </div>- </div></div><!-- Create button group --><div class="pt-4 flex justify-end">@@ -73,7 +41,7 @@</template><script lang="ts">-import { computed, PropType, reactive, ref } from "vue";+import { computed, PropType, reactive } from "vue";import { Database } from "../types";import { isEmpty } from "lodash";import moment from "moment";@@ -81,7 +49,6 @@ import slug from "slug";interface LocalState {backupName: string;- comment: string;}export default {@@ -95,14 +62,11 @@ export default {},components: {},setup(props, ctx) {- const commentTextArea = ref("");-const state = reactive<LocalState>({// The default format is consistent with the default automatic backup name format used in the server.backupName: `${slug(props.database.project.name)}-${slug(props.database.instance.environment.name)}-${moment.utc().local().format("YYYYMMDDTHHmmss")}`,- comment: "",});const allowCreate = computed(() => {@@ -110,7 +74,6 @@ export default {});return {- commentTextArea,state,allowCreate,};diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vueindex 551b9df834..e6b66d7e6e 100644--- a/frontend/src/components/DatabaseBackupPanel.vue+++ b/frontend/src/components/DatabaseBackupPanel.vue@@ -60,8 +60,8 @@<DatabaseBackupCreateForm:database="database"@create="- (backupName, comment) => {- createBackup(backupName, comment);+ (backupName) => {+ createBackup(backupName);state.showCreateBackupModal = false;}"@@ -204,7 +204,7 @@ export default {})`;});- const createBackup = (backupName: string, comment: string) => {+ const createBackup = (backupName: string) => {// Create backupconst newBackup: BackupCreate = {databaseId: props.database.id!,@@ -212,7 +212,6 @@ export default {status: "PENDING_CREATE",type: "MANUAL",storageBackend: "LOCAL",- comment,};store.dispatch("backup/createBackup", {databaseId: props.database.id,diff --git a/frontend/src/types/backup.ts b/frontend/src/types/backup.tsindex 25610ef7c4..d275436272 100644--- a/frontend/src/types/backup.ts+++ b/frontend/src/types/backup.ts@@ -37,7 +37,6 @@ export type BackupCreate = {status: BackupStatus;type: BackupType;storageBackend: BackupStorageBackend;- comment: string;};// Backup setting.diff --git a/server/task_executor_database_backup.go b/server/task_executor_database_backup.goindex d850f789c7..46d5c3cb0c 100644--- a/server/task_executor_database_backup.go+++ b/server/task_executor_database_backup.go@@ -62,13 +62,16 @@ func (exec *DatabaseBackupTaskExecutor) RunOnce(ctx context.Context, server *SerbackupErr := backupDatabase(task.Instance, task.Database, backup, server.dataDir)// Update the status of the backup.newBackupStatus := string(api.BackupStatusDone)+ comment := ""if backupErr != nil {newBackupStatus = string(api.BackupStatusFailed)+ comment = backupErr.Error()}if _, err = server.BackupService.PatchBackup(ctx, &api.BackupPatch{ID: backup.ID,Status: newBackupStatus,UpdaterId: api.SYSTEM_BOT_ID,+ Comment: comment,}); err != nil {return true, "", fmt.Errorf("failed to patch backup: %w", err)}diff --git a/store/backup.go b/store/backup.goindex c52e5a3326..ecba249080 100644--- a/store/backup.go+++ b/store/backup.go@@ -117,10 +117,9 @@ func (s *BackupService) createBackup(ctx context.Context, tx *Tx, create *api.Ba`+"`type`,"+`storage_backend,migration_history_version,- path,- comment+ path)- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, name, `+"`status`,"+` `+"`type`, storage_backend, migration_history_version, path, comment"+``,create.CreatorId,@@ -132,7 +131,6 @@ func (s *BackupService) createBackup(ctx context.Context, tx *Tx, create *api.Bacreate.StorageBackend,create.MigrationHistoryVersion,create.Path,- create.Comment,)if err != nil {@@ -236,6 +234,7 @@ func (s *BackupService) patchBackup(ctx context.Context, tx *Tx, patch *api.Back// Build UPDATE clause.set, args := []string{"updater_id = ?"}, []interface{}{patch.UpdaterId}set, args = append(set, "status = ?"), append(args, patch.Status)+ set, args = append(set, "comment = ?"), append(args, patch.Comment)args = append(args, patch.ID)