Skip to content

Add Drizzle ORM integration for Admin UI#214

Merged
jamals86 merged 7 commits into
kalamstack:mainfrom
inas-sirhan:feat/drizzle-driver
Apr 19, 2026
Merged

Add Drizzle ORM integration for Admin UI#214
jamals86 merged 7 commits into
kalamstack:mainfrom
inas-sirhan:feat/drizzle-driver

Conversation

@inas-sirhan
Copy link
Copy Markdown
Collaborator

Adds Drizzle ORM support. Schema generator introspects KalamDB and outputs typed pgTable definitions. All Admin UI read queries migrated from raw SQL to type-safe Drizzle queries.

  • Schema generator in tools/drizzle/ (SHOW TABLES + DESCRIBE, including hidden system tables)
  • Drizzle pg-proxy driver in ui/src/lib/db.ts
  • All services migrated: users, audit logs, jobs, storages, live queries, server logs, cluster, settings, stats
  • Types inferred from schema via InferSelectModel, no manual interfaces
  • Admin commands (CREATE USER, ALTER USER, KILL LIVE QUERY) remain raw SQL

Schema generator in tools/drizzle/ introspects KalamDB and outputs typed pgTable definitions. Admin UI services (users, audit logs, jobs, storages) migrated from raw SQL to Drizzle queries with types inferred from the schema. Job detail dialog updated to use correct column names (message, exception_trace).
@jamals86
Copy link
Copy Markdown
Member

Thanks inas, but i have these few suggestions:

  • You can place it in link/sdks/typescript/orm
  • i prefer making the users whenever they wish to use kalamdb with drizzle they can easily migrate with few lines only:
    `import { drizzle } from 'drizzle-orm';

import { kalamDriver } from '@kalamdb/orm’;

const db = drizzle(kalamDriver(client));`

  • Make sure we have the tools for dealing with the File datatype as well with its methods from kalam-link like getDownloadLink()
  • Adding more tests to it

Future:

  • the client.live will be able to give zod/drizzle object instead of a hashmap rows

- Driver: pg-proxy adapter with DEFAULT stripping, multi-row INSERT splitting, quote removal
- Generator: introspects tables via SHOW TABLES + system.columns, generates typed Drizzle schemas with .default() for server defaults, FILE column support
- CLI: npx kalamdb-orm --password <pass> generates schema files, supports env vars
- Tests: 61 tests (24 unit, 37 integration) covering SELECT/INSERT/UPDATE/DELETE, defaults, multi-row, FILE type, schema generation, CLI
- Admin UI: migrated to use @kalamdb/orm driver, added generate:schema script
- CI: workflow with KalamDB service container for integration tests
…deSystem

- Default: exclude system/dba tables
- --include-system flag to opt in
- Remove namespaces filter option
SHOW TABLES columns JSON already provides defaults for all regular tables.
Hidden tables (virtual views) don't have defaults and aren't in system.columns anyway.
Wraps client.live with Drizzle schema inference so callbacks
get fully typed rows instead of raw RowData. Handles KalamCellValue
unwrapping and custom column transforms like FILE -> FileRef.
@inas-sirhan
Copy link
Copy Markdown
Collaborator Author

All addressed!
Including the client.live feature.

Let me know if you have any notes

@jamals86

inas-sirhan and others added 2 commits April 19, 2026 21:11
KalamDB returns all BIGINT values as strings in JSON responses.
Previously mapped to bigint({ mode: 'number' }) which silently
corrupted SNOWFLAKE_IDs exceeding JS MAX_SAFE_INTEGER.

Now BIGINT columns generate as text(), timestamps stay as
bigint({ mode: 'number' }) since they're returned as actual numbers.
Updated UI cluster components to handle string types.
@jamals86 jamals86 merged commit ab0abfe into kalamstack:main Apr 19, 2026
1 check failed
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.

2 participants