Skip to content

OUT-3645: add pending_action tombstone columns#104

Merged
SandipBajracharya merged 1 commit into
feature/refresh-sync-OUT-3645from
OUT-3645-pr1-migration
May 25, 2026
Merged

OUT-3645: add pending_action tombstone columns#104
SandipBajracharya merged 1 commit into
feature/refresh-sync-OUT-3645from
OUT-3645-pr1-migration

Conversation

@SandipBajracharya
Copy link
Copy Markdown
Collaborator

Summary

  • Adds pending_action, pending_action_target, pending_action_attempts, pending_action_last_attempt_at, pending_action_last_error columns to file_folder_sync via an additive Drizzle migration.
  • CHECK constraint file_folder_sync_pending_action_target_consistency enforces that pending_action and pending_action_target are both set or both null — prevents application bugs from creating half-set rows the sweeper can't process.
  • New TypeScript enums PendingAction ('delete' | 'create' | 'update') and PendingActionTarget ('assembly' | 'dropbox') in src/db/constants.ts. Postgres enum type names are pending_action_enum / pending_action_target_enum (suffix differentiates them from the column names).
  • Observation-only: nothing reads or writes the new columns yet. Subsequent PRs in the OUT-3645 series will populate them from per-file handlers and act on them from the resync sweeper.
  • Also gitignores docs/ to keep design specs and plans out of the repo.

Why this lives behind a feature branch

This is PR 1 of a multi-PR rollout (feature/refresh-sync-OUT-3645). Future PRs will target the same feature branch:

  • PR 2: tombstone-writing in delete/update handlers
  • PR 3: scheduled Trigger.dev task replacing the existing cron + sweeper service extension
  • PR 4: UI endpoint + channel-level Resync button
  • PR 5: Assembly→Dropbox create pre-insert (closes the create-failure gap)

Test plan

  • Inspect the migration SQL — confirm two CREATE TYPEs (with _enum suffix), five ALTER TABLE ADD COLUMNs with correct nullability/defaults, and the ADD CONSTRAINT line.
  • Run pnpm typecheck — should exit 0.
  • Run pnpm lint — should exit 0.
  • Apply the migration on a non-prod DB (or wait for the preview deploy) and verify with \d file_folder_sync that the five columns and the CHECK constraint exist.
  • On the same DB, sanity-check the constraint by attempting INSERT INTO file_folder_sync (..., pending_action) VALUES (..., 'delete') — expect a constraint violation.
  • Confirm no existing code paths reference the new columns (this PR is observation-only by design).

🤖 Generated with Claude Code

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 22, 2026

OUT-3645

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dropbox-integration Ready Ready Preview, Comment May 22, 2026 11:00am

Request Review

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 22, 2026

Greptile Summary

This PR adds five pending_action_* columns to file_folder_sync via an additive Drizzle migration, introduces PendingAction and PendingActionTarget TypeScript enums, and wires a CHECK constraint enforcing that pending_action and pending_action_target are always co-null. The change is observation-only; no application code reads or writes the new columns yet.

  • Migration creates two new Postgres enum types (pending_action_enum, pending_action_target_enum), five ALTER TABLE ADD COLUMN statements, and a consistency CHECK constraint — all additive and backward-compatible with live rows.
  • The CHECK constraint is now correctly reflected in both the Drizzle schema (check() in the table config callback) and the Drizzle snapshot checkConstraints block, so future drizzle-kit generate runs will track and preserve it.
  • The previous review concern about the constraint being invisible to Drizzle has been fully addressed in this PR.

Confidence Score: 5/5

Safe to merge — purely additive schema change with no reads or writes of the new columns in this PR.

All five new columns are nullable or carry safe defaults, existing rows are unaffected, and the CHECK constraint is correctly tracked by both the raw SQL migration and the Drizzle schema+snapshot so future migrations won't drop it. The change introduces no new code paths.

No files require special attention. The migration SQL is straightforward and self-consistent with the Drizzle schema and snapshot.

Important Files Changed

Filename Overview
src/db/migrations/20260522104036_add_pending_action_columns_to_file_folder_sync.sql Additive migration: two new enum types, five new nullable/defaulted columns, and a co-null CHECK constraint. Missing trailing newline at EOF.
src/db/schema/fileFolderSync.schema.ts Drizzle schema updated with new enum types and five columns; CHECK constraint correctly added via check() in table config callback and reflected in the snapshot.
src/db/constants.ts Adds PendingAction and PendingActionTarget TypeScript enums with matching values to SQL enum types; value types derived correctly.
src/db/migrations/meta/20260522104036_snapshot.json Snapshot includes checkConstraints for the new consistency CHECK, new enum entries, and all five new columns — consistent with the schema and migration.
src/db/migrations/meta/_journal.json Journal entry added correctly as idx 11, tag and timestamp match the migration file name.
.gitignore Adds docs/ to gitignore to exclude design specs; previously reviewed trailing-slash convention note already left as a thread comment.

Entity Relationship Diagram

%%{init: {'theme': 'neutral'}}%%
erDiagram
    file_folder_sync {
        uuid id PK
        varchar portal_id
        uuid channel_sync_id FK
        object_types object
        pending_action_enum pending_action "nullable"
        pending_action_target_enum pending_action_target "nullable"
        integer pending_action_attempts "DEFAULT 0 NOT NULL"
        timestamptz pending_action_last_attempt_at "nullable"
        text pending_action_last_error "nullable"
    }
    pending_action_enum {
        string delete
        string create
        string update
    }
    pending_action_target_enum {
        string assembly
        string dropbox
    }
    file_folder_sync }o--|| pending_action_enum : "pending_action"
    file_folder_sync }o--|| pending_action_target_enum : "pending_action_target"
Loading

Reviews (2): Last reviewed commit: "feat(OUT-3645): add pending_action tombs..." | Re-trigger Greptile

Comment thread src/db/schema/fileFolderSync.schema.ts Outdated
Comment on lines 16 to 36
@@ -22,6 +27,11 @@ export const fileFolderSync = pgTable('file_folder_sync', {
contentHash: varchar(),
dbxFileId: varchar(),
assemblyFileId: uuid(),
pendingAction: PendingActionEnum(),
pendingActionTarget: PendingActionTargetEnum(),
pendingActionAttempts: integer().notNull().default(0),
pendingActionLastAttemptAt: timestamp({ withTimezone: true, mode: 'date' }),
pendingActionLastError: text(),
...timestampsWithSoftDelete,
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 CHECK constraint invisible to Drizzle — will be dropped on next migration

The file_folder_sync_pending_action_target_consistency CHECK constraint is only declared in the raw SQL migration, not in the Drizzle schema definition. The snapshot's checkConstraints for file_folder_sync is therefore {}. When a future PR runs drizzle-kit generate, Drizzle will diff the schema (no constraint) against the database (constraint present) and emit a DROP CONSTRAINT statement, silently removing the guard.

Add the constraint to the table definition using Drizzle's check() and regenerate the snapshot so Drizzle tracks the constraint going forward.

Comment thread .gitignore Outdated
# Sentry Config File
.env.sentry-build-plugin

docs No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Using docs without a trailing slash matches both a file and a directory named docs. Adding the trailing slash makes the intent explicit (ignore only the docs/ directory) and follows the conventional .gitignore style for directories.

Suggested change
docs
docs/

Additive migration. Adds pending_action, pending_action_target,
pending_action_attempts, pending_action_last_attempt_at, and
pending_action_last_error columns plus a CHECK constraint enforcing
that pending_action and pending_action_target are both set or both
null. Also gitignores docs/ for spec and plan artifacts.

Subsequent PRs populate these columns from per-file handlers and read
from the resync sweeper. PR 1 is observation-only — no code reads or
writes the new columns yet.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@SandipBajracharya
Copy link
Copy Markdown
Collaborator Author

@greptileai

@SandipBajracharya SandipBajracharya changed the title feat(OUT-3645): add pending_action tombstone columns OUT-3645: add pending_action tombstone columns May 22, 2026
@SandipBajracharya SandipBajracharya merged commit d75d5a1 into feature/refresh-sync-OUT-3645 May 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants