Skip to content

fix: use AutoMigrate and add runner_id/created_by_user_id columns to sidekiq table migration#5085

Open
BearTS wants to merge 1 commit into
devfrom
07-10-fix_migration_for_sidekiq
Open

fix: use AutoMigrate and add runner_id/created_by_user_id columns to sidekiq table migration#5085
BearTS wants to merge 1 commit into
devfrom
07-10-fix_migration_for_sidekiq

Conversation

@BearTS

@BearTS BearTS commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

The migrationAddSidekiqTable function previously used CreateTable for non-MySQL/PostgreSQL dialects, which would fail if the table already existed. This PR switches to AutoMigrate for the fallback dialect path and adds explicit column addition handling for runner_id and created_by_user_id on existing TableSidekiqJob tables.

Changes

  • Replaced tx.Migrator().CreateTable() with tx.Migrator().AutoMigrate() in the default dialect fallback branch so the migration is idempotent and won't hard-fail on pre-existing tables.
  • Added addColumnIfNotExists calls for runner_id and created_by_user_id columns to ensure existing sidekiq_jobs tables receive the new columns without requiring a full table recreation.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Run the migration against an environment with a pre-existing sidekiq_jobs table (missing runner_id and created_by_user_id columns) and verify the migration completes without error and the new columns are present.

go test ./framework/configstore/...

Verify that after migration:

  • The sidekiq_jobs table still exists with all original data intact.
  • The runner_id and created_by_user_id columns are present.

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

Related issues

N/A

Security considerations

No security implications. This change only affects database schema migration logic.

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

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e0e76577-4dfc-4a07-a85d-193886ac31cc

📥 Commits

Reviewing files that changed from the base of the PR and between c846c5d and 6e98b85.

📒 Files selected for processing (1)
  • framework/configstore/migrations.go
📝 Walkthrough

Walkthrough

The Sidekiq table migration now uses AutoMigrate for the default dialect path and idempotently adds the runner_id and created_by_user_id columns after dialect-specific table creation.

Changes

Sidekiq migration

Layer / File(s) Summary
Ensure Sidekiq table schema
framework/configstore/migrations.go
The default migration path uses AutoMigrate, then ensures runner_id and created_by_user_id exist with idempotent column creation.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR does not address Files API support and instead changes sidekiq migration logic, so it misses the direct issue's objective. Update the PR to implement Files API support for providers like OpenAI or Anthropic, or retarget it to a matching issue and remove the migration work.
Out of Scope Changes check ⚠️ Warning The sidekiq migration fix is unrelated to the linked Files API support issue, so the changes are out of scope for the stated objective. Split the sidekiq migration fix into a separate PR or change the linked issue to match the migration work.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main migration change and matches the code changes.
Description check ✅ Passed The description follows the template well and covers summary, changes, testing, and required sections.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-10-fix_migration_for_sidekiq

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

BearTS commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@BearTS BearTS marked this pull request as ready for review July 10, 2026 06:36
@BearTS BearTS changed the title fix: migration for sidekiq fix: use AutoMigrate and add runner_id/created_by_user_id columns to sidekiq table migration Jul 10, 2026
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
framework/configstore/migrations.go Updates the Sidekiq migration to use AutoMigrate for fallback dialects, add new columns to existing tables, and make rollback less destructive for pre-existing tables.

Reviews (2): Last reviewed commit: "fix: migration for sidekiq" | Re-trigger Greptile

Comment thread framework/configstore/migrations.go
Comment thread framework/configstore/migrations.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@framework/configstore/migrations.go`:
- Around line 10479-10484: Update the migration’s rollback logic associated with
the Sidekiq table creation to avoid unconditionally dropping an existing table.
Track whether the migration created sidekiq, and only execute the drop when it
did; otherwise preserve the table and its data, or explicitly mark/document the
migration as non-rollbackable.
- Around line 10473-10484: In the migration switch’s default branch, return
immediately after the fallback
`tx.Migrator().AutoMigrate(&tables.TableSidekiqJob{})` succeeds (while
propagating errors), preventing execution from falling through to
`tx.Exec(createTable)` and index creation with an empty statement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 00a47dc7-6e6a-4ea3-921c-a927ba61fed2

📥 Commits

Reviewing files that changed from the base of the PR and between 3fbd9a4 and c846c5d.

📒 Files selected for processing (1)
  • framework/configstore/migrations.go

Comment thread framework/configstore/migrations.go Outdated
Comment thread framework/configstore/migrations.go Outdated
@BearTS BearTS force-pushed the 07-10-fix_migration_for_sidekiq branch from c846c5d to 6e98b85 Compare July 10, 2026 07:11
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.

1 participant