| 04-pdf-ingest |
01 |
database |
| drizzle |
| postgres |
| schema |
| migrations |
| seed |
| form-templates |
|
| phase |
provides |
| 03-agent-portal-shell |
documents table and portal data layer this plan extends |
|
|
| form_templates table with id (text PK), name, filename (unique), createdAt, updatedAt |
| documents table extended with formTemplateId (nullable FK) and filePath (nullable text) |
| Drizzle migration 0002 applied to local PostgreSQL |
| seeds/forms/ directory tracked via .gitkeep |
| npm run seed:forms CLI |
| reads seeds/forms/*.pdf, upserts into form_templates via onConflictDoUpdate |
|
|
|
| added |
patterns |
|
|
| DOTENV_CONFIG_PATH=.env.local prefix for tsx seed scripts (mirrors Phase 3 pattern) |
| onConflictDoUpdate on filename for idempotent form template upserts |
| formTemplates table placed above documents table in schema.ts to satisfy FK forward-reference |
|
|
| created |
modified |
| teressa-copeland-homes/scripts/seed-forms.ts |
| teressa-copeland-homes/seeds/forms/.gitkeep |
| teressa-copeland-homes/drizzle/0002_wealthy_zzzax.sql |
| teressa-copeland-homes/drizzle/meta/0002_snapshot.json |
|
| teressa-copeland-homes/src/lib/db/schema.ts |
| teressa-copeland-homes/package.json |
| teressa-copeland-homes/drizzle/meta/_journal.json |
|
|
| formTemplates table uses text PK (crypto.randomUUID()) — consistent with all other tables in schema.ts |
| seed:forms uses DOTENV_CONFIG_PATH=.env.local prefix — dotenv/config reads .env by default but project uses .env.local |
| formTemplateId and filePath are nullable — custom uploads have no template, legacy rows have no file path |
| onConflictDoUpdate on filename column — enables idempotent monthly re-run when PDFs change names |
|
| Seed scripts: DOTENV_CONFIG_PATH=.env.local npx tsx scripts/<script>.ts pattern for all future seed commands |
| Schema ordering: tables with FK references must come after the referenced table in schema.ts |
|
|
8min |
2026-03-19 |