validate

Function validate 

Source
pub async fn validate(
    source_url: &str,
    target_url: &str,
    filter: ReplicationFilter,
) -> Result<()>
Expand description

Pre-flight validation command for migration readiness

Performs comprehensive validation before migration:

  • Checks for required PostgreSQL client tools (pg_dump, pg_dumpall, psql)
  • Validates connection string format
  • Tests connectivity to both source and target databases
  • Discovers and filters databases based on criteria
  • Shows which databases will be replicated
  • Verifies source user has REPLICATION privilege
  • Verifies target user has CREATEDB privilege
  • Confirms PostgreSQL major versions match
  • Validates extension compatibility and preload requirements

§Arguments

  • source_url - PostgreSQL connection string for source database
  • target_url - PostgreSQL connection string for target (Seren) database
  • filter - Replication filter for database and table selection

§Returns

Returns Ok(()) if all validation checks pass.

§Errors

This function will return an error if:

  • Required PostgreSQL tools are not installed
  • Connection strings are invalid
  • Cannot connect to source or target database
  • No databases match filter criteria
  • Source user lacks REPLICATION privilege
  • Target user lacks CREATEDB privilege
  • PostgreSQL major versions don’t match

§Examples

// Validate all databases
validate(
    "postgresql://user:pass@source.example.com/postgres",
    "postgresql://user:pass@target.example.com/postgres",
    ReplicationFilter::empty()
).await?;

// Validate only specific databases
let filter = ReplicationFilter::new(
    Some(vec!["mydb".to_string(), "analytics".to_string()]),
    None,
    None,
    None,
)?;
validate(
    "postgresql://user:pass@source.example.com/postgres",
    "postgresql://user:pass@target.example.com/postgres",
    filter
).await?;