db-migration-review
Review and clean up auto-generated database migration files after running make migrate-create. Identifies and removes unrelated Atlas schema drift such as dropped partial indexes, no-op index recreations, and other operations not related to the intended migration. Use when creating database migrations, running make migrate-create, or reviewing .up.sql files.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 10
- Forks
- 8
01 前言 Front Matter
- name
- db-migration-review
- description
- Review and clean up auto-generated database migration files after running make migrate-create. Identifies and removes unrelated Atlas schema drift such as dropped partial indexes, no-op index recreations, and other operations not related to the intended migration. Use when creating database migrations, running make migrate-create, or reviewing .up.sql files.
03 SKILL.md 正文
DB Migration Review
Atlas diffs the Ent schema against a dev database and often emits operations unrelated to the change, because it can't model some indexes. Review every generated .up.sql in pkg/database/migrations/ before it is committed.
Indexes Atlas can't model (never drop)
| Index | Table | Created in |
|---|---|---|
agentexecution_stage_id_agent_index_top_level |
agent_executions |
20260225235224_add_orchestrator_sub_agent_fields.up.sql |
agentexecution_parent_execution_id_agent_index_sub_agent |
agent_executions |
20260225235224_add_orchestrator_sub_agent_fields.up.sql |
idx_alert_sessions_alert_data_gin |
alert_sessions |
CreateGINIndexes in pkg/database/migrations.go |
idx_alert_sessions_final_analysis_gin |
alert_sessions |
CreateGINIndexes in pkg/database/migrations.go |
idx_timeline_events_content_gin |
timeline_events |
CreateGINIndexes in pkg/database/migrations.go |
idx_alert_sessions_labels_gin |
alert_sessions |
CreateGINIndexes in pkg/database/migrations.go |
The first two are partial unique indexes (WHERE parent_execution_id IS [NOT] NULL) documented in ent/schema/agentexecution.go. The GIN indexes are created at startup.
Checklist
- Wrap the file in
BEGIN;/COMMIT;if Atlas didn't. A failed migration then rolls back cleanly andrecoverDirtyMigration(pkg/database/client.go) can retry on the next deploy. Exception: statements that can't run in a transaction (e.g.CREATE INDEX CONCURRENTLY) go in their own migration file withoutBEGIN/COMMIT. - Remove any
DROP INDEXfor an index in the table above, or any other index created by hand or with aWHEREclause (searchpkg/database/migrations/for where it was created). - Remove
DROP INDEX+CREATE INDEXpairs whoseCREATEmatches the existing definition in an earlier migration (common withsessionscore_session_id). - Remove
ALTER TABLEstatements on tables unrelated to the migration's purpose. If unsure, find the Ent schema change that caused it. - Run
make migrate-hashto updateatlas.sum.
Adding a new index Atlas can't model
Write it as raw SQL in the migration, add a comment naming it and its migration file in the Ent schema's Indexes(), and add a row to the table above.
04 同仓库更多 Skills
simple-skill
A simple test skill to verify directory layout loading.
example-skill
Example skill for config viewer e2e coverage.
networking
Network troubleshooting skills including DNS resolution, TCP connectivity, and packet analysis.
kubernetes-basics
Core Kubernetes concepts including pods, deployments, services, and common troubleshooting patterns.