package migra
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/CHANGELOG.html
Changelog
All notable changes to this project are documented here. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.1
Fixed
rollbackandredonow validate applied migrations against the files on disk before running and returnErroron drift (a modified or missing applied migration), just likemigrate. Previously they could roll back using modified down SQL or silently skip a migration whose file was gone.statusnow includes an applied migration whose file is missing (shown as(migration file missing)) instead of hiding it and understating the applied count.- Database lifecycle commands (
create_database/drop_database) now quote and escape the database identifier in the generated DDL, so PostgreSQL names such asmy-dbwork and MariaDB names containing backticks are handled safely.
1.0.0
First stable release.
Added
- Checksums & validation - each applied migration's file checksum is recorded;
migraterefuses to run if an already-applied migration was modified (ChecksumMismatch) or its file went missing (AppliedFileMissing). - Out-of-order detection - adding a migration older than the latest applied one is rejected (
OutOfOrder). - Configurable migrations table via
--table/Migrator.make ~table. redocommand andMigrator.redo- roll back the last migration(s) and re-apply.--dry-runformigrateandrollback- preview without changing the database.--database-urlflag - overrides theDATABASE_URLenvironment variable.- Library facade -
Migra.Migrator(run/run_or_error/rollback/redo/status/generate, with?on_eventprogress callbacks) andMigra.Database(lifecycle + URL helpers) form the public API; the implementation lives in the internalmigra.enginelibrary. Migra.Migrator.run_or_error- a fail-fast wrapper aroundrunfor the migrate-on-startup path: a migration whose SQL fails is returned asError(MigrationError (ExecutionFailed ...)) rather thanOkwithfailure_count > 0.- Arbitrary SQL support: dollar-quoted bodies,
DELIMITERfor MySQL/MariaDB routines, line/block comments, and literal$/?in statements.
Changed
- Credentials are masked (
*****) instatusoutput and never printed in clear. - Stricter migration filenames: exactly 14 digits then
_<description>.sql; malformed migration-shaped files are reported instead of silently skipped. Migrator.run/rollbackreturnErroronly when migrations could not run; per-migration SQL failures surface asOkwithfailure_count > 0(seeMigrator.succeeded).
Fixed
- Connections are always closed (no leak), even on error paths.
- The admin connection URL preserves passwords, query parameters, and IPv6 hosts.
- Duplicate migration versions are detected and rejected.
Known limitations
- On MySQL/MariaDB, DDL statements implicitly commit and cannot be rolled back, so a multi-statement DDL migration is not atomic there. Keep MySQL/MariaDB migrations to a single DDL change each. (PostgreSQL and SQLite are fully transactional, including DDL.)