Skip to content

feat(server): kysely infrastructure setup + 4 repo migrations#1787

Open
Falinor wants to merge 7 commits into
mainfrom
feat/kysely-setup
Open

feat(server): kysely infrastructure setup + 4 repo migrations#1787
Falinor wants to merge 7 commits into
mainfrom
feat/kysely-setup

Conversation

@Falinor

@Falinor Falinor commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Install kysely + kysely-codegen; generate DB types into db.d.ts (51 tables, snake_case)
  • Configure .kysely-codegenrc.json with camelCase: false to use snake_case column names matching actual database schema
  • Add Nx codegen target (depends on migrate) to server/project.json
  • Implement Kysely transaction infrastructure (kysely-transaction.ts): startKyselyTransaction, getKyselyTransaction, withinKyselyTransaction using AsyncLocalStorage — mirrors existing transaction.ts pattern
  • Migrate settingsRepository, resetLinkRepository, signupLinkRepository, precisionRepository to Kysely with snake_case column names
  • Keep *DBO type exports as aliases for Selectable<DB[...]> for backward compat with callers
  • Add integration tests for the three repos that had none (settings, resetLink, signupLink)
  • Mock ceremaService in signupLinkController.test.ts to enable tests

Test plan

  • yarn nx test server passes (1038 tests passing, 2 unrelated failures in user-api.test.ts)
  • yarn nx run-many -t typecheck passes
  • settingsRepository.test.ts: findOne and upsert (including conflict update)
  • resetLinkRepository.test.ts: insert, get, used
  • signupLinkRepository.test.ts: insert, get, getByEmail, used
  • precisionRepository.test.ts: link (replaces, removes), linkMany (replaces across housings)

🤖 Generated with Claude Code

Falinor and others added 6 commits April 24, 2026 10:29
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…support

Replace Knex query builder with Kysely for find/link/linkMany operations.
Re-export legacy Knex accessors (Precisions, HousingPrecisions) and the
snake_case HousingPrecisionDBO type for backward compatibility with seeds
and other test files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tristanrobert

tristanrobert commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sonarqubecloud

Copy link
Copy Markdown

Override PG DATE columns (birth_date, start_date, end_date, dpe_date_at)
to return "YYYY-MM-DD" strings via a pg type parser, avoiding the day-shift
that occurs when node-postgres constructs a Date in the local timezone (CET).

The hand-maintained db-types.ts layer sits on top of the auto-generated
db.d.ts so re-running kysely-codegen never overwrites the corrections.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@Falinor Falinor self-assigned this Jun 11, 2026
@Falinor Falinor added enhancement New feature or request refactor labels Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants