feat(api)!: retire DAO-API drafts + migrate to User API#2046
Conversation
Drafts are now owned by the User API (user-scoped, session-authenticated),
so the DAO APIs no longer serve them. Removes the /{dao}/proposal/drafts*
routes and their controller/service/repository/mappers, the `general`
schema wiring (pgGeneralClient + boot migration) and its drizzle config,
and drops all Draft* symbols from the regenerated @anticapture/client
(fetchers, hooks, MCP tools, models) — breaking for external SDK consumers.
The physical general.proposal_drafts table is intentionally left in each
DAO database for the one-shot migration; a later PR drops it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copies general.proposal_drafts rows from a DAO database into the User API drafts table, preserving ids (share links keep resolving) and timestamps, lowercasing the author into author_address, and leaving user_id NULL so the row is claimed on that wallet's first SIWE login. Idempotent via ON CONFLICT DO NOTHING (also resolves cross-DAO id collisions — first writer wins), validates rows, and supports --dry-run. Run once per DAO source db. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
🎨 UI Review
This PR is a backend-only cutover: it removes the draft-proposal routes/controller/service/repository/mappers from The Out of scope for a UI review; no findings to report. Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 550b982440
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| title: row.title, | ||
| discussionUrl: row.discussionUrl, | ||
| body: row.body, | ||
| actions: row.actions, |
There was a problem hiding this comment.
Validate draft actions before migrating
If any legacy row has non-array JSON in actions (the source column is plain jsonb, so the database does not enforce the old API's array schema), this copies it into the User API even though DraftResponseSchema later parses actions as an array. That makes the migrated draft fail response validation and return a 500 on GET /drafts/{id}/list instead of being counted as invalid during the migration.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cdeb3ab2ef
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "@anticapture/api": minor | ||
| "@anticapture/gateful": minor |
There was a problem hiding this comment.
Mark removed REST routes as major
Because this commit removes /{dao}/proposal/drafts* from the DAO API and therefore from Gateful's OpenAPI surface, keeping @anticapture/api and @anticapture/gateful at minor lets release automation publish a non-breaking version even though REST clients calling those endpoints will fail after deploy. Please make these package changesets major as well; the generated client is already correctly marked major.
Useful? React with 👍 / 👎.
Summary
The cutover that retires draft proposals from the DAO APIs now that the User API owns them (stacked on #2044 backend and #2045 frontend). Two coordinated commits:
/{dao}/proposal/drafts*routes + controller/service/repository/mappers, thegeneralPostgres schema wiring (pgGeneralClient+ boot migration + drizzle config), and regenerates@anticapture/clientwith everyDraft*symbol gone (fetchers, hooks, MCP tools, models). Gateful needs no code change; its spec loses the routes on redeploy.apps/user-api/scripts/migrate-drafts.ts) — copiesgeneral.proposal_draftsfrom a DAO database into the User APIdraftstable.Migration behaviour
ids verbatim → existing share links (?draftId=…) keep resolving.user_id NULL) with the author wallet inauthor_address; the User API attaches them to a user on that wallet's first SIWE login (already implemented inDraftsService.listForUser).ON CONFLICT DO NOTHING, so re-runs are safe and cross-DAO id collisions resolve first-writer-wins (logged as skipped).--dry-run. Run once per DAO source database:Safety
general.proposal_draftstable is left intact in each DAO database (no drop migration generated) so the migration can read it. A follow-up drops it after migration is verified.@anticapture/clientis a major bump — the dashboard already stopped importing them (feat(dashboard): platform accounts — sign-in modal (SIWE/email/Google) + drafts on the User API #2045), so nothing in-repo breaks (dashboard typecheck green against the regenerated client).Verification
apps/api: typecheck + lint clean; offchain tests updated (they incidentally spread thegeneralschema).apps/user-api: 19 tests green incl. 5 new migration tests (unclaimed copy, idempotency, malformed-row skip, dry-run, claim-on-first-login); typecheck clean.@anticapture/client: regenerated, built, typechecks; 0Draft*symbols remain.apps/dashboard: typecheck green against the draftless client.Rollout order
Deploy #2044 + #2045 → run this migration (
--dry-runfirst) per DAO db → merge/deploy this PR (route removal) → later: drop the orphanedgeneral.proposal_draftstables.Refs DEV-978, DEV-979.
🤖 Generated with Claude Code