celestial-skills / database-migrations-engineering
AGENTS.md1 starsChanged 18 days agoApache-2.0View on GitHub
Change the schema in small expand-then-contract steps that old and new code can both run against, so deploys never need downtime or a frantic rollback.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository182 other files it gives its agents.
- skills/accessibility-audit-engineering/AGENTS.mdAGENTS.md
- skills/angular-app-engineering/AGENTS.mdAGENTS.md
- skills/aspnet-core-api-engineering/AGENTS.mdAGENTS.md
- skills/chrome-extension-engineering/AGENTS.mdAGENTS.md
- skills/ci-cd-pipelines-engineering/AGENTS.mdAGENTS.md
- skills/code-review-engineering/AGENTS.mdAGENTS.md
- skills/compose-android-app-engineering/AGENTS.mdAGENTS.md
- skills/context-engineering-engineering/AGENTS.mdAGENTS.md
- skills/dbt-analytics-engineering/AGENTS.mdAGENTS.md
- skills/dependency-supply-chain-engineering/AGENTS.mdAGENTS.md
- skills/deprecation-and-removal-engineering/AGENTS.mdAGENTS.md
- skills/design-tokens-to-code-engineering/AGENTS.mdAGENTS.md
- skills/django-app-engineering/AGENTS.mdAGENTS.md
- skills/end-to-end-testing-engineering/AGENTS.mdAGENTS.md
- skills/expo-react-native-app-engineering/AGENTS.mdAGENTS.md
- skills/fastapi-service-engineering/AGENTS.mdAGENTS.md
- skills/fastify-api-engineering/AGENTS.mdAGENTS.md
- skills/feature-flags-engineering/AGENTS.mdAGENTS.md
- skills/flutter-app-engineering/AGENTS.mdAGENTS.md
- skills/framework-upgrades-engineering/AGENTS.mdAGENTS.md
- skills/git-workflow-engineering/AGENTS.mdAGENTS.md
- skills/go-http-service-engineering/AGENTS.mdAGENTS.md
- skills/graphql-api-engineering/AGENTS.mdAGENTS.md
- skills/incident-response-engineering/AGENTS.mdAGENTS.md
- skills/incremental-implementation-engineering/AGENTS.mdAGENTS.md
- skills/internationalisation-engineering/AGENTS.mdAGENTS.md
- skills/kubernetes-helm-engineering/AGENTS.mdAGENTS.md
- skills/laravel-app-engineering/AGENTS.mdAGENTS.md
- skills/launch-readiness-engineering/AGENTS.mdAGENTS.md
- skills/llm-features-and-evals-engineering/AGENTS.mdAGENTS.md
- skills/marketing-site-engineering/AGENTS.mdAGENTS.md
- skills/nestjs-service-engineering/AGENTS.mdAGENTS.md
- skills/nextjs-app-engineering/AGENTS.mdAGENTS.md
- skills/nuxt-app-engineering/AGENTS.mdAGENTS.md
- skills/observability-engineering/AGENTS.mdAGENTS.md
- skills/privacy-by-design-engineering/AGENTS.mdAGENTS.md
- skills/python-ml-service-engineering/AGENTS.mdAGENTS.md
- skills/rails-app-engineering/AGENTS.mdAGENTS.md
- skills/react-web-app-engineering/AGENTS.mdAGENTS.md
- skills/release-and-versioning-engineering/AGENTS.mdAGENTS.md
- skills/requirements-interview-engineering/AGENTS.mdAGENTS.md
- skills/rest-api-design-engineering/AGENTS.mdAGENTS.md
- skills/rust-axum-service-engineering/AGENTS.mdAGENTS.md
- skills/rust-cli-tool-engineering/AGENTS.mdAGENTS.md
- skills/safe-refactoring-engineering/AGENTS.mdAGENTS.md
- skills/secure-code-review-engineering/AGENTS.mdAGENTS.md
- skills/source-grounded-development-engineering/AGENTS.mdAGENTS.md
- skills/spec-before-code-engineering/AGENTS.mdAGENTS.md
- skills/spec-driven-development-engineering/AGENTS.mdAGENTS.md
- skills/spring-boot-service-engineering/AGENTS.mdAGENTS.md
- skills/sveltekit-app-engineering/AGENTS.mdAGENTS.md
- skills/swiftui-ios-app-engineering/AGENTS.mdAGENTS.md
- skills/systematic-debugging-engineering/AGENTS.mdAGENTS.md
- skills/task-breakdown-engineering/AGENTS.mdAGENTS.md
- skills/tauri-desktop-app-engineering/AGENTS.mdAGENTS.md
- skills/technical-documentation-engineering/AGENTS.mdAGENTS.md
- skills/terraform-infrastructure-engineering/AGENTS.mdAGENTS.md
- skills/test-first-development-engineering/AGENTS.mdAGENTS.md
- skills/threat-modelling-engineering/AGENTS.mdAGENTS.md
- skills/typescript-library-engineering/AGENTS.mdAGENTS.md
- The first 60 shown.
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
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
- Distinctive: line 25
Never rename or drop a column in the same deploy as the code that stops using it.
- Distinctive: line 28
Every foreign key and every column in a frequent WHERE or ORDER BY has a supporting index checked with the query plan.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — Database schema and safe migrations
Change the schema in small expand-then-contract steps that old and new code can both run against, so deploys never need downtime or a frantic rollback.
How to do it
- Design the target schema — Write the end state: tables, columns with types and nullability, primary and foreign keys, unique constraints and the indexes each query needs. Check every new query plan against realistic data volume.
- Split into expand and contract — Plan the change as phases that each deploy separately. Expand: add new tables, nullable columns or new indexes without removing anything. Migrate: backfill data and switch code to read and write the new shape. Contract: remove the old column, table or code path only once nothing uses it.
- Make each migration compatible with the running code — Before merging, confirm the currently deployed application version works against the post-migration schema, and the new application version works against the pre-migration schema. If either fails, split the change further.
- Avoid locking operations — Create indexes concurrently or online where the database supports it, add constraints as not-valid then validate separately, add columns without volatile defaults, and set a lock timeout on every migration so it fails fast instead of queueing traffic.
- Backfill in batches — Move data with an idempotent job that processes bounded batches by primary key, sleeps between batches, records progress and can resume. Never backfill a large table in one transaction inside the migration.
- Rehearse on production-sized data — Run the migration against a recent anonymised copy or staging database of similar size. Record duration and lock waits; anything over a few seconds of exclusive lock needs redesign.
- Ship with a rollback path — Each expand step has a down migration or is harmless to leave in place. Contract steps that drop data run only after a backup is confirmed and after the release using the new shape has been stable for an agreed period.
- Verify after deploy — Check error rates, slow-query logs and row counts between old and new columns. Close the contract phase with a ticket so old columns do not linger forever.
Checklist (before a pull request)
- Change is split into expand, migrate and contract phases, each deployable alone
- Old and new application versions both run against the migrated schema
- No migration takes a long exclusive lock; lock timeout is set
- Indexes are created concurrently or online
- Backfills run in resumable batches outside the migration transaction
- Migration was rehearsed on production-sized data with timing recorded
- Destructive steps wait for a confirmed backup and a stable release
Rules
- Never rename or drop a column in the same deploy as the code that stops using it. (The old code is still running during the rollout and will fail.)
- Migrations are forward-only files in version control, applied by the deploy pipeline, never edited after merge. (Editing an applied migration makes environments disagree about the schema.)
- Enforce integrity in the database with constraints and foreign keys, not only in application code. (Every client and script that touches the data gets the same guarantees.)
- Every foreign key and every column in a frequent WHERE or ORDER BY has a supporting index checked with the query plan. (Missing indexes are invisible on small data and fatal at scale.)
- Set a lock timeout and statement timeout on migration sessions. (A migration that waits for a lock blocks every query queued behind it.)
Checks
| Gate | Tool | Threshold | When |
| Migration safety check | Migration linter for the database (for example squawk for PostgreSQL) + test run of up and down migrations | No locking or destructive operations flagged without an approved exception; up and down both succeed in CI | Every pull request containing a migration |
Generated from the Celestial engineering practice “Database schema and safe migrations”.
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
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.

