Skip to main content

Crate cratestack_sqlx

Crate cratestack_sqlx 

Source

Re-exports§

pub use sqlx;

Structs§

CreateDefault
CreateRecord
DeleteRecord
FieldRef
Filter
FindMany
FindUnique
Migration
A single migration step. Banks store these in source control alongside the schema; the runner applies any rows in migrations not yet present in cratestack_migrations. down is recorded but the runner doesn’t call it — irreversible-by-default is the safe banking posture.
MigrationState
ModelColumn
ModelDelegate
ModelDescriptor
OrderClause
ReadPolicy
RelationFilter
ScopedCreateRecord
ScopedDeleteRecord
ScopedFindMany
ScopedFindUnique
ScopedModelDelegate
ScopedUpdateRecord
ScopedUpdateRecordSet
SqlColumnValue
SqlxIdempotencyStore
SqlxRuntime
UpdateRecord
UpdateRecordSet

Enums§

CreateDefaultType
FilterExpr
MigrationStatus
PolicyExpr
PolicyLiteral
ReadPredicate
RelationQuantifier
SortDirection
SqlValue

Constants§

AUDIT_TABLE_DDL
DDL for the audit log table. Banks typically run migrations through their own tooling — this DDL is exposed so the crate::SqlxRuntime can idempotently ensure the table exists during bootstrap.
MIGRATIONS_TABLE_DDL

Traits§

CreateModelInput
IntoSqlValue
UpdateModelInput

Functions§

apply_pending
Apply every pending migration in the input slice, in order. Each migration runs inside its own transaction; checksum drift aborts the whole apply (banks treat drift as a release-process failure to be resolved by humans, not silently overwritten).
create_record_with_executor
ensure_migrations_table
expiry_from
Compute when a record originally captured at created_at will expire. Pulled out for unit-test reach; the SystemTime arithmetic is otherwise awkward to assert against without a clock injection point.
primary_key_from_snapshot
Extract the primary-key field from a serialized model snapshot. Used to stamp audit events with a stable identifier even when the schema doesn’t surface the PK column verbatim in the response (e.g. policy-stripped).
run_in_isolated_tx
Begin a transaction at the requested isolation level, run body against the live transaction, and commit. On 40001 (serialization_failure) or 40P01 (deadlock_detected) the transaction is rolled back and the body runs again, up to MAX_RETRIES_DEFAULT times. Other errors propagate immediately.
run_in_isolated_tx_with_retries
Same as run_in_isolated_tx but with a caller-chosen retry budget. Banks running long-tail contended writes sometimes want a higher cap (5–10); single-row CAS workflows can drop to 1 to fail fast.
snapshot_model
Convert a model into the JSON snapshot used by the audit log. Returns None if the model isn’t serializable; that should never happen for generated models which derive Serialize, but we degrade gracefully rather than panic.
status
Inspect each migration in migrations against cratestack_migrations and report which are pending / applied / drifted. Use before apply to surface drift to the operator without changing state.
update_record_with_executor