pub async fn init_sqlite_to_postgres(
sqlite_path: &str,
target_url: &str,
) -> Result<()>Expand description
Initial replication from SQLite to PostgreSQL
Performs one-time migration of SQLite database to PostgreSQL target using JSONB storage:
- Validates SQLite file exists and is readable
- Validates PostgreSQL target connection
- Lists all tables from SQLite database
- For each table:
- Converts rows to JSONB format
- Creates JSONB table in PostgreSQL
- Batch inserts all data
All SQLite data is stored as JSONB with metadata:
- id: Original row ID (from ID column or row number)
- data: Complete row as JSON object
- _source_type: “sqlite”
- _migrated_at: Timestamp of migration
§Arguments
sqlite_path- Path to SQLite database file (.db, .sqlite, or .sqlite3)target_url- PostgreSQL connection string for target (Seren) database
§Returns
Returns Ok(()) if migration completes successfully.
§Errors
This function will return an error if:
- SQLite file doesn’t exist or isn’t readable
- Cannot connect to target PostgreSQL database
- Table conversion fails
- Database creation or insert operations fail
§Examples
init_sqlite_to_postgres(
"database.db",
"postgresql://user:pass@seren.example.com/targetdb"
).await?;