fixing duplicate migration runs for logstore - #4416
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughMigration orchestration in both ChangesMigration Orchestration and DDL/DML Hardening
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
Confidence Score: 4/5Safe to merge for correctness; the core migration-deduplication fix is sound and the configstore change is a clean extension to SQLite. The only remaining rough edge is cosmetic debug logging left in logstore's new helper. The root-cause fix is well-targeted: moving the dialect check inside the framework/logstore/migrations.go — the new Important Files Changed
Reviews (1): Last reviewed commit: "fixing duplicate migration runs for logs..." | Re-trigger Greptile |
|
|
Merge activity
|
## Summary
Removes noisy, redundant `logger.Info` calls that were logging truncated SQL statement strings immediately before executing those same statements in both `configstore` and `logstore` migration functions. Additionally, removes the Postgres-only guard from `areThereAnyPendingMigrations` in both stores so that the preflight migration check runs for all database dialects (including SQLite), aligning behavior across environments.
## Changes
- Removed ~100 `logger.Info` calls that logged partial, truncated SQL strings (e.g. `"executing ALTER TABLE config_keys ADD COLUMN name VARCHAR(255)\").Error; err != nil { retur"`) immediately before executing those statements — these logs were misleading and added no diagnostic value.
- Removed the `if db.Dialector.Name() == "postgres"` guard from `areThereAnyPendingMigrations` in `configstore/migrations.go`, making the pending-migration preflight check dialect-agnostic and consistent with the fail-open behavior already documented in the comment.
- Extracted `areThereAnyPendingMigrations` in `logstore/migrations.go` as a named function (mirroring the configstore pattern) and removed the Postgres-only guard from `triggerMigrations`, so SQLite deployments also benefit from the preflight skip and double-check-after-lock optimizations.
- Added structured logging in the logstore `areThereAnyPendingMigrations` function to enumerate each pending migration ID.
- Moved the SQLite dialect guard inside the `migrationUpdateTimestampFormat` migrate closure so the migration step is always registered but skips execution on non-SQLite dialects, keeping the migration table consistent across dialects.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI
## Affected areas
- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
```sh
go test ./framework/configstore/... ./framework/logstore/...
```
Verify that on startup with a fresh SQLite database, migrations run without errors and the migration preflight check correctly skips re-running already-applied steps. Verify the same on Postgres. Confirm that log output no longer contains truncated SQL strings prefixed with `"executing"`.
## Breaking changes
- [ ] Yes
- [x] No
## Security considerations
None. Changes are limited to migration orchestration logic and log verbosity.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable

Summary
Removes noisy, redundant
logger.Infocalls that were logging truncated SQL statement strings immediately before executing those same statements in bothconfigstoreandlogstoremigration functions. Additionally, removes the Postgres-only guard fromareThereAnyPendingMigrationsin both stores so that the preflight migration check runs for all database dialects (including SQLite), aligning behavior across environments.Changes
logger.Infocalls that logged partial, truncated SQL strings (e.g."executing ALTER TABLE config_keys ADD COLUMN name VARCHAR(255)\").Error; err != nil { retur") immediately before executing those statements — these logs were misleading and added no diagnostic value.if db.Dialector.Name() == "postgres"guard fromareThereAnyPendingMigrationsinconfigstore/migrations.go, making the pending-migration preflight check dialect-agnostic and consistent with the fail-open behavior already documented in the comment.areThereAnyPendingMigrationsinlogstore/migrations.goas a named function (mirroring the configstore pattern) and removed the Postgres-only guard fromtriggerMigrations, so SQLite deployments also benefit from the preflight skip and double-check-after-lock optimizations.areThereAnyPendingMigrationsfunction to enumerate each pending migration ID.migrationUpdateTimestampFormatmigrate closure so the migration step is always registered but skips execution on non-SQLite dialects, keeping the migration table consistent across dialects.Type of change
Affected areas
How to test
go test ./framework/configstore/... ./framework/logstore/...Verify that on startup with a fresh SQLite database, migrations run without errors and the migration preflight check correctly skips re-running already-applied steps. Verify the same on Postgres. Confirm that log output no longer contains truncated SQL strings prefixed with
"executing".Breaking changes
Security considerations
None. Changes are limited to migration orchestration logic and log verbosity.
Checklist
docs/contributing/README.mdand followed the guidelines