Skip to content

fix(db): give push-managed databases the bytewise order_key collation - #10372

Merged
waleedlatif1 merged 1 commit into
stagingfrom
ci/flake-sweep
Nov 24, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
ci/flake-sweep

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • ignored-columns.integration.ts ("a batch insert names each dropped key once, in the order first sent") failed on 5 of the last 40 staging validations, every time on an integration (push, …) shard. Rows came back out of insertion order
  • Cause: migration 0228 makes user_table_rows.order_key COLLATE "C", so fractional keys (base-62, mixed case) compare bytewise as the library mints them. schema.ts can't express a column collation, so databases built by db:push (local, dev, and the push CI path) kept the default en_US.UTF-8, which orders lowercase before uppercase. appendKeys mints keys with random bits, so some batches sort out of order there
  • apply-dev-table-triggers.ts, which db:push already runs to give push-managed databases the migration-only SQL for user_table_rows, now also sets the collation. It runs only when the column isn't already "C", so a migrated database (staging, prod) is untouched, and a rerun doesn't rebuild the index. It runs between dropping and recreating the update trigger, since that trigger's WHEN reads order_key
  • writes.integration.ts no longer works around the gap with ORDER BY order_key COLLATE "C". Its new case asserts 'Zz' sorts before 'a0', as it does bytewise
  • schema.ts's comment now points at where push-managed databases get the collation

Type of Change

  • Bug fix

Testing

  • Local Postgres provisioned like CI's push shards (extensions + db:push). Before the fix, order_key had no collation and the new test failed (['a0','Zz']); after, collation C and both writes.integration.ts and ignored-columns.integration.ts pass (112/112)
  • ignored-columns.integration.ts passed 10/10 consecutive runs on the push-provisioned database
  • Rerunning the script leaves the order-key index untouched (same OID) and all three user_table_rows triggers in place
  • packages/db/scripts/push.integration.ts 19/19
  • biome, check:comment-hygiene

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 24, 2026 7:06pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Makes push-managed databases use the same bytewise order_key comparisons as migrated databases.

  • Push-managed tables now sort rows by their fractional keys.

No actionable issues found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "fix(db): give push-managed databases the..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 5bef3d8 into staging Nov 24, 2026
74 checks passed
@waleedlatif1
waleedlatif1 deleted the ci/flake-sweep branch November 24, 2026 19:10

This branch was previously deployed

1 inactive deployment
Preview — 10824c74 Deployed Nov 24, 2026 by vercel[bot]
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