Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/todo-seed-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore(todo): fix two app-todo defects found driving it end-to-end — (1) `todo_task.owner` was a lookup to `user`, which isn't a registered object, so seed/owner resolution hit "no such table: user" (the platform user object is `sys_user`); (2) the two `completed` seed tasks omitted `completed_date`, violating the object's own `completed_date_required` validation, so they silently failed to seed (6 of 8 rows loaded). Repointed the lookup to `sys_user`, dropped the unresolvable `owner: 'admin'` seed value, and gave completed seeds a `completed_date`. Now all 8 rows seed; validation still rejects a completed task with no date. Example-app only.
21 changes: 13 additions & 8 deletions examples/app-todo/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ import { Task } from '../objects/task.object';
const tasks = defineSeed(Task, {
mode: 'upsert',
externalId: 'subject',
// NOTE: `owner` is a lookup to `sys_user`; there's no stable seed key for the
// bootstrap admin (created by auth), so it's left unset rather than pointing
// at a non-existent 'admin'. Completed tasks MUST carry `completed_date` — the
// object's `completed_date_required` validation rejects the row otherwise
// (this is why the two completed seeds previously failed to load).
records: [
{ subject: 'Learn ObjectStack', status: 'completed', priority: 'high', category: 'work', owner: 'admin' },
{ subject: 'Build a cool app', status: 'in_progress', priority: 'normal', category: 'work', owner: 'admin', due_date: cel`daysFromNow(3)` },
{ subject: 'Review PR #102', status: 'completed', priority: 'high', category: 'work', owner: 'admin' },
{ subject: 'Write Documentation', status: 'not_started', priority: 'normal', category: 'work', owner: 'admin', due_date: cel`daysFromNow(1)` },
{ subject: 'Fix Server bug', status: 'waiting', priority: 'urgent', category: 'work', owner: 'admin' },
{ subject: 'Buy groceries', status: 'not_started', priority: 'low', category: 'shopping', owner: 'admin', due_date: cel`today()` },
{ subject: 'Schedule dentist appointment',status: 'not_started', priority: 'normal', category: 'health', owner: 'admin', due_date: cel`daysFromNow(7)` },
{ subject: 'Pay utility bills', status: 'not_started', priority: 'high', category: 'finance', owner: 'admin', due_date: cel`daysFromNow(2)` },
{ subject: 'Learn ObjectStack', status: 'completed', priority: 'high', category: 'work', completed_date: cel`daysAgo(2)` },
{ subject: 'Build a cool app', status: 'in_progress', priority: 'normal', category: 'work', due_date: cel`daysFromNow(3)` },
{ subject: 'Review PR #102', status: 'completed', priority: 'high', category: 'work', completed_date: cel`daysAgo(1)` },
{ subject: 'Write Documentation', status: 'not_started', priority: 'normal', category: 'work', due_date: cel`daysFromNow(1)` },
{ subject: 'Fix Server bug', status: 'waiting', priority: 'urgent', category: 'work' },
{ subject: 'Buy groceries', status: 'not_started', priority: 'low', category: 'shopping', due_date: cel`today()` },
{ subject: 'Schedule dentist appointment',status: 'not_started', priority: 'normal', category: 'health', due_date: cel`daysFromNow(7)` },
{ subject: 'Pay utility bills', status: 'not_started', priority: 'high', category: 'finance', due_date: cel`daysFromNow(2)` },
],
});

Expand Down
6 changes: 4 additions & 2 deletions examples/app-todo/src/objects/task.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export const Task = ObjectSchema.create({
readonly: true,
}),

// Assignment
owner: Field.lookup('user', {
// Assignment — the platform user object is `sys_user` (better-auth managed);
// `user` is not a registered object/table, so the old reference resolved to
// a non-existent `user` table at seed/lookup time ("no such table: user").
owner: Field.lookup('sys_user', {
label: 'Assigned To',
}),

Expand Down