Imported from vibe-code-tours/team-09-app (
.claude/skills/schema-check/SKILL.md). Install upstream withnpx skills add vibe-code-tours/team-09-app --skill schema-check. Copyright stays with the author.
Schema Check (SQLite + Drizzle)
When to Use
- After modifying Drizzle schema files
- After changing TypeScript type definitions
- Before committing database-related changes
- When investigating data inconsistencies
Instructions
-
Read the Drizzle schema:
find mhat-tan/src -name "schema.ts" -o -name "*.schema.ts" -
Read the TypeScript types:
cat mhat-tan/src/types/index.ts -
Read the V1 spec:
cat docs/mhat-tan-database-schema-v1.md -
Cross-check three sources:
Source What to check V1 spec Tables, columns, types, indexes, constraints Drizzle schema Maps 1:1 to V1 spec TypeScript types Matches Drizzle inferred types -
Run type check:
npx tsc --noEmit -
Report findings:
Output Format
Schema Validation Report
========================
Tables Check:
[PASS] users — 6 columns, 2 indexes
[PASS] categories — 12 columns, 2 indexes, 1 unique constraint
[FAIL] entries — missing `timezone` column (V1 spec requires it)
Indexes Check:
[PASS] idx_entries_user_created
[WARN] idx_entries_user_occurred — not defined in Drizzle schema
TypeScript Check:
[PASS] Entry type matches Drizzle inferred type
[FAIL] Category.type — 'expense' | 'income' in spec, but type allows 'string'
Summary: 14 passed, 1 warning, 2 failures
Auto-Fix Suggestions
For each failure, suggest the Drizzle schema change:
// Fix: Add timezone column
export const entries = sqliteTable('entries', {
// ... existing columns
timezone: text('timezone').notNull().default('Asia/Yangon'),
});
References
- Drizzle schema: https://orm.drizzle.team/docs/sql-schema-declaration
- V1 spec:
docs/mhat-tan-database-schema-v1.md - Project types:
src/types/index.ts