Skip to content

Conversation

@pedroscosta
Copy link
Contributor

@pedroscosta pedroscosta commented Nov 15, 2025

This PR aims to improve the docs (the SQL schema example) and fix Kysely tests.

The issue was in the keyHash column, it was created as key_hash. Even though this can be fixed in user land (using apiKeyColumns options), it should have working default example.


Summary by cubic

Fixed Kysely tests by renaming the API key column from key_hash to "keyHash" in SQL examples and test schema. This aligns the docs with the default column name so users don’t need custom apiKeyColumns.

  • Bug Fixes
    • Updated README SQL: api_keys table and index use "keyHash".
    • Updated test schema: apikey table and indexes use "keyHash".

Written for commit b417c5e. Summary will update automatically on new commits.

Summary by CodeRabbit

Refactor

  • Updated database schema for API keys table, adopting camelCase naming convention for consistency, with corresponding index and test fixture updates.

@vercel
Copy link

vercel bot commented Nov 15, 2025

@pedroscosta is attempting to deploy a commit to the Databuddy Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 15, 2025

Walkthrough

The pull request renames the database column key_hash to "keyHash" (with quoted identifiers) in the apikey table. All references to this column are updated across the schema documentation and test files, including table definitions and index creation statements.

Changes

Cohort / File(s) Summary
Schema & Documentation Updates
README.md
Updated SQL schema sample to rename apikey table column from key_hash to "keyHash" (with quoted identifiers); updated index creation to reference the new column name
Test Suite Updates
src/storage/kysely.test.ts
Updated Kysely test setup to reflect the column rename from key_hash to "keyHash"; updated table definition and index creation in test configuration

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify all references to the renamed column are consistently updated across both files
  • Confirm that quoted identifier "keyHash" is correctly applied in SQL contexts (schema, migrations, index definitions)
  • Cross-check that test assertions and record property accesses use the new column name

Possibly related PRs

Poem

🐰 A hop, a skip, a column rename,
From snake_case to camelCase we came!
Through tests and docs, the changes flow,
"keyHash" now leads the way we go! 🔑

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: renaming key_hash to keyHash in kysely schema and tests, which aligns with the PR objectives and file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f40a588 and b417c5e.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • src/storage/kysely.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{ts,tsx,js,jsx}: Don't use consecutive spaces in regular expression literals
Don't use the comma operator
Avoid functions exceeding configured Cognitive Complexity
Don't use unnecessary boolean casts
Don't use unnecessary callbacks with flatMap
Prefer for...of statements over Array.forEach
Don't create classes that only have static members
Don't use this and super in static contexts
Don't use unnecessary catch clauses
Don't use unnecessary constructors
Don't use unnecessary continue statements
Don't export empty modules
Don't use unnecessary escape sequences in regex literals
Don't use unnecessary labels
Don't use unnecessary nested block statements
Don't rename imports/exports/destructured assignments to the same name
Avoid unnecessary string or template literal concatenation
Don't use String.raw in template literals without escapes
Don't use useless case statements in switch
Avoid ternary operators when simpler alternatives exist
Don't use useless this aliasing
Don't initialize variables to undefined
Don't use the void operator
Prefer arrow functions over function expressions
Use Date.now() for epoch milliseconds
Prefer .flatMap() over map().flat() when possible
Use literal property access instead of computed when possible
Don't use parseInt/Number.parseInt for binary, octal, or hex literals
Use optional chaining instead of chained logical expressions
Prefer regex literals over RegExp constructor when possible
Don't use non-decimal or underscored number literal member names
Remove redundant terms from logical expressions
Use while loops when for initial/update are not needed
Don't reassign const variables
Don't use constant expressions in conditions
Avoid Math.min/Math.max to clamp when result is constant
Don't return a value from a constructor
Don't use empty character classes in regex literals
Don't use empty destructuring patterns
Don't call global object properties as functions
Don't declare functions/vars that escape their block (use block scoping prop...

Files:

  • src/storage/kysely.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{ts,tsx}: Don't use the arguments object
Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use any or unknown as type constraints
Don't return a value from a function with return type void
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Don't export imported variables
Don't add type annotations to variables/params/class properties initialized with literal expressions
Don't use TypeScript namespaces
Don't use non-null assertions with ! postfix
Don't use parameter properties in class constructors
Don't use user-defined types (type aliases) where discouraged
Prefer as const over literal types/type annotations for literals
Use either T[] or Array consistently
Initialize each enum member value explicitly
Use export type for types
Use import type for types
Ensure all enum members are literal values
Don't use const enum
Don't declare empty interfaces
Don't let variables evolve into any through reassignments
Don't use the any type
Don't misuse non-null assertion operator in TS files
Don't use implicit any in variable declarations
Don't merge interfaces and classes unsafely
Place overload signatures adjacent to each other
Use namespace keyword instead of module to declare TS namespaces
Don't use void type outside generics or return types

Files:

  • src/storage/kysely.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Don't nest describe() blocks too deeply in test files
Don't use callbacks in asynchronous tests and hooks
Don't have duplicate hooks in describe blocks
Don't use export or module.exports in test files
Don't use focused tests
Ensure assertions (e.g., expect) are placed inside an it() call
Don't use disabled tests

Files:

  • src/storage/kysely.test.ts
**/*.{jsx,tsx,js,ts}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

**/*.{jsx,tsx,js,ts}: Ensure preconnect is used with Google Fonts
Use a recommended display strategy with Google Fonts

Files:

  • src/storage/kysely.test.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)

Don't import next/document outside of pages/_document.jsx

Files:

  • src/storage/kysely.test.ts
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Prefer Bun.file over node:fs readFile/writeFile

Files:

  • src/storage/kysely.test.ts
🧬 Code graph analysis (1)
src/storage/kysely.test.ts (1)
src/drizzle/db.ts (1)
  • db (5-12)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
src/storage/kysely.test.ts (1)

49-63: LGTM! Column rename is correctly implemented.

The schema changes correctly rename key_hash to "keyHash" using quoted identifiers to preserve case sensitivity in PostgreSQL. This aligns the database column name with the TypeScript field naming convention and should resolve the test failures.

Minor consideration: The index names still use snake_case (e.g., apikey_key_hash_idx) while the column is now camelCase. This is functionally fine but could optionally be updated for naming consistency (e.g., apikey_keyHash_idx). However, since index names are internal identifiers and the functional behavior is correct, this is purely a stylistic consideration.

README.md (1)

589-597: LGTM! Documentation updated to match the corrected schema.

The SQL schema example correctly reflects the column rename from key_hash to "keyHash", ensuring users implement the schema that matches the Kysely tests and TypeScript interface expectations. The use of quoted identifiers properly preserves case sensitivity in PostgreSQL.

This aligns with the changes in src/storage/kysely.test.ts, maintaining consistency between the documentation and the test setup.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant