Conversation
WalkthroughThe migrations listener now handles a new "reset" notification prefix. Upon receiving this notification, the max_counter for the next version (lastVersion+1) is reset to 0 in the versions table. Errors from the update are logged but do not halt execution. This reset handling occurs before existing initialization logic. Changes
Sequence DiagramsequenceDiagram
participant L as Listener
participant DB as Versions Table
participant Log as Logger
L->>L: Receive notification
alt notification prefix is "reset"
L->>DB: UPDATE versions SET max_counter=0<br/>WHERE version_id=lastVersion+1
alt update succeeds
L->>Log: Log success
else update fails
L->>Log: Log error
L->>L: Continue (return nil)
end
else notification prefix is "init"
L->>L: Handle init...
else other
L->>L: Continue
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
b9a11ee to
e74070c
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
migrations/migrator.go (1)
348-357: Consider aligning the notification format with existing patterns.The "reset" prefix doesn't include a colon, while "init: " and "continue: " do. This inconsistency means "reset" will match "reset", "reset:", or "reset: anything". If the reset notification should never carry additional data, this is fine. However, for consistency and to make the intent explicit, consider using "reset:" or a more restrictive pattern.
-case strings.HasPrefix(notification.Payload, "reset"): +case notification.Payload == "reset": _, err = conn.Exec(ctx, ` update `+m.getVersionsTable()+` set max_counter = 0 where version_id = $1 `, lastVersion+1) if err != nil { logging.FromContext(ctx).Debugf("failed to reset max counter: %v", err) return nil }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
migrations/migrator.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
migrations/migrator.go (2)
logging/context.go (1)
FromContext(12-20)logging/logging.go (1)
Debugf(21-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Ci
🔇 Additional comments (1)
migrations/migrator.go (1)
348-357: Reset logic is correct for the stated purpose.The implementation correctly resets max_counter to 0 for the next migration version (lastVersion+1). The error handling is consistent with the existing "init: " case—logging at Debug level and continuing listener operation. This aligns with the PR objective of allowing recovery after restart when migrations cannot recover automatically.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #535 +/- ##
=======================================
Coverage 28.68% 28.69%
=======================================
Files 162 162
Lines 6644 6653 +9
=======================================
+ Hits 1906 1909 +3
- Misses 4622 4628 +6
Partials 116 116 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Some migrations are, sometimes, not able to recover after a restart.
The new notification payload allow to reset the counter.