Skip to content

Commit b1f45aa

Browse files
PiquelChipsclaude
andcommitted
test(database): scope the purge test's foreign keys to its own schema
The audit tests migrate schemas of their own in the same database. Listing every foreign key to users across schemas raced their migrations (a half-migrated schema still has security_audit_log) and scanned every leftover schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 95aaedd commit b1f45aa

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • crates/database/src/repositories/deletions

‎crates/database/src/repositories/deletions/tests.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ async fn purge_leaves_nothing_that_references_or_identifies_the_account() {
282282
assert!(purge(&pool, user).await);
283283

284284
// Every column with a foreign key to users(id), and how many rows hold the account.
285+
// Only this schema's: audit tests migrate schemas of their own beside it.
285286
let references: Vec<(String, String, i64)> = sqlx::query_as(
286287
"SELECT
287288
source.table_name::text, source.column_name::text,
@@ -297,7 +298,8 @@ async fn purge_leaves_nothing_that_references_or_identifies_the_account() {
297298
ON target.constraint_name = r.unique_constraint_name
298299
AND target.constraint_schema = r.unique_constraint_schema
299300
AND target.ordinal_position = source.position_in_unique_constraint
300-
WHERE target.table_name = 'users' AND target.column_name = 'id'",
301+
WHERE target.table_schema = current_schema()
302+
AND target.table_name = 'users' AND target.column_name = 'id'",
301303
)
302304
.bind(user.to_string())
303305
.fetch_all(&pool)

0 commit comments

Comments
 (0)