agentleFS
andy-dendy-repoandy-dendy-repo/govern/.claude/skills/add-migration/SKILL.md

add-migration

Skill2 starsChanged 32 days agoMITView on GitHub

Creates, reviews and verifies an EF Core migration for Govern after model changes (entities or configurations). Use when the EF model changed, the user asks for a migration, or tests fail with pending model changes.

13 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If user-secrets are configured for src/Govern.Api, the environment variables are not needed.

    line 20

“Common” is measured: kept by at least 6 in 10 of the 12 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

Add a migration

1. Generate

Name the migration in PascalCase after what it does (AddOrders, AddUserDisplayName). No database connection is needed, but the host must build:

dotnet tool restore
ConnectionStrings__Govern="Host=localhost;Database=govern;Username=postgres;Password=unused" \
Jwt__SigningKey="design-time-only-key-not-a-secret-000000" \
dotnet ef migrations add <Name> --project src/Govern.Infrastructure --startup-project src/Govern.Api --output-dir Persistence/Migrations

If user-secrets are configured for src/Govern.Api, the environment variables are not needed.

2. Review the generated Up/Down

  • Data loss: DropColumn or DropTable where you meant a rename. Fix the model (EF can't guess renames): remove the migration and hand the rename to EF with RenameColumn in a fresh migration only when necessary. Never edit the *.Designer.cs or the snapshot (a hook blocks it).
  • New non-nullable columns on existing tables: need a default or a backfill.
  • Checks:
    • indexes for new foreign keys and unique business keys
    • Down reverses Up
    • snake_case names generated by convention, not hard-coded
  • Undo a wrong migration: dotnet ef migrations remove --project src/Govern.Infrastructure --startup-project src/Govern.Api. This only works while it hasn't been applied anywhere shared.

3. Verify

  • dotnet build Govern.slnx.
  • dotnet test Govern.slnx. Integration tests apply all migrations to a fresh Postgres container at startup, so a broken migration fails there.
  • Optionally apply to the local database: run the Api (it migrates on startup) and inspect with the postgres MCP, read-only.
  • For non-trivial schema changes, run the ef-core-specialist agent.

4. Deploy note

Production applies migrations at startup (DatabaseMigrationService). For destructive or long-running changes, plan an expand/contract sequence across releases and document it in the PR.

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.