0.40.0

drizzle-team/drizzle-orm0.40.0Feb 25, 2025by github-actions[bot]

AI Summary

This release introduces support for the Gel database with a new Gel dialect and gel-js client integration. Since Gel is PostgreSQL-compatible, most query-building features were ported from the PostgreSQL dialect, with Gel-specific data types that avoid extra conversions. The integration works through drizzle-kit pull to import the schema.

Key Highlights

  • Added new Gel dialect with Gel-specific types and logic
  • Gel is PostgreSQL-compatible - most query features copied from PostgreSQL dialect
  • Integration works only via drizzle-kit pull (no generate/migrate/push support)
  • New gelTable, uniqueIndex, uuid, smallint, text helpers in drizzle-orm/gel-core
  • New drizzle-kit dialect option: dialect: 'gel'

New Features

  • Gel dialect support with its own types and Gel-specific logic
  • gel-js client support for connecting to Gel databases
  • drizzle-orm/gel module for creating Gel client connections
  • drizzle-orm/gel-core module with Gel-specific table helpers (gelTable, uniqueIndex, uuid, smallint, text)
  • drizzle-kit support for Gel dialect via dialect: 'gel' configuration

Full Release Notes

# New Features 

## Added `Gel` dialect support and `gel-js` client support

Drizzle is getting a new `Gel` dialect with its own types and Gel-specific logic. In this first iteration, almost all query-building features have been copied from the `PostgreSQL` dialect since Gel is fully PostgreSQL-compatible. The only change in this iteration is the data types. The Gel dialect has a different set of available data types, and all mappings for these types have been designed to avoid any extra conversions on Drizzle's side. This means you will insert and select exactly the same data as supported by the Gel protocol.

Drizzle + Gel integration will work only through `drizzle-kit pull`. Drizzle won't support `generate`, `migrate`, or `push` features in this case. Instead, drizzle-kit is used solely to pull the Drizzle schema from the Gel database, which can then be used in your `drizzle-orm` queries.

The Gel + Drizzle workflow:

1. Use the `gel` CLI to manage your schema.
2. Use the `gel` CLI to generate and apply migrations to the database.
3. Use drizzle-kit to pull the Gel database schema into a Drizzle schema.
4. Use drizzle-orm with gel-js to query the Gel database.

Here is a small example of how to connect to Gel using Drizzle:

```typescript copy
// Make sure to install the 'gel' package 
import { drizzle } from "drizzle-orm/gel";
import { createClient } from "gel";

const gelClient = createClient();
const db = drizzle({ client: gelClient });

const result = await db.execute('select 1');
```

and drizzle-gel schema definition
```typescript
import { gelTable, uniqueIndex, uuid, smallint, text } from "drizzle-orm/gel-core"
import { sql } from "drizzle-orm"

export const users = gelTable("users", {
    id: uuid().default(sql`uuid_generate_v4()`).primaryKey(),
    age: smallint(),
    email: text().notNull(),
    name: text(),
});
```

On the drizzle-kit side you can now use `dialect: "gel"`

```ts
// drizzle.config.ts
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
  dialect: 'gel',
});
```

For a complete Get Started tutorial you can use our new guides:

- [Get Started with Drizzle and Gel in a new project](https://orm.drizzle.team/docs/get-started/gel-new)
- [Get Started with Drizzle and Gel in a existing project](https://orm.drizzle.team/docs/get-started/gel-existing)