123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101typestep={label:string;statement:string;check_fk:bool}typesteps=steplisttypet=string*stepsletname="migration"exceptionExceptionofstringexceptionDirty_migrationmoduletypeSig=sig(** [register_migration migration] registers a migration [migration] with the
migration service so it can be executed with `run_all`. *)valregister_migration:t->unit(** [register_migrations migrations] registers migrations [migrations] with
the migration service so it can be executed with `run_all`. *)valregister_migrations:tlist->unit(** [execute ?ctx migrations] runs all migrations [migrations] on the
connection pool. *)valexecute:?ctx:(string*string)list->tlist->unitLwt.t(** [run_all ?ctx ()] runs all migrations that have been registered on the
connection pool. *)valrun_all:?ctx:(string*string)list->unit->unitLwt.t(** [migrations_status ?ctx ?migrations ()] returns a list of migration
namespaces and the number of their unapplied migrations.
By default, the migrations are checked that have been registered when
registering the migration service. Custom [migrations] can be provided to
override this behaviour. *)valmigrations_status:?ctx:(string*string)list->?migrations:tlist->unit->(string*intoption)listLwt.t(** [check_migration_status ?ctx ?migrations ()] returns a list of migration
namespaces and the number of their unapplied migrations.
It does the same thing as {!migration_status} and additionally interprets
whether there are too many, not enough or just the right number of
migrations applied. If there are too many or not enough migrations
applied, a descriptive warning message is logged. *)valcheck_migrations_status:?ctx:(string*string)list->?migrations:tlist->unit->unitLwt.t(** [pending_migrations ?ctx ()] returns a list of migrations that need to be
executed in order to have all migrations applied on the connection pool.
The returned migration is a tuple [(namespace, number)] where [namespace]
is the namespace of the migration and [number] is the number of pending
migrations that need to be applied in order to achieve the desired schema
version.
An empty list means that there are no pending migrations and that the
database schema is up-to-date. *)valpending_migrations:?ctx:(string*string)list->unit->(string*int)listLwt.tvalregister:tlist->Core_container.Service.tincludeCore_container.Service.Sigend(* Common *)letto_sexp(namespace,steps)=letopenSexplib0.Sexp_convinletopenSexplib0.Sexpinletsteps=List.map(fun{label;statement;check_fk}->List[List[Atom"label";sexp_of_stringlabel];List[Atom"statement";sexp_of_stringstatement];List[Atom"check_fk";sexp_of_boolcheck_fk]])stepsinList(List.cons(List[Atom"namespace";sexp_of_stringnamespace])steps);;letppfmtt=Sexplib0.Sexp.pp_humfmt(to_sexpt)letemptynamespace=namespace,[]letcreate_step~label?(check_fk=true)statement={label;check_fk;statement};;(* Append the migration step to the list of steps *)letadd_stepstep(label,steps)=label,List.concat[steps;[step]]