Skip to content

Installation

Go Module

Add Queen to your Go project:

go get github.com/honeynil/queen

CLI Setup

Queen is an embedded CLI library. You create a small entrypoint in your project, and all CLI commands become available through go run or a compiled binary.

1. Create entrypoint

// cmd/queen/main.go
package main

import (
    "yourmodule/migrations"
    "github.com/honeynil/queen/cli"
    _ "github.com/jackc/pgx/v5/stdlib" // your database driver
)

func main() {
    cli.Run(migrations.Register)
}

2. Run commands

# Run directly (no build step needed)
go run ./cmd/queen up --driver postgres --dsn "postgres://localhost/mydb"

# Or build once and use the binary
go build -o queen ./cmd/queen
./queen up --driver postgres --dsn "postgres://localhost/mydb"

Note

For bootstrap commands that don't need migrations (init, create, import, version), you can pass nil instead of a register function: cli.Run(nil).

Supported Go Versions

Queen requires Go 1.24 or later.

Database Drivers

Queen supports the following databases:

Database Go Import
PostgreSQL github.com/jackc/pgx/v5/stdlib
MySQL github.com/go-sql-driver/mysql
SQLite github.com/mattn/go-sqlite3
ClickHouse github.com/ClickHouse/clickhouse-go/v2
CockroachDB github.com/jackc/pgx/v5/stdlib
MS SQL Server github.com/microsoft/go-mssqldb

Example: PostgreSQL

import (
    "github.com/honeynil/queen"
    "github.com/honeynil/queen/drivers/postgres"
    _ "github.com/jackc/pgx/v5/stdlib"
)

Example: MySQL

import (
    "github.com/honeynil/queen"
    "github.com/honeynil/queen/drivers/mysql"
    _ "github.com/go-sql-driver/mysql"
)

Verify Installation

go run ./cmd/queen version

Or after building:

./queen version

Next Steps