Skip to content

fix: [#934] Modify queue database connection when installing db driver#1425

Merged
hwbrzzl merged 3 commits intomasterfrom
bowen/#934
Mar 28, 2026
Merged

fix: [#934] Modify queue database connection when installing db driver#1425
hwbrzzl merged 3 commits intomasterfrom
bowen/#934

Conversation

@hwbrzzl
Copy link
Copy Markdown
Contributor

@hwbrzzl hwbrzzl commented Mar 27, 2026

Summary

  • Queue setup now reads both queue.connections.database.connection and queue.failed.database from DB_CONNECTION, removing the hardcoded postgres behavior.
  • Database setup stubs now include DB_CONNECTION= so driver installers can persist the selected connection in .env.
  • Added modify.Env(file, key, value) to rewrite existing .env keys (including duplicates) or append missing keys, while returning os.ErrNotExist when the file is absent.

Closes #934

Why

Installing a non-PostgreSQL driver could still leave queue database settings pinned to postgres, causing workers and failed-job logging to use the wrong database connection. The setup stubs now consistently defer to DB_CONNECTION, and the generated .env template always includes that key for installer updates.

The new modify.Env helper centralizes .env rewrites in setup flows so repeated runs replace stale values instead of drifting. It also fails fast when .env is missing, giving callers a concrete setup error to handle.

envPath := filepath.Join(t.TempDir(), ".env") _ = os.WriteFile(envPath, []byte("DB_CONNECTION=postgres\nAPP_ENV=local"), 0o644) // Before fix: setup could leave queue database settings effectively pinned to postgres. // After fix: setup rewrites DB_CONNECTION to the selected driver. _ = Env(envPath, "DB_CONNECTION", "mysql").Apply()
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 27, 2026 07:42
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.20%. Comparing base (a770ad2) to head (5bd142c).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
queue/setup/stubs.go 0.00% 2 Missing ⚠️
database/setup/setup.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## master #1425 +/- ## ========================================== + Coverage 67.98% 68.20% +0.22%  ========================================== Files 354 357 +3 Lines 27521 27648 +127 ========================================== + Hits 18709 18857 +148  + Misses 7963 7940 -23  - Partials 849 851 +2 

☔ 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.
@hwbrzzl hwbrzzl merged commit 8d48d3a into master Mar 28, 2026
18 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#934 branch March 28, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant