Skip to content

feat: add squix export backup/schema subcommands via native pg_dump - #82

Open
DeprecatedLuar wants to merge 2 commits into
eduardofuncao:mainfrom
DeprecatedLuar:export-backup-schema
Open

DeprecatedLuar wants to merge 2 commits into
eduardofuncao:mainfrom
DeprecatedLuar:export-backup-schema

Conversation

@DeprecatedLuar

@DeprecatedLuar DeprecatedLuar commented Jul 23, 2026 •

Copy link
Copy Markdown

Basically added this:

  • squix export backup: it wraps the native db cli tool to produce exports for backup (currently Postgres only, via pg_dump since I do not use other database types)
  • squix export schema: a schema-only (DDL) export, with optional --table <name> to dump specific tables.
  • I made so that the format is inferred from file extension or set explicitly with --format (custom/plain/tar); backup defaults to custom, schema defaults to plain.
  • --table is only for export schema; it just fails on anything else.
  • Other db engines (besides Postgres) will error with "not implemented" so that is obvious enough.

About the decision:

Using the native dumps preserves with max fidelity (types, indexes, constraints). Using generic row export would get exponentially more complex for engine specific implementation, and schema-only exports are useful for sharing/diffing structure without data.

Test plan

  • Unit tests for ResolveFormat/ResolvePath/pgDumpArgs in internal/backup/backup_test.go
  • Integration tests in test/integration/export_test.go covering usage errors, unsupported-engine errors, and --table misuse
  • Manually verified end-to-end against a live Postgres container: default/subdir/plain backup exports, schema-only exports with --table, pg_restore --list sanity check, and format-conflict / missing-engine / missing-binary error paths

Add internal/backup/ (Dumper interface, ResolveFormat/ResolvePath helpers,
factory, postgresDumper wrapping pg_dump) and wire `squix export [path]
--backup [--format <fmt>]` into cmd/squix/export.go, app.go, help.go, and
completion.go. Postgres-only this phase; other engines error clearly.
Verified end-to-end against a live Postgres container (default/subdir/plain
exports, pg_restore --list, format-conflict and missing-engine/missing-binary
error paths) plus unit tests for ResolveFormat/ResolvePath.
Restructures `squix export` into `backup` and `schema` subcommands
(replacing the old `--backup` flag), and adds pg_dump --schema-only
support with optional -t/--table narrowing for schema-only dumps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant