migrable
Declarative config file migrations for TOML.
Features
- 14 migration ops covering structure, data, and raw edits
- Comment-preserving TOML editing via go-toml-edit
- Rollback via down ops
- Multi-file transactional writes
- CEL expressions for transforms
- Dry-run preview
- Conformance test suite
Install
go install github.com/smm-h/migrable@latest
Or download binaries from GitHub Releases.
npm and PyPI wrappers coming soon.
Quick start
- Scaffold a new project:
migrable init
This creates migrable.toml and a migrations/ directory.
- Edit
migrable.toml to point to your config file:
migrations_dir = "migrations"
[files]
config = "config.toml"
- Create a migration file
migrations/0001_add-debug.toml:
description = "add debug flag to server section"
[[structure]]
op = "add_field"
path = "server.debug"
type = "boolean"
default = false
down = { op = "remove_field", path = "server.debug" }
- Apply pending migrations:
migrable migrate
- Preview changes without writing:
migrable migrate --dry-run
- Reverse the last migration:
migrable migrate --rollback
Library usage
Go projects can import the engine directly:
import (
"github.com/smm-h/migrable/config"
"github.com/smm-h/migrable/engine"
)
cfg, _ := config.Load("")
result, _ := engine.Migrate(cfg, false)
CLI reference
| Command |
Description |
migrable migrate |
Run pending migrations |
migrable migrate --dry-run |
Preview changes |
migrable migrate --rollback |
Reverse last migration |
migrable status |
Show version and pending migrations |
migrable validate |
Check migration files |
migrable merge <version> |
Combine staging files |
migrable init |
Scaffold new project |
Shell completions
migrable completion bash > /etc/bash_completion.d/migrable
migrable completion zsh > "${fpath[1]}/_migrable"
migrable completion fish > ~/.config/fish/completions/migrable.fish
License
MIT