agentleFS
hiromailyhiromaily/go-crypto-wallet/.claude/skills/db-migration/SKILL.md

db-migration

Skill128 starsChanged 6 months agoMITView on GitHub

Database schema and migration workflow. Use when modifying database schemas in tools/atlas/ or SQLC queries in tools/sqlc/.

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 16 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run all three targets after modifying HCL schemas:

    line 42
  2. Distinctive:

    After running the regenerate targets, confirm each DB dialect has exactly one migration SQL file:

    line 59

“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Database Migration Workflow

Workflow for database schema and migration changes.

Prerequisites

  • Use git-workflow Skill for branch, commit, and PR workflow.
  • Refer to .claude/rules/hcl.md for HCL schema rules (SSOT).
  • Refer to .claude/rules/sql.md for SQL query rules (SSOT).

Applicable Files

PathDescription
tools/atlas/schemas/{db_dialect}/*.hclHCL schema definitions (source of truth)
tools/sqlc/queries/{db_dialect}/*.sqlSQLC query definitions

Workflow

1. Modify Schema (HCL)

Edit HCL files in tools/atlas/schemas/{db_dialect}/.

Dialect directories:

  • tools/atlas/schemas/postgres/*.hcl
  • tools/atlas/schemas/mysql/*.hcl

2. Verify HCL (from rules/hcl.md)

make atlas-fmt && make atlas-lint

3. Regenerate All Artifacts

Run all three targets after modifying HCL schemas:

# Regenerate migrations, extract SQLC schemas, and generate Go code for PostgreSQL
make regenerate-all-from-atlas

# Regenerate for MySQL
make regenerate-all-from-atlas-mysql

# Convert PostgreSQL schemas to SQLite and generate Go code for SQLite
make regenerate-all-from-atlas-sqlite

Each target handles: Atlas migrations → Docker DB reset → SQLC schema extraction → SQLC code generation.

4. Verify Migration Files

After running the regenerate targets, confirm each DB dialect has exactly one migration SQL file:

  • tools/atlas/migrations/postgres/{db-name}/*.sql ← one file, updated
  • tools/atlas/migrations/mysql/{db-name}/*.sql ← one file, updated

DB names: keygen, sign, watch

5. Verify Go Code

make check-build && make go-test

Self-Review Checklist

  • HCL format/lint passes
  • make regenerate-all-from-atlas succeeds (postgres)
  • make regenerate-all-from-atlas-mysql succeeds (mysql)
  • make regenerate-all-from-atlas-sqlite succeeds (sqlite)
  • Each tools/atlas/migrations/{postgres,mysql}/{db-name}/ has exactly one .sql file and it is updated
  • SQLC generates correctly
  • Go build passes

Related

  • .claude/rules/hcl.md - HCL rules (SSOT)
  • .claude/rules/sql.md - SQL rules (SSOT)
  • go-development - Go verification after SQLC generation
  • git-workflow - Branch, commit, PR workflow

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.