- Rewrote Drizzle schema: 20 tables with enums, relations, indexes - Generated migration with DROP TABLE records (v1 EAV removal) - Added passkey auth routes (register/login) - Added requireWorkspaceAccess helper - Added seedDefaultData for Personal workspace + welcome note - Updated SSE endpoint for v2 entities + workspace_id filtering - Created recordActivity helper (insert + pg_notify) - Updated sidebar: Graph replaces Reports, removed Analytics - Updated command palette for v2 entities - Created AGENTS.md with locked contract - Created llm-wiki scaffold (5 stubs) - Added inline AGENT INSTRUCTION comments to all 50 API route files - Fixed globals.css border-border class conflict - Updated database.ts stub for v1 compatibility
34 lines
1.3 KiB
Markdown
34 lines
1.3 KiB
Markdown
# Data Model
|
|
|
|
## Entity Relationship Overview
|
|
|
|
- **domains** — Workspaces (parent_id=null) and sub-groups
|
|
- **tasks** — Rich task model with subtasks, dependencies, time tracking
|
|
- **habits** — Habit tracking with streaks, mood, reminders
|
|
- **projects** — Projects with sections (milestones)
|
|
- **notes** — Markdown notes with wikilinks and backlinks
|
|
- **tags** — Universal tags with entity scoping and hierarchy
|
|
- **activity_feed** — Append-only audit log
|
|
- **scheduled_jobs** — Recurring task/habit spawning
|
|
- **jobs** — Worker queue
|
|
- **webhooks** — Registered webhook endpoints
|
|
|
|
## Key Design Decisions
|
|
|
|
- Soft-delete via `deleted_at` on all user data tables
|
|
- UUID primary keys with `gen_random_uuid()`
|
|
- Text enums via `pgEnum` for status/priority/type fields
|
|
- JSONB for flexible data (custom_fields, changes, payload)
|
|
- All entities scoped to a workspace via `domain_id` or `workspace_id`
|
|
|
|
## Junction Tables
|
|
|
|
- task_tags, habit_tags, note_tags, project_tags — many-to-many entity↔tag
|
|
- task_dependencies — task dependency graph
|
|
- note_links — wikilink/backlink connections
|
|
- note_entity_links — cross-entity linking (note → task/habit/project)
|
|
|
|
## Indexes
|
|
|
|
Every FK column and frequently filtered column has an index. See `packages/db/src/schema.ts` for the full list.
|