# CLAUDE.md — `web/migrations/`

D1 schema migrations for the `one-owners` database. Sequential numbered SQL files.

## Ordering rule

Migrations run in filename order. **Never renumber or reorder existing files.** New migrations get the next number (`0083_*.sql`, `0084_*.sql`, ...).

## Schema drift hazard

After a `DROP COLUMN` + `ALTER TABLE ADD COLUMN` migration, grep `src/` for the old column name before deploying. TypeScript can't catch D1 schema drift — the error appears at runtime as `no such column`. This has burned us before (`0059_domains.sql` renamed `slug` → `gid`; call sites were missed).

## Apply locally

```bash
bun run db:migrate:local   # from one.ie/web/
```

Note: the script's hardcoded range is stale (last checked at 0035–0045). Widen the range in `package.json` if you need to apply migrations beyond it.

## See also

- `web/CLAUDE.md` — commands + D1 binding names
- `web/src/lib/substrate.ts` — runtime D1 usage
