Skip to content

Commit aef12cf

Browse files
OAGrclaude
andcommitted
fix(ci): exclude adding-foreign-key-constraint squawk rule
Drizzle's migrator runs all statements in a single transaction, making the two-step NOT VALID / VALIDATE pattern (squawk's recommended fix for adding-foreign-key-constraint) impossible. Excluded the rule with the same justification as the existing exclusions for require-concurrent-index-creation and constraint-missing-not-valid. agent_sessions is a small table (~hundreds of rows) so the brief SHARE ROW EXCLUSIVE lock during migration is acceptable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 89a36e8 commit aef12cf

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.squawk.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ pg_version = "16"
2222
# by ensuring migrations only run once.
2323
#
2424
# require-concurrent-index-creation, disallowed-unique-constraint, constraint-missing-not-valid,
25-
# adding-not-nullable-field:
25+
# adding-not-nullable-field, adding-foreign-key-constraint:
2626
# Drizzle's migrator runs ALL statements in a single transaction (see pg-core/dialect.js
27-
# line 60). CREATE INDEX CONCURRENTLY cannot run inside a transaction, so these online-safe
28-
# patterns are impossible with Drizzle. Tables are small (~700 rows) so brief locking is
29-
# acceptable. If large-table migrations are needed in the future, use a separate raw SQL
30-
# runner outside Drizzle.
27+
# line 60). CREATE INDEX CONCURRENTLY cannot run inside a transaction, and the NOT VALID
28+
# two-step pattern for FK constraints requires two separate transactions — both impossible
29+
# with Drizzle. Tables are small (hundreds of rows) so brief locking is acceptable.
30+
# If large-table migrations are needed in the future, use a separate raw SQL runner
31+
# outside Drizzle (see .claude/rules/database-migrations.md for the manual migration pattern).
3132
excluded_rules = [
3233
"prefer-bigint-over-int",
3334
"prefer-identity",
@@ -38,4 +39,5 @@ excluded_rules = [
3839
"disallowed-unique-constraint",
3940
"constraint-missing-not-valid",
4041
"adding-not-nullable-field",
42+
"adding-foreign-key-constraint",
4143
]

apps/wiki-server/drizzle/0063_add_session_id_to_agent_sessions.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
-- 1. Older records predate this migration and won't have a session_id
1010
-- 2. Some agent sessions may never produce a session log (e.g., abandoned sessions)
1111
-- 3. Session logs can be created after agent sessions (at PR time)
12+
--
13+
-- Note: adding-foreign-key-constraint is excluded in .squawk.toml because Drizzle's
14+
-- migrator runs in a single transaction, making the two-step NOT VALID / VALIDATE
15+
-- pattern impossible. agent_sessions is a small table (hundreds of rows), so the
16+
-- brief SHARE ROW EXCLUSIVE lock is acceptable.
1217

1318
ALTER TABLE "agent_sessions" ADD COLUMN IF NOT EXISTS "session_id" integer REFERENCES "sessions"("id") ON DELETE SET NULL;
1419

0 commit comments

Comments
 (0)