feat(migrations): reconcile collaboration tables missed by initial-schema backfill (B3) #151
No reviewers
Labels
No labels
agent-context-drift
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rstillwell/deckhearth#151
Loading…
Reference in a new issue
No description provided.
Delete branch "convoy/reconcile-b3-collaboration-tables"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Brief 3 of
reconcile-historical-add-scripts(convoy22ebef2).Captures the DDL half of
scripts/add-collaboration-features.js(a no-go-zone historical script) that theinitial-schemabackfill missed:collection_permissions(collaboration roles + invite tokens)collection_activity(audit-trail;details JSONB)users.is_pending(invited-but-not-yet-accepted users)idx_collection_permissions_collection_id,idx_collection_permissions_user_id,idx_collection_activity_collection_id,idx_collections_visibility)lib/permission-middleware.js::withCollectionPermissionreadscollection_permissionsandlogCollectionActivitywritescollection_activity— both are runtime invariants. Prod has these surfaces from the historical script running; this migration brings fresh Neon branches to parity sonpm install→npm run setup-dbalone is sufficient onboarding.Files changed
migrations/1781000000003_reconcile-collaboration-tables.js(new, +101 LOC)Acceptance criteria
1781000000003CREATE TABLE IF NOT EXISTS(2x),ADD COLUMN IF NOT EXISTS(1x),CREATE INDEX IF NOT EXISTS(4x)ON DELETE CASCADEoncollection_id/user_id;ON DELETE SET NULLoncollection_activity.user_id; bareREFERENCES users(id)oninvited_by)roleandstatusmatch the historical scriptUNIQUE(collection_id, user_id)andUNIQUEoninvite_tokenpreserveddetails JSONBper.cursor/rules/schema-map.mdcdown()is a hard-stub throw matchinginitial-schema.js's patternTest plan
node --check migrations/1781000000003_*.js→ exit 0npm run lint→ 0 errors (1 pre-existing baseline warning unchanged)npm run test:run→ 131/131 pass (no fixture breakage; tests don't exercise these tables directly)grep -r "collection_permissions\|collection_activity\|is_pending\|idx_collection_permissions\|idx_collection_activity\|idx_collections_visibility" migrations/returns only this new fileNotes for reviewer
idx_collections_visibilityreferencescollections.visibility, which B2 (reconcile-collections-columns, timestamp1781000000002) adds. Atnpm run migrate uptime the timestamps enforce ordering (B2 < B3 → B2 runs first), so this is satisfied. The architect's plan allocated all 4 historical-script indexes to B3; per the convoy's D7 "Audited ordering risks" B3 was listed as depending oncollections+usersonly, but thevisibilitycolumn dependency is implicit in the index. Worth a glance — if B2 is delayed/reordered, B3 would fail to apply on a partial-state env. Acceptable risk: timestamps are immutable and B1-B5 are siblings landing intomain.details JSONBruntime shape.lib/permission-middleware.js::logCollectionActivitywrites${JSON.stringify(details)}into the column, matching the JSONB type declared here.collectionsandusersare created by1779853647564_initial-schema;cards/ scan tables / etc. are not referenced by this migration. No FK ordering bug.Made with Cursor
The latest updates on your projects. Learn more about Vercel for GitHub.
Pipeline Health
Build + CI gates
Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).
Role reports
See individual comments above for details. This rollup updates automatically.