-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: missing features migrations for existing ledgers #601
Conversation
Warning Rate limit exceeded@gfyrag has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 46 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes involve modifications to the migration logic in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
e76a66a
to
3a78184
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
internal/storage/system/migrations_test.go (1)
86-101
: Consider enhancing test coverage.While the current test verifies that features are set to DefaultFeatures after migration, it would be beneficial to also test:
- Pre-existing non-null features are preserved
- Edge cases like empty JSON objects
Here's a suggested enhancement:
var addDefaultFeatures = migrations.Hook{ + Before: func(ctx context.Context, t *testing.T, db bun.IDB) error { + // Insert test ledgers with various feature states + _, err := db.NewInsert(). + Model(&map[string]any{ + "name": "ledger_null_features", + "features": nil, + }). + TableExpr("_system.ledgers"). + Exec(ctx) + require.NoError(t, err) + + // Insert ledger with custom features + customFeatures := map[string]string{"custom": "value"} + _, err = db.NewInsert(). + Model(&map[string]any{ + "name": "ledger_custom_features", + "features": customFeatures, + }). + TableExpr("_system.ledgers"). + Exec(ctx) + require.NoError(t, err) + return nil + }, After: func(ctx context.Context, t *testing.T, db bun.IDB) { type x struct { + Name string `bun:"name"` Features map[string]string `bun:"features"` } model := make([]x, 0) err := db.NewSelect(). ModelTableExpr("_system.ledgers"). Scan(ctx, &model) require.NoError(t, err) for _, m := range model { - require.EqualValues(t, features.DefaultFeatures, m.Features) + if m.Name == "ledger_null_features" { + require.EqualValues(t, features.DefaultFeatures, m.Features) + } else if m.Name == "ledger_custom_features" { + require.EqualValues(t, map[string]string{"custom": "value"}, m.Features) + } } }, }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
internal/storage/system/migrations.go
(2 hunks)internal/storage/system/migrations_test.go
(3 hunks)
🔇 Additional comments (2)
internal/storage/system/migrations.go (1)
205-217
: LGTM! Migration looks safe and well-implemented.
The migration correctly:
- Uses transaction wrapper
- Uses parameterized query to prevent SQL injection
- Only updates null features, preserving existing configurations
- Handles errors appropriately
Let's verify the default features configuration:
✅ Verification successful
Default features configuration verified and properly used
The verification confirms that:
DefaultFeatures
is defined inpkg/features/features.go
with appropriate feature flags:- MovesHistory: "ON"
- MovesHistoryPostCommitEffectiveVolumes: "SYNC"
- HashLogs: "SYNC"
- AccountMetadataHistory: "SYNC"
- TransactionMetadataHistory: "SYNC"
The migration correctly uses this configuration to set default features for ledgers where features are null, ensuring consistent behavior across the system.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the default features configuration and its usage
# Expected: Should find references to DefaultFeatures in the codebase
# Check the DefaultFeatures definition
rg -A 5 "DefaultFeatures.*=" pkg/features/
# Check where these features are used
ast-grep --pattern 'features.DefaultFeatures'
Length of output: 40654
internal/storage/system/migrations_test.go (1)
41-41
: LGTM! Test hook properly registered.
The hook is correctly appended to the migration test sequence.
3a78184
to
83c2fe8
Compare
No description provided.