Bolt¶
Bolt is a command-line tool designed to simplify and streamline your database migration process.
It is distributed as a standalone binary, making it easy to run anywhere without having to setup any tooling, and it is language independent. It doesn't matter what programming language you're using, you can use Bolt for any project you have.
Features¶
- Schema migrations are written in plain SQL
- Migrations can be versioned sequentially or by creation timestamp
- 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
Quick Start¶
Install Bolt¶
This will install Bolt to your $GOBIN directory. Make sure that $GOBIN is in your $PATH.
Create your first migration¶
Write your migration¶
Edit the generated SQL file in the migrations/ directory:
-- migrate:up
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);
-- migrate:down
DROP TABLE users;
Configure Bolt¶
Create a bolt.toml file:
[database]
dsn = "postgresql://user:password@localhost:5432/mydb?sslmode=disable"
driver = "postgresql"
Apply your migration¶
Next Steps¶
- Read the installation guide for all installation options.
- Follow the Tutorial for a detailed walkthrough.
- Check out How-To Guides for specific tasks.
- Browse the Reference for commands and configuration options.
- Read Explanations to understand how Bolt works internally.
- See Contributing if you're interesting in contributing to Bolt.