Skip to content

feat: add replica identity on tables without primary key#1237

Merged
gfyrag merged 1 commit intomainfrom
fix/replica-identity
Feb 3, 2026
Merged

feat: add replica identity on tables without primary key#1237
gfyrag merged 1 commit intomainfrom
fix/replica-identity

Conversation

@gfyrag
Copy link
Contributor

@gfyrag gfyrag commented Jan 23, 2026

No description provided.

@gfyrag gfyrag requested a review from a team as a code owner January 23, 2026 08:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

The 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

Cohort / File(s) Summary
Schema Version Update
internal/storage/bucket/default_bucket.go
Incremented MinimalSchemaVersion constant from 48 to 49 to reflect the new baseline schema requirement.
Primary Key Migration
internal/storage/bucket/migrations/45-fix-missing-primary-keys/up.sql
New migration script that adds primary keys to transactions, accounts, and logs tables by promoting existing indexes as the respective primary keys.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops and wiggles with glee,
Primary keys found—one, two, three!
From forty-eight to forty-nine we leap,
Database integrity, databases keep. 🔐

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions 'replica identity' but the actual changes involve adding primary keys via migrations and updating the schema version constant, not replica identity configuration. Update the title to reflect the actual changes, such as 'feat: add primary keys to tables using existing indexes' or 'chore: update minimal schema version to 49'.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the purpose of the schema migration, why primary keys are being added, and how it relates to the minimal schema version bump.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/replica-identity

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

@gfyrag gfyrag force-pushed the fix/replica-identity branch from 4fc1c9c to e507fa3 Compare January 23, 2026 09:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

@gfyrag gfyrag force-pushed the fix/replica-identity branch from e507fa3 to a1edee8 Compare January 23, 2026 09:20
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.22%. Comparing base (1cfd498) to head (2f91490).
⚠️ Report is 6 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gfyrag gfyrag enabled auto-merge January 27, 2026 11:36
Azorlogh
Azorlogh previously approved these changes Jan 28, 2026
@gfyrag gfyrag force-pushed the fix/replica-identity branch from 62e7a63 to 2f91490 Compare February 3, 2026 08:22
@gfyrag gfyrag added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit a2b701e Feb 3, 2026
13 of 14 checks passed
@gfyrag gfyrag deleted the fix/replica-identity branch February 3, 2026 09:45
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.

3 participants