pub async fn create_jsonb_table(
client: &Client,
table_name: &str,
source_type: &str,
) -> Result<()>Expand description
Create a table with JSONB schema for storing non-PostgreSQL data
Creates a table with the following structure:
- id: TEXT PRIMARY KEY (original document/row ID)
- data: JSONB NOT NULL (complete document/row as JSON)
- _source_type: TEXT NOT NULL (‘sqlite’, ‘mongodb’, or ‘mysql’)
- _migrated_at: TIMESTAMP NOT NULL DEFAULT NOW()
Also creates two indexes:
- GIN index on data column for efficient JSONB queries
- Index on _migrated_at for temporal queries
§Arguments
client- PostgreSQL client connectiontable_name- Name of the table to create (must be validated)source_type- Source database type (‘sqlite’, ‘mongodb’, or ‘mysql’)
§Security
CRITICAL: table_name MUST be validated with validate_table_name() before calling. This function uses table_name in SQL directly (not parameterized) after validation.
§Examples
let table_name = "users";
validate_table_name(table_name)?;
create_jsonb_table(client, table_name, "sqlite").await?;