test(integration): add otherField column to protect-ci fixture#403
test(integration): add otherField column to protect-ci fixture#403
Conversation
The supabase test suites (packages/protect/__tests__/supabase.test.ts, packages/stack/__tests__/supabase.test.ts) write a non-encrypted 'otherField' text column to 'protect-ci' that PR #400's union schema missed. Add it to all three CREATE TABLE IF NOT EXISTS bodies (drizzle plus the two supabase suites). Add an ALTER TABLE ADD COLUMN IF NOT EXISTS so long-lived CI databases — where CREATE TABLE IF NOT EXISTS is a no-op — get the column backfilled the next time any suite runs.
|
📝 WalkthroughWalkthroughThree test fixture files across the drizzle, protect, and stack packages are updated to add an ChangesTest Fixture Schema Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/drizzle/__tests__/drizzle.test.ts (1)
125-143: ⚡ Quick winConsider centralizing the shared
protect-ciDDL into a single helper.This PR exists precisely because the union schema DDL was kept in sync manually across three files and a column was missed in one of them (PR
#400). Extracting theCREATE TABLE IF NOT EXISTS+ALTER TABLE ADD COLUMN IF NOT EXISTSblock into a shared test-fixture helper (e.g.,packages/test-helpers/setupProtectCi.ts) would make any future column addition a one-line change and eliminate drift by construction.💡 Suggested approach
// packages/test-helpers/setupProtectCi.ts (new file) + import postgres from 'postgres' + + export async function setupProtectCiTable(databaseUrl: string): Promise<void> { + const sql = postgres(databaseUrl, { prepare: false }) + try { + await sql` + CREATE TABLE IF NOT EXISTS "protect-ci" ( + id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY, + email eql_v2_encrypted, + age eql_v2_encrypted, + score eql_v2_encrypted, + profile eql_v2_encrypted, + encrypted eql_v2_encrypted, + "otherField" TEXT, + created_at TIMESTAMPTZ DEFAULT NOW(), + test_run_id TEXT + ) + ` + await sql`ALTER TABLE "protect-ci" ADD COLUMN IF NOT EXISTS "otherField" TEXT` + } finally { + await sql.end() + } + }Each
beforeAllwould then callawait setupProtectCiTable(process.env.DATABASE_URL as string)instead of inlining the DDL.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/drizzle/__tests__/drizzle.test.ts` around lines 125 - 143, Extract the duplicated CREATE TABLE IF NOT EXISTS / ALTER TABLE ADD COLUMN IF NOT EXISTS block into a single test helper (e.g., export async function setupProtectCiTable(databaseUrl: string) in packages/test-helpers/setupProtectCi.ts) and replace the inlined SQL in packages/drizzle/__tests__/drizzle.test.ts (and the other two test files that currently inline the same DDL) with a call to await setupProtectCiTable(process.env.DATABASE_URL as string); ensure the helper opens a DB client, runs the CREATE TABLE and ALTER TABLE statements exactly as before, and closes the client so adding future columns is a single change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/drizzle/__tests__/drizzle.test.ts`:
- Around line 125-143: Extract the duplicated CREATE TABLE IF NOT EXISTS / ALTER
TABLE ADD COLUMN IF NOT EXISTS block into a single test helper (e.g., export
async function setupProtectCiTable(databaseUrl: string) in
packages/test-helpers/setupProtectCi.ts) and replace the inlined SQL in
packages/drizzle/__tests__/drizzle.test.ts (and the other two test files that
currently inline the same DDL) with a call to await
setupProtectCiTable(process.env.DATABASE_URL as string); ensure the helper opens
a DB client, runs the CREATE TABLE and ALTER TABLE statements exactly as before,
and closes the client so adding future columns is a single change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 064444ce-0a59-4e79-81cb-6e1688a99d90
📒 Files selected for processing (3)
packages/drizzle/__tests__/drizzle.test.tspackages/protect/__tests__/supabase.test.tspackages/stack/__tests__/supabase.test.ts
Summary
Test plan
Summary by CodeRabbit