AgentSkillsCN

database-migrations

为本项目使用 golang-migrate 创建并管理 PostgreSQL Schema 迁移。当您需要新增或修改表、列、索引或约束,或执行迁移、回滚迁移时,此技能将助您事半功倍。

SKILL.md
--- frontmatter
name: database-migrations
description: Creates and manages PostgreSQL schema migrations with golang-migrate for this project. Use when adding or changing tables, columns, indexes, or constraints, or when running or rolling back migrations.
version: 1.0

Database Migrations Skill

When to use

  • Adding or changing tables, columns, indexes, or constraints
  • Creating new NNNNNN_description.up.sql and .down.sql pairs
  • Running or rolling back migrations (make migrate-up, make migrate-down)
  • Checking migration version or troubleshooting migrate state

For repository code (queries, transactions, domain↔DB mapping), see .cursor/rules/database-migrations.mdc and the go-backend skill.

References

FilePurpose
.cursor/rules/database-migrations.mdcMigration naming, immutability, up/down, schema conventions (tables, columns, indexes, FKs), column types, SQL practices; repository pattern, parameterized queries, transactions, error mapping, connection pooling, testcontainers
migrations/README.mdProject migrate setup, make migrate-*, migrate CLI, troubleshooting, schema_migrations