Skip to content

feat: Kysely adapter (@rafters/ledger/kysely) #15

@ssilvius

Description

@ssilvius

Goal

Add a Kysely ORM adapter alongside the existing Drizzle adapter. Kysely is the ORM better-auth uses internally, making this a native integration path.

Blocked by: better-auth 1.6 upgrade evaluation (may change the integration surface)

Subpath Exports

Subpath What
./kysely Adapter barrel
./kysely/schema/sqlite Audit log table definition (Kysely createTable)
./kysely/schema/pg PostgreSQL variant
./kysely/schema/mysql MySQL variant
./kysely/soft-delete/sqlite Soft-delete column helpers
./kysely/soft-delete/pg PG variant
./kysely/soft-delete/mysql MySQL variant

Adapter Must Implement

  • Query filters: notDeleted, onlyDeleted, includingDeleted (Kysely query builder)
  • Automatic soft-delete: interceptor that converts delete to update
  • Audit logging: insert audit entries via Kysely
  • Audit query: getRecordHistory via Kysely
  • GDPR purge: purgeUserData via Kysely query builder
  • Schema definitions: audit log table per dialect

Design Constraints

  • Core types, context, pure helpers come from @rafters/ledger (no duplication)
  • Follow the same pattern as src/drizzle/ -- same file structure, same exports shape
  • Kysely is an optional peer dependency
  • Tests in test/kysely/ mirroring test/drizzle/

Out of Scope

  • Prisma adapter (evaluate if demand exists)
  • Changes to core
  • better-auth plugin changes (evaluate after 1.6)

Complete When

All Drizzle adapter functionality has a Kysely equivalent. Tests pass. Docs updated with Kysely examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions