Repodb.Ddl.S

repodb · API reference

Dialect-aware DDL facade for schemas and migrations.

Ddl.Make(D) binds Schema and Migration rendering to a concrete driver dialect. It is a small convenience layer for migration runners, admin CLIs, and tests that need to render DDL using the same dialect as the connection they will execute against.

module Ddl = Repodb.Ddl.Make (Repodb_postgresql.Driver)

  let sql = Ddl.schema_to_sql User.table_def
  let actions = Ddl.plan_migrate ~applied_versions:[] ~target:None migrations
  let statements = List.concat_map Repodb.Migration.action_to_sql actions

The facade does not execute SQL. Pair it with a concrete Repo.Make.Ddl module or the driver's exec function when building a migration runner.

val dialect : Driver.dialect
val schema_to_sql : Schema.table_def -> string
val migration_operation_to_sql : Migration.operation -> string
val generate_up_sql : Migration.t -> string list
val generate_down_sql : Migration.t -> string list
val create_schema_migrations_sql : string
val insert_migration_sql : string
val delete_migration_sql : string
val plan_migrate : 
  applied_versions:int64 list ->
  target:int64 option ->
  Migration.t list ->
  Migration.migration_action list
val plan_rollback : 
  applied_versions:int64 list ->
  step:int option ->
  Migration.t list ->
  Migration.migration_action list