Skip to content
Back to skills

Database Change

ASecurity

Change the Postgres schema of this repo with Drizzle. Use when adding or changing a table, column, index or constraint in src/server/db/schema, or when writing or reviewing a migration in drizzle/.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 26, 2026
ai-agentssqldatabase

Security analysis

A100/100

Scanned October 26, 2026

npx -y skills add TiagoGranelli/slopproof --skill database-change --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database Change?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Database Change
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tiagogranelli-database-change/badge)](https://www.skillsdirectory.com/skills/tiagogranelli-database-change)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: database-change
description: Change the Postgres schema of this repo with Drizzle. Use when adding or changing a table, column, index or constraint in src/server/db/schema, or when writing or reviewing a migration in drizzle/.
---

# Database change

## Steps

1. Edit `src/server/db/schema/*.ts`. `src/server/db/schema/auth.ts` is application code: edit it by hand and
   keep timestamps `timestamptz` (the `auth-change` skill says how to find what Better Auth needs). An id column
   carries its brand from `src/contract/ids.ts`: `uuidv7Id().$type<PostId>()` for the table's own id, and
   `authorId()` is already a `UserId`. A foreign key to another table gets `.$type<ThatId>()` too.
2. Run `pnpm db:generate --name <slug>`. It writes a new SQL file and updates `drizzle/meta/`.
3. Review the new SQL in `drizzle/`. Only this new file may be adjusted by hand, and only before it is
   committed. A type change that must convert data gets its `USING` clause there, as in
   `0004_auth_timestamptz.sql`. An index on a large table is built by hand `CONCURRENTLY`
   ([docs/operations.md](../../../docs/operations.md#migration-safety)).
4. Apply it: `pnpm db:up`, then `pnpm db:migrate`.
5. Run `pnpm check:drift migrations` and `pnpm check:migrations` (squawk: no statement that blocks a busy
   table). Waive one statement only with `-- squawk-ignore <rule>` under a comment line giving the reason.
6. A new or changed repository query gets a query budget in `tests/db/<feature>-query-budget.test.ts`, then
   `pnpm test:db` (read `tests/db/AGENTS.md`).

## Rules

- Migrations already in the journal at `HEAD` are frozen: databases may have applied them, so
  `tests/unit/repo-policy.test.ts` rejects an edit. Change the schema and generate a new migration instead.
- `drizzle/meta/**` is written by `pnpm db:generate` only.

## Done when

`pnpm check:drift migrations`, `pnpm check:migrations`, `pnpm check:drift database` (needs Postgres) and
`pnpm check` pass, and the schema, the SQL file and `drizzle/meta/` are in one commit.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.