You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/pages/.beans/pages-jgc4--d1-schema-and-q...

1.4 KiB

title status type priority created_at updated_at parent blocked_by
D1 schema and query layer completed feature normal 2026-07-13T02:09:08Z 2026-07-13T02:57:07Z pages-77lk
pages-saom

migrations/schema.sql exactly per design doc §4.2 (users, sessions, pages). src/db.rs (wasm-only): thin typed wrappers over worker d1 — upsert_user_on_login(github_id, login, avatar_url, admin_login_match) handling ADMIN_GITHUB_LOGIN auto-promotion (design §2.4), get_user_by_session(token_hash) with expiry check, create_session/delete_session, list_pages (join owner login), get_page, count_pages_for_user, insert_page (surface PK conflict as typed NameTaken error), delete_page, list_users, set_can_upload. Row structs with serde.

  • migrations/schema.sql
  • src/db.rs typed query layer
  • wasm32 check + clippy pass; native suite unaffected

Summary of Changes

migrations/schema.sql (idempotent, indexed) + src/db.rs typed D1 query layer (wasm-only), by a Sonnet agent. Opus review: REQUEST-CHANGES then fixed:

  • BLOCKER: session expiry compare now normalizes both sides via datetime() (lexicographic ISO-T/Z trap removed); create_session param/doc contract fixed.
  • NIT: NameTaken detection tightened to 'unique' matches only (real FK on pages.owner_id would have misclassified as 409). Validation green on both targets; native suite unaffected (72 tests + 4 doctests).