pub async fn run_sql_migrations<F, Fut>(
pool: &SqlitePool,
registry_table: &str,
steps: &[(i64, &str, &str)],
detect_existing: F,
) -> Result<(), AdkError>Expand description
Run all pending migrations for a SQL backend.
registry_table must be an ASCII identifier of at most 63 bytes,
starting with a letter or underscore. Step bodies are trusted executable SQL, never user input.
Descriptions are bound as values and may contain quotes.
- Creates the registry table if it does not exist.
- Calls
detect_existingto check for pre-existing schema tables. If tables exist but the registry is empty, records version 1 as already applied (baseline). - Reads the maximum applied version from the registry.
- If the database version exceeds the compiled-in maximum, returns a version-mismatch error.
- Executes each unapplied step inside a transaction and records it in the registry.
Each statement takes a connection from pool. Use
run_sql_migrations_on_connection when every statement must
run on the connection that holds a session-level lock.