feat: add replica identity on tables without primary key#1237
Conversation
WalkthroughThe pull request bumps the minimal schema version from 48 to 49 and adds a new SQL migration script that adds missing primary keys to three tables (transactions, accounts, logs) using their existing indexes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal/storage/bucket/migrations/45-add-replica-identity/up.sql`:
- Around line 6-17: The loop over _system.ledgers is unnecessary; remove the FOR
loop and its body and instead set the search_path once and execute the three
ALTER TABLE statements exactly once: ALTER TABLE transactions REPLICA IDENTITY
USING INDEX transactions_ledger, ALTER TABLE accounts REPLICA IDENTITY USING
INDEX accounts_ledger, and ALTER TABLE logs REPLICA IDENTITY USING INDEX
logs_ledger; remove references to vsql and the loop (FOR ledger ... END LOOP) so
the statements run only a single time in this migration.
internal/storage/bucket/migrations/45-add-replica-identity/up.sql
Outdated
Show resolved
Hide resolved
4fc1c9c to
e507fa3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@internal/storage/bucket/migrations/45-add-replica-identity/up.sql`:
- Line 3: The migration uses a session-level "set search_path = '{{ .Schema
}}';" which can leak into subsequent migrations; change it to use "SET LOCAL
search_path = '{{ .Schema }}';" so the search_path change is scoped to the
current DO block/transaction. Locate the "set search_path" statement in the
migration (up.sql) and replace it with the local-scoped variant to prevent
session leakage when the connection is reused.
internal/storage/bucket/migrations/45-add-replica-identity/up.sql
Outdated
Show resolved
Hide resolved
e507fa3 to
a1edee8
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1237 +/- ##
==========================================
+ Coverage 74.63% 82.22% +7.59%
==========================================
Files 198 198
Lines 10410 10224 -186
==========================================
+ Hits 7769 8407 +638
+ Misses 1512 1325 -187
+ Partials 1129 492 -637 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a1edee8 to
62e7a63
Compare
62e7a63 to
2f91490
Compare
No description provided.