Plans005 2026 02 20 Operational Database
Completed
- T-001: Scaffold @packages/db package
- T-002: schema/core.ts
- T-003: schema/db.ts
- T-004: schema/catalog.ts
- T-005: schema/commerce.ts and schema/finance.ts
- T-006: schema/marketing.ts
- T-007: schema/target.ts
- T-008: Package index
- T-009: bun install + type-check
- T-010: Generate and apply migrations
- T-011: Update AGENTS.md
- T-012: Verify @services/dashboard can import @packages/db
In Progress
- None
Blocked
- None
Pending
- None
Learnings
- Drizzle push duplicated unique index creation against existing local baseline; removing inline .unique() and using uniqueIndex() in table-level third argument stabilized push.
- ON CONFLICT clause in LibSQL raw SQL requires column-level UNIQUE, not a named index — upsertRows in seed.ts was updated to conflict on
id(PK) instead. - ensureTables() in the old sync seed.ts was redundant once @packages/db manages schema via Drizzle — removed.
- seed.ts migrated to @packages/db using Drizzle ORM; @packages/sync now re-exports from @packages/db. Schema authority is consolidated in @packages/db.
- 14 unique indexes applied across all lookup tables; atlas-ops.db wiped and re-pushed cleanly with 37 tables.
Questions
- None
Next
- Optional: add @packages/db as a dev dep to @packages/sync and remove the remaining @libsql/client direct usage in sync (now only used in xlsx.ts duck path, not seeding)