fix(db): fail boot loudly on legacy single-tenant audit_log schema (#4919) - #5035
Open
yippietheproducer wants to merge 1 commit into
Open
fix(db): fail boot loudly on legacy single-tenant audit_log schema (#4919)#5035yippietheproducer wants to merge 1 commit into
yippietheproducer wants to merge 1 commit into
Conversation
…lock#4919) A legacy audit_log (pre multi-tenant rewrite) has no community_id column, so every audit write ERRORs with `column "community_id" does not exist` while the relay keeps serving traffic — a tamper-evident audit chain silently stops recording in production, and the per-event ERROR line is easy to miss. The legacy->multi-tenant cutover is deliberately an operator script (scripts/cutover/1321_backfill_default_community.sql), not startup migration state, so instead of a (stance-rejected) 0028 migration this adds a startup preflight that detects the legacy shape and fails the boot loudly with the operator path. Runs on both the migrating and non-migrating startup paths. The check is a live table-shape probe, not a _sqlx_migrations version check: affected deployments reached this state with no migration record of audit_log at all (the table predates the migration chain), so no version predicate would catch them. Covered by a DB-backed regression test (fresh schema passes, legacy shape blocks with an actionable message, absent table passes). Signed-off-by: mmaciejek <chacinskimaciej@gmail.com>
yippietheproducer
force-pushed
the
pr/4919-audit-preflight
branch
from
August 6, 2026 10:17
0924218 to
94f0e8a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4919.
Problem
A legacy single-tenant
audit_log(pre multi-tenant rewrite) has nocommunity_idcolumn, so every audit write errors withcolumn "community_id" does not existwhile the relay keeps servingtraffic — a tamper-evident audit chain silently stops recording in
production, and the per-event ERROR line is easy to miss.
The legacy→multi-tenant cutover is deliberately an operator script
(
scripts/cutover/1321_backfill_default_community.sql), not startupmigration state (see the stance in
crates/buzz-db/src/migration.rsandthe discussion in the issue), so a
0028migration was not the fix.Fix
Adds
reject_legacy_audit_log_shape()— a startup preflight that detectsthe legacy shape and fails the boot loudly with the operator path,
instead of the silent per-event ERROR spam.
run_migrations) and non-migrating(
main.rs,BUZZ_AUTO_MIGRATEdefaults to off) startup paths._sqlx_migrationsversioncheck: affected deployments reached this state with no migration record
of
audit_logat all, so no version predicate would have caught them.reject_legacy_nip_rs_cardinality_ambiguityfail-closed preflight in the same file.
Verification
cargo check -p buzz-db -p buzz-relay— clean, zero warningswith an actionable message naming
community_id+ the cutover path,absent table passes)
buzz-dbDB-backed suite: 152 passed / 2 failed — the 2 failures(
relay_membersowner-limit tests) are pre-existing, reproduced on theclean tree without this change