db-state-update
Skill12 starsChanged 7 days agoMITView on GitHub
ALWAYS each time you add a DB migration, right after it has been applied to the local dev DB — comment new tables/columns and regenerate docs/knowledgebase/db_state.sql
- Reads credentials
In this repository28 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- adlc-scriptingSkill
- architect-assistantSkill
- big-prod-e2e-testSkill
- ceSkill
- changelogSkill
- check-fix-buildSkill
- git-branchingSkill
- github-issuesSkill
- hook-debuggingSkill
- migrations-data-integritySkill
- morning-checkSkill
- nodejs-scriptSkill
- pocSkill
- post-impl-check-client-component-sizeSkill
- post-impl-check-cost-calc-no-autoSkill
- post-impl-check-indexesSkill
- post-impl-check-kb-actualSkill
- post-impl-check-migrationsSkill
- post-impl-check-performance-no-autoSkill
- post-impl-check-security-no-autoSkill
- security-checkSkill
- server-e2e-testsSkill
- session-kb-suggestSkill
- sql-reviewSkill
- ui-componentsSkill
- update-install-instructionsSkill
- use-playwrightSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
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
- Very specific: line 41
Keep the regenerated db_state.sql in the same change as the migration.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill 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
docs/knowledgebase/db_state.sql is the current database schema as plain DDL with light comments —
the KB's answer to "what does the DB look like now". It is generated, never hand-edited, and must
name the latest migration in its header. Keep it in step with every new migration.
When
Each time you add a migration under server/drizzle/migrations/, once it is written, locked
(npm run migrations:lock from server/) and applied to the local dev DB without errors
(npm run migrate from server/, or the dev server's startup log). Not for a migration you only
read, and never for an already committed migration (they are immutable — see the
migrations-data-integrity skill).
Steps
- Comments in the same migration. A new table gets
COMMENT ON TABLE <t> IS '…': one line — what a row is and who writes it (service / module). A new or changed column getsCOMMENT ON COLUMN <t>.<c> IS '…'only when name and type do not explain it: discriminator values, units, what NULL means, a cached copy of other data, soft-delete or legacy flags, an id stored as text without an FK. Most columns get none. Plain English, no task ids, DD numbers or dates. Get the comments right before the firstnpm run migrations:lock: once a migration is locked and applied it is immutable, even if uncommitted, so a wrong comment is fixed by a new comments-only migration (see themigrations-data-integrityskill). - Regenerate from the repo root:
It migrates its own throw-away database (npm run db:stateloghub_db_state, next to the devDATABASE_URL) with the server'snpm run migrate, writes the DDL from the Postgres catalog and drops the database — the dev DB itself is not read or changed. Expectwrote docs\knowledgebase\db_state.sql (<latest migration tag>, N bytes). - Read the diff of
docs/knowledgebase/db_state.sql: only the tables, columns, constraints, indexes and comments your migration touched may change, and the header must name your migration. An unrelated change means the dev DB server, the generator or another uncommitted migration differs — find out why before keeping it. - Verify:
npm run db:state -- --checkprintsis up to date (<tag>). - Keep the regenerated
db_state.sqlin the same change as the migration. If the migration also changes a cross-table rule (cascade, soft delete, scoping, a derived table), updatedocs/knowledgebase/db-tables.mdtoo.
If it fails
DATABASE_URL is not set— set it in the env orserver/.env(any role allowed to create a database on the dev Postgres).npm run migrate failed— the migration itself does not apply on a clean database; fix the migration first (output is in the error).- A stale
loghub_db_statedatabase left by an interrupted run is dropped by the next run.
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.

