Skip to content

fix(copilot): seq migration#4804

Merged
icecrasher321 merged 1 commit into
stagingfrom
fix/seq-mig
May 30, 2026
Merged

fix(copilot): seq migration#4804
icecrasher321 merged 1 commit into
stagingfrom
fix/seq-mig

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

seq copilot message migration error

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 30, 2026 1:48am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 30, 2026

PR Summary

Low Risk
Migration changes only add IF NOT EXISTS guards; no new billing logic in the diff, only test coverage for execution cost aggregation.

Overview
Makes migration 0219_amused_leo safe to re-run by using ADD COLUMN IF NOT EXISTS on copilot_messages.seq and CREATE INDEX IF NOT EXISTS for copilot_messages_chat_seq_idx, so a partial or retried deploy does not fail when the column or index already exists. The backfill UPDATE from copilot_chats JSON is unchanged.

Adds a calculateCostSummary regression test for three levels of nested synthetic workflow execution roots, asserting leaf agent costs are billed once, workflow roots are not charged, and the cost ledger still reconciles with totalCost.

Reviewed by Cursor Bugbot for commit c1252de. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR fixes a re-entrant migration failure for the copilot_messages.seq column by adding IF NOT EXISTS guards to both the ADD COLUMN and CREATE INDEX statements in migration 0219_amused_leo.sql. A vim swap file accidentally committed earlier is also cleaned up, and a new test covering 3-level nested workflow cost deduplication is added.

  • Migration fix: ADD COLUMN IF NOT EXISTS and CREATE INDEX IF NOT EXISTS make the migration safe to re-run if it was previously interrupted or partially applied.
  • Cleanup: packages/db/.env.swp (a vim editor swap file) is deleted from version control.
  • Test addition: A new test in logging-factory.test.ts asserts that calculateCostSummary does not double-count aggregate costs from intermediate workflow-type span nodes in a 3-deep nesting scenario.

Confidence Score: 5/5

Safe to merge — the migration change is a minimal, targeted idempotency fix and the swap file deletion is harmless cleanup.

The two SQL changes are narrow and correct: IF NOT EXISTS on ADD COLUMN prevents a duplicate-column error on re-run, and IF NOT EXISTS on CREATE INDEX prevents a duplicate-index error. The UPDATE CTE is unchanged and produces the same result on repeat executions. The new test exercises a realistic scenario and includes a ledger reconciliation check.

No files require special attention.

Important Files Changed

Filename Overview
packages/db/migrations/0219_amused_leo.sql Adds IF NOT EXISTS guards to ADD COLUMN and CREATE INDEX — the correct idempotency fix for a migration that failed on re-run.
packages/db/.env.swp Vim swap file deleted from version control — correct cleanup, no functional impact.
apps/sim/lib/logs/execution/logging-factory.test.ts Adds a 3-level nested workflow cost test; test logic is sound but the ledger reconciliation check relies on the implementation under test already being correct — if calculateCostSummary double-counts, both the cost assertion and the ledger check could pass incorrectly.

Reviews (1): Last reviewed commit: "fix(copilot): seq migration" | Re-trigger Greptile

@icecrasher321 icecrasher321 merged commit 15ca66f into staging May 30, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/seq-mig branch May 30, 2026 03:00
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.

1 participant