Migra_engine.RunnerSourceEvery operation takes an optional ?table (default default_table) naming the table that tracks applied migrations.
Validate that a table name is a safe SQL identifier (it is interpolated into queries, not bound as a parameter).
val ensure_migrations_table :
?table:string ->
Dialect.t ->
Types.db_conn ->
(unit, [> Caqti_error.t ]) Lwt_result.tCreate the migrations table if absent and add the checksum column to pre-existing tables that lack it (dialect-aware). Idempotent.
val is_applied :
?table:string ->
Types.db_conn ->
int64 ->
(bool, [> Caqti_error.t ]) Lwt_result.tval get_applied_versions :
?table:string ->
Types.db_conn ->
(int64 list, [> Caqti_error.t ]) Lwt_result.tval get_applied_records :
?table:string ->
Dialect.t ->
Types.db_conn ->
(migration_record list, [> Caqti_error.t ]) Lwt_result.tGet all applied migrations with timestamps, sorted chronologically (dialect-aware)
val get_applied_checksums :
?table:string ->
Types.db_conn ->
((int64 * string option) list, [> Caqti_error.t ]) Lwt_result.tGet all applied (version, checksum) pairs, sorted chronologically. The checksum is None for rows recorded before checksums were tracked.
val get_latest_version :
?table:string ->
Types.db_conn ->
(int64 option, [> Caqti_error.t ]) Lwt_result.tThe following functions are exposed for testing purposes. They should not be used directly in application code.
val add_migration :
?table:string ->
Types.db_conn ->
int64 ->
string option ->
(unit, [> Caqti_error.t ]) Lwt_result.tAdd a migration (mark as applied) with its checksum. Internal - use run_migration.
val remove_migration :
?table:string ->
Types.db_conn ->
int64 ->
(unit, [> Caqti_error.t ]) Lwt_result.tRemove a migration record (for rollback). Internal - use rollback_migration instead.
val run_until_failure :
step:('a -> 'b Lwt.t) ->
is_ok:('b -> bool) ->
'a list ->
'b list Lwt.tRun step over each item in order, stopping after the first result for which is_ok is false (that failing result is still included). Shared sequential engine; callers supply a step that may add timing or output.
val pending_migrations :
?table:string ->
?migrations_dir:string ->
Types.db_conn ->
(Migration.t list, Types.error) Lwt_result.tAll migrations on disk minus those already applied. Fails with OutOfOrder if a pending migration predates the latest applied one.
val applied_migrations :
?table:string ->
?migrations_dir:string ->
Types.db_conn ->
(Migration.t list, Types.error) Lwt_result.tMigrations that are both recorded as applied and present on disk, in chronological order.
val rollback_targets :
?table:string ->
?migrations_dir:string ->
Types.db_conn ->
rollback_strategy ->
(Migration.t list, Types.error) Lwt_result.tval validate :
?table:string ->
?migrations_dir:string ->
Types.db_conn ->
(unit, Types.error) Lwt_result.tValidate applied migrations against the files on disk: detects an applied migration whose file is missing (AppliedFileMissing) or whose contents changed since it was applied (ChecksumMismatch). Rows recorded before checksums were tracked are skipped.
val run_migration :
?verbose:bool ->
?table:string ->
Types.db_conn ->
Migration.t ->
execution_result Lwt.tExecute a migration's up SQL within a transaction, recording its checksum. Returns Success on success, Failure on error (transaction rolled back).
val run_migrations :
?verbose:bool ->
?table:string ->
Types.db_conn ->
Migration.t list ->
execution_result list Lwt.tval run_pending :
?verbose:bool ->
?table:string ->
Types.db_conn ->
string ->
(execution_result list, Types.error) Lwt_result.tval rollback_migration :
?verbose:bool ->
?table:string ->
Types.db_conn ->
Migration.t ->
execution_result Lwt.tExecute a migration's down SQL (rollback) within a transaction. On failure, transaction is rolled back automatically.
val rollback_step :
?verbose:bool ->
?table:string ->
?migrations_dir:string ->
Types.db_conn ->
int ->
(execution_result list, Types.error) Lwt_result.tval rollback_to :
?verbose:bool ->
?table:string ->
?migrations_dir:string ->
Types.db_conn ->
int64 ->
(execution_result list, Types.error) Lwt_result.tval rollback_all :
?verbose:bool ->
?table:string ->
?migrations_dir:string ->
Types.db_conn ->
(execution_result list, Types.error) Lwt_result.t