db-migrate

Database migration management - Use Flyway and Atlas for version-controlled database schema migrations

23 stars

Best use case

db-migrate is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Database migration management - Use Flyway and Atlas for version-controlled database schema migrations

Teams using db-migrate should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/db-migrate/SKILL.md --create-dirs "https://raw.githubusercontent.com/wangjianjq/Skill/main/.agents/skills/db-migrate/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/db-migrate/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How db-migrate Compares

Feature / Agentdb-migrateStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Database migration management - Use Flyway and Atlas for version-controlled database schema migrations

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Database Migration Skill

## 📋 Overview

Provides two modern database migration tools:

- **Flyway**: Mature and stable, based on versioned SQL scripts
- **Atlas**: Modern, declarative schema management

## 🔧 Prerequisites

### Flyway

| Tool | Installation |
|------|--------------|
| Java 11+ | [adoptium.net](https://adoptium.net/) |
| Flyway CLI | [Download](https://flywaydb.org/download) |

### Atlas

| Tool | Windows | Linux/Mac |
|------|---------|-----------|
| Atlas | `scoop install atlas` | `brew install ariga/tap/atlas` |

## 🚀 Usage

### Flyway Migration

**Create migration script:**

```bash
.\.agent\skills\db-migrate\scripts\flyway-create.ps1 -Name "add_users_table"
# Generates: V1__add_users_table.sql
```

**Execute migration:**

```bash
.\.agent\skills\db-migrate\scripts\flyway-migrate.ps1
```

**Rollback migration:**

```bash
.\.agent\skills\db-migrate\scripts\flyway-undo.ps1
```

### Atlas Migration

**Schema diff:**

```bash
.\.agent\skills\db-migrate\scripts\atlas-diff.ps1
```

**Auto-generate migration:**

```bash
.\.agent\skills\db-migrate\scripts\atlas-migrate.ps1 -Auto
```

## 🎯 Features

### Flyway

- ✅ Versioned SQL migrations (V1__xxx.sql)
- ✅ Repeatable migrations (R__xxx.sql)
- ✅ Rollback support
- ✅ Migration history tracking

### Atlas

- ✅ Declarative schema definition (HCL)
- ✅ Auto-generated migration scripts
- ✅ Visual schema diff
- ✅ Linting and validation

## 📊 Migration Script Examples

**Flyway (V1__create_users.sql):**

```sql
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    username VARCHAR(50) UNIQUE NOT NULL,
    email VARCHAR(100) NOT NULL,
    created_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX idx_users_email ON users(email);
```

**Atlas (schema.hcl):**

```hcl
table "users" {
  schema = schema.public
  column "id" {
    type = serial
  }
  column "username" {
    type = varchar(50)
    null = false
  }
  primary_key {
    columns = [column.id]
  }
  index "idx_users_email" {
    columns = [column.email]
  }
}
```

## 🔗 Related Resources

- [Flyway Documentation](https://flywaydb.org/documentation/)
- [Atlas Documentation](https://atlasgo.io/getting-started)