agentleFS
LeanMeanCleanAppsLeanMeanCleanApps/CleanModelContextProtocol/.agents/skills/database-migrations/SKILL.md

database-migrations

Skill1 starsChanged 6 days agoMITView on GitHub

How to change the data model and add an EF Core migration for the SQLite database, including the namespace, folder and naming fixes the tools need. Use when adding a column, table, index or relationship.

52 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use deployment-patterns, postgres-patterns and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • royaluniondesign-sysSkill

    deployment-patterns

    Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.

    Also in 6 projects that use this

  • nek1987Skill

    postgres-patterns

    PostgreSQL patterns for reviewing migrations and writing efficient queries. Use when reviewing Alembic migrations, optimizing queries, or debugging database issues.

    Also in 7 projects that use this

  • nek1987Skill

    redis-patterns

    Upstash Redis patterns for caching and rate limiting.

    Also in 3 projects that use this

  • HABUBUSSSkill

    backend-patterns

    Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.

    Also in 9 projects that use this

  • seikaikyoSkill

    fastapi-patterns

    FastAPI + SQLModel + Neon PostgreSQL 後端開發最佳實踐。適用於 Render 部署的 API 服務。涵蓋路由設計、資料庫操作、錯誤處理、認證授權。

    Also in 3 projects that use this

  • SentrySkill

    react-testing

    Write and review React/TypeScript tests for Sentry's frontend using Jest and React Testing Library. Use when adding or editing tests in static/ (*.spec.tsx), writing component/hook tests, mocking API responses with MockApiClient, testing routing or network requests, or when asked to "write a frontend test", "add a React test", "test this component", or "fix a flaky RTL test".

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 48 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add the migration from the repository root:

    line 18
  2. Very specific:

    Check where the files landed.

    line 27
  3. Very specific:

    Update MovieReviewsDbContextExtensions.AddData and the test data if the new column needs a value (sample-data).

    line 37
  4. Very specific:

    Check nothing is left over with dotnet ef migrations has-pending-model-changes --project ./src/Infrastructure, then run every test project.

    line 38
  5. Very specific:

    Call EnsureCreated() anywhere.

    line 43
  6. Very specific:

    Use ValueGeneratedOnAdd() on DateCreated or DateModified.

    line 44
  7. Very specific:

    Add data annotations like [Required] or [MaxLength] to models.

    line 45

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

The rule

The schema comes only from migrations in src/Infrastructure/Databases/MovieReviews/Migrations. The app applies pending migrations at startup in InitialiseInfrastructure(), and the tests build their databases from the same migrations, so a model change without a migration fails the tests. MovieReviewsDbContextFactory lets the EF Core tools create the context at design time.

Steps

  1. Change the database model in Models/ and its configuration in Configuration/. Relationships, keys, indexes and collations are configured with the fluent API in an EntityConfiguration<T> subclass. Text people search or sort by uses UseCollation(Collations.NoCase), and columns we sort or filter by get a HasIndex.
  2. Install the tool once: dotnet tool install --global dotnet-ef.
  3. Add the migration from the repository root:

    dotnet ef migrations add <Name> \
      --project ./src/Infrastructure \
      --output-dir Databases/MovieReviews/Migrations \
      --namespace CleanModelContextProtocol.Infrastructure.Databases.MovieReviews.Migrations
  4. Check where the files landed. If MovieReviewsDbContextModelSnapshot.cs was written somewhere else or in another namespace, move it into Migrations/ and fix its namespace.
  5. Strip the byte order mark the tool adds, so dotnet format and the diff stay clean, and make sure the migration file starts with // <auto-generated /> so the analysers skip it. The tool adds that line to the .Designer.cs file but not always to the migration itself:

    sed -i '1s/^\xEF\xBB\xBF//' src/Infrastructure/Databases/MovieReviews/Migrations/*.cs
  6. Rename both files and the [Migration] attribute to <yyyyMMdd>000000_<Name>, so the id is the day it was written and not the second you ran the tool.
  7. Name the migration for what it does (AddReviewComment), in PascalCase.
  8. Update MovieReviewsDbContextExtensions.AddData and the test data if the new column needs a value (sample-data).
  9. Check nothing is left over with dotnet ef migrations has-pending-model-changes --project ./src/Infrastructure, then run every test project. Migrations are excluded from coverage.

Don't

  • Edit a migration that has already been released. Add a new one.
  • Call EnsureCreated() anywhere. It skips migrations.
  • Use ValueGeneratedOnAdd() on DateCreated or DateModified. SQLite then tries to insert NULL into a NOT NULL column; the repository sets both.
  • Add data annotations like [Required] or [MaxLength] to models. Configure in Configuration/.

Check

dotnet build
dotnet test
dotnet format --verify-no-changes

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.