package migra

  1. Overview
  2. Docs
A database migration tool and library for OCaml supporting PostgreSQL, MariaDB/MySQL, and SQLite

Install

dune-project
 Dependency

Authors

Maintainers

Sources

migra-1.0.1.tbz
sha256=daaaab416e580e5b8dc9f0a74482e142cef6d77b248d995d320f6f882d3a9e35
sha512=8f60494b9ee6ac2e7e69a16eefce69d1e8c22e831fe28f600a42200e3086e2f4d15331323ad1848f7165e1c8ff30fe320445185b7e988325588293a66937966a

doc/migra.engine/Migra_engine/Database/index.html

Module Migra_engine.DatabaseSource

Sourceval get_hostname : Uri.t -> (string, Types.error) result
Sourceval get_port : Uri.t -> (int, Types.error) result
Sourceval get_database : Uri.t -> (string, Types.error) result
Sourceval get_database_url : unit -> (string, Types.error) result
Sourceval redact_url : string -> string

Replace the password in a connection URL with a fixed ***** mask for safe display (does not reveal the password length).

Sourceval connect_db : string -> (Types.db_conn, Types.error) result Lwt.t

Connect to database using connection string. Returns a single connection (use for one-off operations or transactions).

Sourceval with_db : string -> (Types.db_conn -> 'a Lwt.t) -> ('a, Types.error) Lwt_result.t
Sourceval get_admin_database_url : Dialect.t -> Uri.t -> (string, Types.error) result

Build connection URL for admin database (dialect-aware). Used for creating/dropping databases.

  • parameter dialect

    Database dialect type

  • parameter uri

    Parsed database URL

  • returns

    Admin database connection URL

Sourceval create_database : string -> (unit, Types.error) Lwt_result.t

Create database if it doesn't exist (dialect-aware). For SQLite: Database file created on first connection. For PostgreSQL/MariaDB: Uses admin database to execute CREATE DATABASE.

Sourceval drop_database : string -> (unit, Types.error) Lwt_result.t

Drop database if it exists (dialect-aware). For SQLite: Deletes the database file. For PostgreSQL/MariaDB: Uses admin database to execute DROP DATABASE.