Bolt
Bolt is a command-line tool for database migrations.
Why Bolt?
Bolt aims to be a simple and reliable tool that can work anywhere you need to run database migrations.
- Schema migrations are written in plain SQL.
- Migrations are versioned sequentially.
- All migrations run in transactions by default.
- Supports up and down migrations and jumping to any particular schema version.
- Supports PostgreSQL, MySQL, SQL Server, and SQLite3.
What It Looks Like
Migrations are separated by “up” and “down” comments to delineate what runs when you apply the migration and what runs when you revert it.
-- migrate:up
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
-- migrate:down
DROP TABLE posts;
$ bolt status
Version Message Applied
0001 create_users_table X
0002 create_posts_table X
0003 add_email_index
Installation
From Source
Clone the repository:
git clone https://git.eugenetriguba.com/bolt/cli bolt
Build the binary:
cd bolt
make
Install the binary and man pages:
sudo make install
Homebrew
If you’re on macOS (or Linux and use Homebrew), you can install Bolt from the tap:
brew tap eugenetriguba/bolt https://git.eugenetriguba.com/bolt/homebrew-tap
brew install bolt
Documentation
After installation, documentation is available via man pages.
Commands
| Page | Description |
|---|---|
| bolt(1) | Main command overview |
| bolt-new(1) | Create a new migration |
| bolt-up(1) | Apply migrations |
| bolt-down(1) | Revert migrations |
| bolt-status(1) | List migration statuses |
| bolt-version(1) | Print version |
| bolt-help(1) | Show manual pages |
File Formats
| Page | Description |
|---|---|
| bolt.toml(5) | Configuration file and environment variables |
| bolt-migration(5) | Migration script format |
Concepts
| Page | Description |
|---|---|
| bolt-tutorial(7) | Getting started tutorial |
| bolt-databases(7) | Database drivers and DSN formats |
| bolt-execution(7) | How migrations are executed |
License
MIT License. See LICENSE for details.