Skip to content

fix: postgres-provider - #88

Merged
RambokDev merged 15 commits into
mainfrom
fix/postgres-provider
Jul 23, 2026
Merged

fix: postgres-provider#88
RambokDev merged 15 commits into
mainfrom
fix/postgres-provider

Conversation

@RambokDev

@RambokDev RambokDev commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Improved PostgreSQL restore support for custom and directory-format backups.
    • Added automatic archive format detection and validation before restoring.
    • Added configurable cleanup modes, including schema cleanup, database recreation, and standard clean restores.
    • Improved handling of ownership, privileges, active connections, schemas, and public schema recreation.
    • Added clearer restore progress and failure reporting.
  • Bug Fixes

    • Prevented destructive restore actions for invalid or corrupt archives.
    • Improved compatibility across PostgreSQL server versions and privilege levels.
  • Tests

    • Expanded coverage for restore workflows, cleanup modes, archive formats, permissions, and SQL safety.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c626032-54c9-4649-a5f6-3ef6e18bed44

📥 Commits

Reviewing files that changed from the base of the PR and between baf2edc and 9790837.

📒 Files selected for processing (13)
  • docker-compose.yml
  • src/domain/postgres/clean_mode.rs
  • src/domain/postgres/cluster/restore.rs
  • src/domain/postgres/connection.rs
  • src/domain/postgres/format.rs
  • src/domain/postgres/mod.rs
  • src/domain/postgres/restore.rs
  • src/domain/postgres/restore/command.rs
  • src/domain/postgres/restore/mod.rs
  • src/domain/postgres/restore/prepare.rs
  • src/domain/postgres/restore/run.rs
  • src/domain/postgres/restore/toc.rs
  • src/tests/domain/postgres.rs

📝 Walkthrough

Walkthrough

PostgreSQL restore handling was reorganized into preparation, command execution, clean-mode selection, and database lifecycle helpers. Cluster restore blocking calls now use Tokio’s runtime handle, and integration coverage was expanded. The Compose EDGE_KEY value was also changed.

Changes

PostgreSQL restore flow

Layer / File(s) Summary
Restore contracts and database lifecycle helpers
src/domain/postgres/clean_mode.rs, src/domain/postgres/connection.rs, src/domain/postgres/format.rs, src/domain/postgres/mod.rs
Adds clean-mode parsing, PostgreSQL format comparisons, SQL quoting, format sniffing, privilege checks, schema cleanup, and database drop/recreation helpers.
Archive preparation and command execution
src/domain/postgres/restore/*
Splits restore preparation and execution into archive extraction, TOC inspection, command logging, and restore module wiring.
Clean-mode restore orchestration
src/domain/postgres/restore/run.rs, src/domain/postgres/restore.rs
The restore workflow selects the binary, applies configured cleanup behavior, builds format-specific arguments, and executes pg_restore.
Tokio-compatible cluster restore calls
src/domain/postgres/cluster/restore.rs
Uses the current Tokio runtime handle for blocking version, privilege, and connection-termination operations.
Integration and unit coverage
src/tests/domain/postgres.rs
Adds coverage for archive preparation, restore round trips, cleanup modes, privileges, database recreation, format detection, quoting, TOC parsing, and corrupt archives.

Compose environment update

Layer / File(s) Summary
rust-app environment value
docker-compose.yml
Replaces the EDGE_KEY value for the rust-app service.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Restore
  participant PostgreSQL
  participant pg_restore
  participant JobLogger
  Restore->>PostgreSQL: inspect version and cleanup mode
  Restore->>PostgreSQL: drop schemas or recreate database when configured
  Restore->>pg_restore: execute restore command
  pg_restore-->>Restore: return status and output
  Restore->>JobLogger: log restore result
Loading

Possibly related PRs

  • Portabase/agent#69: Overlaps the PostgreSQL cluster restore path and its psql-based restore flow.
  • Portabase/agent#73: Overlaps ownership, privilege, and connection-termination handling in restore operations.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/postgres-provider

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
docker-compose.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@RambokDev
RambokDev merged commit 84c6b76 into main Jul 23, 2026
1 of 2 checks passed
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.43269% with 38 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/domain/postgres/connection.rs 89.43% 15 Missing ⚠️
src/domain/postgres/restore/prepare.rs 78.04% 9 Missing ⚠️
src/domain/postgres/restore/command.rs 74.07% 7 Missing ⚠️
src/domain/postgres/restore/run.rs 91.30% 6 Missing ⚠️
src/tests/domain/postgres.rs 99.81% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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