smithery.ai

gookit-miglite

miglite is an Lite database schema migration tool by Go

First seen Apr 12, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Skill metadata

Parsed from SKILL.md frontmatter.

Version1.0.0

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 11,068 B
  • docs SUMMARY.md 63 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

miglite - Lite Database Migration Tool

A minimalist database schema migration tool implemented in Golang by gookit. Designed for simplicity with minimal dependencies, miglite provides a lightweight yet powerful solution for managing database schema changes.

Table of Contents

  • [Overview](#overview)
  • [Key Features](#key-features)
  • [Installation](#installation)
  • [Quick Start](#quick-start)
  • [Documentation](#documentation)
  • [Basic Usage](#basic-usage)
  • [Resources](#resources)

Overview

miglite is a database migration tool that prioritizes simplicity and ease of use. Unlike heavyweight alternatives, it has minimal dependencies and is built directly on Go's database/sql package without adding any driver dependencies by default.

Supported Databases

  • MySQL - Full support with transaction-based migrations
  • PostgreSQL - Complete PostgreSQL compatibility
  • SQLite - Lightweight embedded database support
  • MSSQL - Microsoft SQL Server support

Design Philosophy

  • Zero Configuration: Works out of the box with environment variables
  • Minimal Dependencies: No external dependencies in the core library
  • Transaction Safety: All migrations execute within transactions
  • Raw SQL: Uses plain SQL files for maximum flexibility
  • Dual Mode: Works as both CLI tool and Go library

Key Features

1. Easy to Use

  • Simple command-line interface
  • Clear status reporting with visual feedback
  • Interactive confirmation for destructive operations
  • Minimal learning curve

2. Minimal Dependencies

  • Core library has zero third-party dependencies
  • Built on database/sql standard library
  • You choose your own database driver

3. Transaction Safety

  • All migration SQL executes within transactions
  • Ensures data consistency
  • Automatic rollback on failure

4. Flexible Migration Files

  • Uses raw SQL files (no Go code required)
  • Fixed naming convention: YYYYMMDD-HHMMSS-{migration-name}.sql
  • Supports both UP and DOWN migrations
  • Recursive directory scanning
  • Supports multiple migration directories
  • Environment variables in directory paths

5. Zero Configuration Option

  • Works with just DATABASE_URL environment variable
  • Auto-loads .env files if present
  • Auto-loads miglite.yaml if present
  • Supports multiple configuration sources with priority

6. Special Features

  • Ignores directories starting with (e.g., backup/)
  • Multiple migration paths with comma separation
  • Environment variable substitution in paths (e.g., ./migrations/${MODULE_NAME})
  • Built-in support for multiple database drivers in CLI tool

Installation

As CLI Tool

Install the miglite command-line tool globally:

# Install latest version
go install github.com/gookit/miglite/cmd/miglite@latest

# Verify installation
miglite --version

The CLI tool comes with all database drivers included (MySQL, PostgreSQL, SQLite, MSSQL).

As Go Library

Add miglite as a dependency to your Go project:

# Add dependency
go get github.com/gookit/miglite

# In your code
import "github.com/gookit/miglite"

Important: When using as a library, you must add your own database driver dependencies:

# For MySQL
go get github.com/go-sql-driver/mysql

# For PostgreSQL
go get github.com/lib/pq

# For SQLite (CGO-free recommended)
go get modernc.org/sqlite

# For MSSQL
go get github.com/microsoft/go-mssqldb

More drivers: https://go.dev/wiki/SQLDrivers

Quick Start

1. Initialize Your Project

Create a migrations directory:

mkdir migrations

2. Configure Database Connection

Option A: Environment Variable (Recommended)

# For SQLite
export DATABASE_URL="sqlite://./app.db"

# For MySQL
export DATABASE_URL="mysql://user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local"

# For PostgreSQL
export DATABASE_URL="postgres://host=localhost port=5432 user=username password=password dbname=dbname sslmode=disable"

Option B: Configuration File

Create miglite.yaml:

database:
  driver: mysql  # or: sqlite, postgres, mssql
  dsn: user:password@tcp(localhost:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local

migrations:
  path: ./migrations
  recursive: true

3. Initialize Migration System

# Create the migration tracking table
miglite init

4. Create Your First Migration

# Create a new migration file
miglite create create-users-table

This creates: ./migrations/20260128-143022-create-users-table.sql

Edit the file:

-- Migrate:UP
CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(255) NOT NULL,
  email VARCHAR(255) NOT NULL UNIQUE,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Migrate:DOWN
DROP TABLE users;

5. Run Migrations

# Apply all pending migrations
miglite up

# Or skip confirmation
miglite up --yes

6. Check Status

# View migration status
miglite status

Documentation

Detailed documentation is organized into focused guides:

📘 [Configuration Guide](references/CONFIGURATION.md)

Complete configuration reference covering:

  • Configuration priority and loading
  • YAML file format
  • Environment variables
  • Database URL formats
  • Connection pool settings
  • Multi-environment setup
  • Docker configuration

🔧 [CLI Command Reference](references/CLI_REFERENCE.md)

Comprehensive CLI documentation:

  • All commands (init, create, up, down, status, show, skip)
  • Command options and flags
  • Usage examples
  • Common workflows
  • Exit codes

📝 [Migration Files Guide](references/MIGRATION_FILES.md)

Everything about migration files:

  • File naming conventions
  • File structure and sections
  • Migration examples (5 detailed examples)
  • Database-specific syntax
  • Directory organization
  • Best practices for writing migrations

📚 [Library Usage Guide](references/LIBRARY_USAGE.md)

Using miglite as a Go library:

  • Installation and setup
  • Basic usage examples (4 examples)
  • Advanced usage patterns
  • Framework integration (Gin, Echo)
  • Testing integration
  • Building custom migration tools
  • Docker integration

🔍 [API Reference](references/API_REFERENCE.md)

Complete API documentation:

  • Migrator type and methods
  • Configuration types
  • Command options
  • Helper types
  • Error handling
  • Thread safety considerations

✅ [Best Practices](references/BEST_PRACTICES.md)

Recommended practices (10 key practices):

  • Writing DOWN migrations
  • Testing migrations
  • Naming conventions
  • Keeping migrations atomic
  • Data migration handling
  • Transaction usage
  • Version control
  • Production deployment
  • Environment management
  • CI/CD integration

🔧 [Troubleshooting](references/TROUBLESHOOTING.md)

Common issues and solutions:

  • Configuration issues
  • Database connection problems
  • Migration file issues
  • Transaction errors
  • SQLite specific issues
  • Environment variable problems
  • Performance issues
  • Debugging tips

Basic Usage

CLI Commands

# Initialize migration system
miglite init

# Create new migration
miglite create MIGRATION_NAME

# Apply pending migrations
miglite up
miglite up --yes              # Skip confirmation
miglite up --number 3         # Apply only 3 migrations

# Rollback migrations
miglite down
miglite down --number 2       # Rollback 2 migrations

# View migration status
miglite status
miglite status --json         # JSON output

# Show database tables
miglite show
miglite show --details

# Skip migrations
miglite skip VERSION          # Skip specific migration
miglite skip --all            # Skip all pending

See [CLI Reference](references/CLI_REFERENCE.md) for detailed documentation.

Library Usage

Simple Example:

package main

import (
    "log"
    "github.com/gookit/miglite"
    "github.com/gookit/miglite/pkg/command"
    _ "github.com/go-sql-driver/mysql"
)

func main() {
    // Create migrator with auto-loaded config
    mig, err := miglite.NewAuto()
    if err != nil {
        log.Fatal(err)
    }

    // Initialize migration table
    if err := mig.Init(command.InitOption{}); err != nil {
        log.Fatal(err)
    }

    // Run migrations
    if err := mig.Up(command.UpOption{Yes: true}); err != nil {
        log.Fatal(err)
    }

    log.Println("Migrations applied successfully!")
}

See [Library Usage Guide](references/LIBRARY_USAGE.md) for more examples and patterns.

Resources

Official Links

Database Drivers

MySQL:

PostgreSQL:

SQLite (CGO-free):

SQLite (CGO):

MSSQL:

Complete List:

Related Projects

Alternative Migration Tools:

Community

- goutil - Go utility functions library - color - Terminal color output - config - Configuration management

Learning Resources

Go database/sql:

Database Schema Migrations:

Support

For questions and issues:

  1. Check the [documentation guides](references/) in this skill
  2. Read the official README
  3. Review [troubleshooting guide](references/TROUBLESHOOTING.md)
  4. Search existing issues
  5. Create a new issue

Note: This skill was auto-generated by repo2skill on 2026-01-28. For the latest information, always refer to the official repository.