fix: use DB_SCHEMA for Oban tables - #3826
Conversation
| @@ -0,0 +1,114 @@ | |||
| defmodule Logflare.ObanSchemaMigrationTest do | |||
There was a problem hiding this comment.
test repo would already have migrations run against it, so this test module is redundant.
can instead do the following:
- change application config for db schema in test setup
- provision the schema and run the migration
- assert that the oban tables are created in the randomized schema.
- assert no public tables created.
There was a problem hiding this comment.
The CI setup runs mix ecto.setup before the test suite, so public.oban_jobs already exists when this test starts. For the "assert no public tables created" step, would you prefer that we snapshot and assert the existing public Oban tables/jobs remain unchanged, or temporarily remove and restore the public Oban structures around this test?
| def up, do: Oban.Migration.up(version: 12, prefix: oban_prefix()) | ||
| def down, do: :ok | ||
|
|
||
| defp oban_prefix, do: System.get_env("DB_SCHEMA", "public") |
There was a problem hiding this comment.
should not use env var directly, should reference the db schem via application config with get_env
| def up, do: Oban.Migration.up(version: 12, prefix: oban_prefix()) | ||
| def down, do: Oban.Migration.down(version: 1, prefix: oban_prefix()) | ||
|
|
||
| defp oban_prefix, do: System.get_env("DB_SCHEMA", "public") |
There was a problem hiding this comment.
shoudl not use env var directly
| enable_alerting? = Env.get_boolean("LOGFLARE_ALERTS_ENABLED", true) | ||
|
|
||
| config :logflare, Oban, | ||
| prefix: System.get_env("DB_SCHEMA", "public"), |
There was a problem hiding this comment.
can bind as module variable and reference for both db config and oban config.
| | `DB_PASSWORD` | String, defaults to `nil` | Password for Logflare's internal PostgreSQL database connection. | | ||
| | `DB_POOL_SIZE` | Integer, defaults to `10` | Overrides the Ecto connection pool size for Logflare's internal PostgreSQL database connection. | | ||
| | `DB_SCHEMA` | String, defaults to `nil` | Allows configuration of the database schema to scope Logflare operations. | | ||
| | `DB_SCHEMA` | String, defaults to `nil` | Allows configuration of the database schema to scope Logflare operations, including Oban jobs. Defaults to the `public` schema when unset. When upgrading an existing installation, Oban structures are created in the configured schema, but existing jobs and Oban objects in `public` are not copied or removed automatically. Stop all Logflare nodes before manually migrating jobs that must be preserved. | |
There was a problem hiding this comment.
We can move the upgrade note to a an Upgrading section with a version number + date.
There was a problem hiding this comment.
Which release version should the new Upgrading section use? I can date the note 2026-08-14, but I don't want to guess the target release version.
Summary
DB_SCHEMA, falling back topublicpublicduring upgradesFixes #3251
Testing
mix test test/logflare/oban_schema_migration_test.exs --trace(2 tests, 0 failures)mix format --check-formattedmix credogit diff --check