From 71bed995b25e7f9e1a47d376ab551a7feb0ec8ac Mon Sep 17 00:00:00 2001 From: necessarylion Date: Sun, 8 Nov 2026 09:57:35 +0700 Subject: [PATCH] Make the custom format the default for PostgreSQL backups The backup dialog started on plain SQL. A custom .dump file is smaller and pg_restore loads it much faster. The dialog now starts on custom each time it opens. Plain SQL can still be picked. --- CLAUDE.md | 2 +- src/components/PgToolDialog.vue | 10 +++++++++- src/constants/pgTools.ts | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index a2cb7a0..e84de13 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -109,7 +109,7 @@ Constants are in `constants/mod.rs`. Errors are `AppError` (`error.rs`), which r The PostgreSQL dialog always lists versions 18 to 12 (`PG_TOOL_VERSIONS`). The app never installs a tool: a missing version shows an install guide for the platform (`PgInstallGuide`). `open_link` opens only the guide links (`GUIDE_LINKS`). - PostgreSQL only (`PgToolDialog.vue`): the user picks plain SQL or custom format (`--format=custom`, a - `.dump` file) and the pg_dump version. `DumpRepository::pg_tools` lists the installed versions + `.dump` file, the default each time the dialog opens) and the pg_dump version. `DumpRepository::pg_tools` lists the installed versions (`--version`). The default is the server version (`SHOW server_version_num`), else the newest. - `restore_dump` loads a `.dump` file with `pg_restore --no-owner --no-privileges` into the current database, optionally with `--clean --if-exists`. It uses the same progress, cancel map and `DumpLog`. diff --git a/src/components/PgToolDialog.vue b/src/components/PgToolDialog.vue index fc53e90..206446a 100644 --- a/src/components/PgToolDialog.vue +++ b/src/components/PgToolDialog.vue @@ -4,6 +4,7 @@ import { confirm, save } from '@tauri-apps/plugin-dialog' import { PG_INSTALL_GUIDE, injectRequired } from '../services/keys' import type { GuideLink, GuideStep } from '../services/PgInstallGuide' import { PgToolLoader, type PgToolChoice } from '../services/PgToolChoice' +import { PG_BACKUP_CUSTOM_DEFAULT } from '../constants/pgTools' import type { Session } from '../services/Session' // The PostgreSQL backup and restore dialog: the format of a backup, the pg_dump or @@ -12,7 +13,13 @@ import type { Session } from '../services/Session' const props = defineProps<{ session: Session }>() const guide = injectRequired(PG_INSTALL_GUIDE) const dialog = useTemplateRef('dialog') -const form = reactive({ restoring: false, path: '', custom: false, clean: false, problem: '' }) +const form = reactive({ + restoring: false, + path: '', + custom: PG_BACKUP_CUSTOM_DEFAULT, + clean: false, + problem: '', +}) const choice = ref(null) const loader = new PgToolLoader() const checking = ref(false) @@ -29,6 +36,7 @@ function openRestore(path: string): Promise { async function show(restoring: boolean, path: string): Promise { form.restoring = restoring form.path = path + form.custom = PG_BACKUP_CUSTOM_DEFAULT form.clean = false choice.value = null dialog.value?.showModal() diff --git a/src/constants/pgTools.ts b/src/constants/pgTools.ts index 8a577d4..d84e2e7 100644 --- a/src/constants/pgTools.ts +++ b/src/constants/pgTools.ts @@ -24,3 +24,6 @@ export const PG_WINDOWS_DOWNLOAD_URL = 'https://www.postgresql.org/download/wind /** `navigator.platform` of Windows matches this. */ export const WINDOWS_PLATFORM_PATTERN = /win/i + +/** The backup dialog starts on the custom format (.dump). It is smaller and pg_restore loads it faster. */ +export const PG_BACKUP_CUSTOM_DEFAULT = true