dennisonbertram/go-code/db-migrations

Claude Code and agent skill by dennisonbertram/go-code

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Create, run, and rollback database migrations using goose or golang-migrate. Trigger: when running database migrations, creating migration files, rolling back migrations, using goose, using golang-migrate

Install

npx vskill@latest install dennisonbertram/go-code/db-migrations

SKILL.md

Database Migrations

You are now operating in database migration mode.

Goose (Recommended for Go Projects)

Installation
bash
go install github.com/pressly/goose/v3/cmd/goose@latest
Create Migrations
bash
# Create a SQL migration
goose -dir migrations create add_users_table sql
# Create a Go migration (for complex data transforms)
goose -dir migrations create backfill_user_roles go

This creates timestamped files like migrations/20260310120000_add_users_table.sql.

SQL Migration File Format
sql
-- +goose Up
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX idx_users_email ON users(email);
-- +goose Down
DROP TABLE IF EXISTS users;
Running Migrations
bash
# Apply all pending migrations
goose -dir migrations postgres "postgresql://postgres:dev@localhost:5432/myapp" up
# Apply one migration
goose -dir migrations postgres "postgresql://postgres:dev@localhost:5432/myapp" up-by-one
# Rollback one migration
goose -dir migrations postgres "postgresql://postgres:dev@localhost:5432/myapp" down
# Rollback to a specific version
goose -dir migrations postgres "postgresql://postgres:dev@localhost:5432/myapp" down-to 20260310000000
# Rollback and re-apply last migration
goose -dir migrations postgres "postgresql://postgres:dev@localhost:5432/myapp" redo
# Show migration status
goose -dir migrations postgres "postgresql://postgres:dev@localhost:5432/myapp" status
SQLite with Goose
bash
# SQLite driver
goose -dir migrations sqlite3 "./app.db" up
goose -dir migrations sqlite3 "./app.db" status
Goose in Go Code (Embedded)
go
import (
"embed"
"database/sql"
"github.com/pressly/goose/v3"
)
//go:embed migrations/*.sql
var migrations embed.FS
func runMigrations(db *sql.DB) error {
goose.SetBaseFS(migrations)
if err := goose.SetDialect("postgres"); err != nil {
return err
}
return goose.Up(db, "migrations")
}

golang-migrate

Installation
bash
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
Create Migrations

golang-migrate uses paired files: one for up, one for down.

bash
migrate create -ext sql -dir migrations -seq add_users_table
# Creates:
# migrations/000001_add_users_table.up.sql
# migrations/000001_add_users_table.down.sql
Running Migrations
bash
# Apply all migrations
migrate -path migrations -database "postgresql://postgres:dev@localhost:5432/myapp?sslmode=disable" up
# Rollback N steps
migrate -path migrations -database "..." down 1
# Go to a specific version
migrate -path migrations -database "..." goto 3
# Show current version
migrate -path migrations -database "..." version

Simple SQL Migration Pattern (No Tool)

For small projects without a migration tool:

bash
# Create migration directory
mkdir -p migrations
# Number migrations sequentially
# migrations/001_create_users.sql
# migrations/002_add_sessions.sql
# Apply with a simple script
for f in migrations/*.sql; do
psql "$DATABASE_URL" -f "$f"
echo "Applied: $f"
done

Best Practices

  • Always write a Down migration that perfectly reverses the Up.
  • Test the rollback locally before merging.
  • Never edit a migration that has already been applied to production.
  • Use transactions in SQL migrations when the database supports them.
  • Keep migrations small and focused — one logical change per migration.
  • Run status before up in CI to confirm the expected state.

Migration Status Check

bash
# Goose status shows applied/pending
goose -dir migrations postgres "$DATABASE_URL" status
# Example output:
# Applied At Migration
# =======================================
# 2026-03-01 10:00:00 +0000 001_create_users.sql
# Pending 002_add_sessions.sql

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1
Repository forks
1
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/dennisonbertram/go-code/db-migrations/badge)](https://verified-skill.com/skills/dennisonbertram/go-code/db-migrations)

Something wrong with this skill or its page? Tell us.