Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update all non-major dependencies #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented May 9, 2024

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@aws-sdk/client-s3 (source) ^3.572.0 -> ^3.614.0 age adoption passing confidence
@types/node (source) ^20.12.11 -> ^20.14.10 age adoption passing confidence
@types/react (source) ^18.3.1 -> ^18.3.3 age adoption passing confidence
cookies-next ^4.1.1 -> ^4.2.1 age adoption passing confidence
drizzle-kit ^0.20.18 -> ^0.23.0 age adoption passing confidence
drizzle-orm (source) ^0.30.10 -> ^0.32.0 age adoption passing confidence
firebase (source, changelog) ^10.11.1 -> ^10.12.3 age adoption passing confidence
firebase-admin (source) ^12.1.0 -> ^12.2.0 age adoption passing confidence
lucide-react (source) ^0.378.0 -> ^0.408.0 age adoption passing confidence
next (source) 14.2.3 -> 14.2.5 age adoption passing confidence
pg (source) ^8.11.5 -> ^8.12.0 age adoption passing confidence
postcss (source) ^8.4.38 -> ^8.4.39 age adoption passing confidence
sharp (source, changelog) ^0.33.3 -> ^0.33.4 age adoption passing confidence
tailwindcss (source) ^3.4.3 -> ^3.4.4 age adoption passing confidence
undici (source) ^6.16.0 -> ^6.19.2 age adoption passing confidence
use-immer ^0.9.0 -> ^0.10.0 age adoption passing confidence

Release Notes

aws/aws-sdk-js-v3 (@​aws-sdk/client-s3)

v3.614.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.613.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.609.0

Compare Source

Features
  • client-s3: Added response overrides to Head Object requests. (ac9f3d2)

v3.608.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.606.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.600.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.598.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.596.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.592.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.591.0

Compare Source

Features
  • client-s3: Added new params copySource and key to copyObject API for supporting S3 Access Grants plugin. These changes will not change any of the existing S3 API functionality. (ad0e8d9)

v3.590.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.588.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.587.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.583.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.582.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.577.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.576.0

Compare Source

Features
  • client-s3: Updated a few x-id in the http uri traits (dcde25a)

v3.575.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

v3.574.0

Compare Source

Note: Version bump only for package @​aws-sdk/client-s3

andreizanik/cookies-next (cookies-next)

v4.2.1

Compare Source

hot fix bug with types

What's Changed

New Contributors

Full Changelog: andreizanik/cookies-next@v4.2.0...v4.2.1

v4.2.0

Compare Source

What's Changed

New Contributors

Full Changelog: andreizanik/cookies-next@v4.1.1...v4.2.0

drizzle-team/drizzle-kit-mirror (drizzle-kit)

v0.23.0

Compare Source

v0.22.8: 0.22.8

Compare Source

v0.22.7

Compare Source

v0.22.6: 0.22.6

Compare Source

  • 🐛 Fixed drizzle-kit up of snapshots from v6 to v7
  • 🐛 [BUG]: extensionsFilters: ['postgis'] still trying to delete spatial_ref_sys - #​2464

v0.22.5: 0.22.5

Compare Source

  • 🐛 [BUG]: Recreating pg index in version 0.31(orm) + 0.22(kit) fails - #​2470
  • 🐛 [BUG]: Drizzle migrator doesn't work with uppercase names when creating indexes - #​2457
  • 🐛 [BUG]: 'left' column name not escaped in index - #​2425
  • 🐛 [BUG]: drizzle-kit push TypeError Cannot use 'in' operator to search for 'default' in undefined - #​2385
  • 🐛 [BUG]: Breaking change in the new "PostgreSQL Indexes API" missing quotes for uppercase column letters - #​2413
  • 🐛 [BUG]: drizzle-kit migrate fail "applying migrations...error: column "authorid" does not exist" - #​2423

v0.22.4: 0.22.4

Compare Source

  • Removed data loss triggers on push when adding a NOT NULL constraint to a column and when removing the default value from a column. These actions will now be performed immediately, and if there are any NULL values in the column, you will receive an error from the database

v0.22.3: 0.22.3

Compare Source

  • 🐛 Fix Cannot use 'in' operator to search for 'default' in undefined error on push and generate

v0.22.2: 0.22.2

Compare Source

  • 🐛 Fixed index-on-expressions sql statement generation if the expression contains a ,. This should fix problems for tsvector indexes, such as:
titleSearchIndex: index('title_search_index').using('gin', sql`to_tsvector('english', ${table.title})`)

v0.22.1: 0.22.1

Compare Source

Bug fixes
  • 🐛 [BUG]: postgis geometry error: type "geometry(point)" does not exist
Improvements
  • 🎉 Drizzle Studio now supports raw responses from D1 HTTP. This means that Drizzle Studio now has full support for D1, and all queries should work as expected!

  • 🎉 Refactor the d1-http driver to properly show the table row count

v0.22.0: 0.22.0

Compare Source

New Features

🎉 Full support for indexes in PostgreSQL

The previous Drizzle+PostgreSQL indexes API was incorrect and was not aligned with the PostgreSQL documentation. The good thing is that it was not used in queries, and drizzle-kit didn't support all properties for indexes. This means we can now change the API to the correct one and provide full support for it in drizzle-kit

Previous API

  • No way to define SQL expressions inside .on.
  • .using and .on in our case are the same thing, so the API is incorrect here.
  • .asc(), .desc(), .nullsFirst(), and .nullsLast() should be specified for each column or expression on indexes, but not on an index itself.
// Index declaration reference
index('name')
  .on(table.column1, table.column2, ...) or .onOnly(table.column1, table.column2, ...)
  .concurrently()
  .using(sql``) // sql expression
  .asc() or .desc()
  .nullsFirst() or .nullsLast()
  .where(sql``) // sql expression

Current API

// First example, with `.on()`
index('name')
  .on(table.column1.asc(), table.column2.nullsFirst(), ...) or .onOnly(table.column1.desc().nullsLast(), table.column2, ...)
  .concurrently()
  .where(sql``)
  .with({ fillfactor: '70' })

// Second Example, with `.using()`
index('name')
  .using('btree', table.column1.asc(), sql`lower(${table.column2})`, table.column1.op('text_ops'))
  .where(sql``) // sql expression
  .with({ fillfactor: '70' })

🎉 Support for new types

Drizzle Kit can now handle:

  • point and line from PostgreSQL
  • vector from the PostgreSQL pg_vector extension
  • geometry from the PostgreSQL PostGIS extension

🎉 New param in drizzle.config - extensionsFilters

The PostGIS extension creates a few internal tables in the public schema. This means that if you have a database with the PostGIS extension and use push or introspect, all those tables will be included in diff operations. In this case, you would need to specify tablesFilter, find all tables created by the extension, and list them in this parameter.

We have addressed this issue so that you won't need to take all these steps. Simply specify extensionsFilters with the name of the extension used, and Drizzle will skip all the necessary tables.

Currently, we only support the postgis option, but we plan to add more extensions if they create tables in the public schema.

The postgis option will skip the geography_columns, geometry_columns, and spatial_ref_sys tables

import { defineConfig } from 'drizzle-kit'

export default defaultConfig({
  dialect: "postgresql",
  extensionsFilters: ["postgis"],
})

Improvements

👍 Update zod schemas for database credentials and write tests to all the positive/negative cases
👍 Support full set of SSL params in kit config, provide types from node:tls connection
import { defineConfig } from 'drizzle-kit'

export default defaultConfig({
  dialect: "postgresql",
  dbCredentials: {
    ssl: true, //"require" | "allow" | "prefer" | "verify-full" | options from node:tls
  }
})
import { defineConfig } from 'drizzle-kit'

export default defaultConfig({
  dialect: "mysql",
  dbCredentials: {
    ssl: "", // string | SslOptions (ssl options from mysql2 package)
  }
})
👍 Normilized SQLite urls for libsql and better-sqlite3 drivers

Those drivers have different file path patterns, and Drizzle Kit will accept both and create a proper file path format for each

👍 Updated MySQL and SQLite index-as-expression behavior

In this release MySQL and SQLite will properly map expressions into SQL query. Expressions won't be escaped in string but columns will be

export const users = sqliteTable(
  'users',
  {
    id: integer('id').primaryKey(),
    email: text('email').notNull(),
  },
  (table) => ({
    emailUniqueIndex: uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
  }),
);
-- before
CREATE UNIQUE INDEX `emailUniqueIndex` ON `users` (`lower("users"."email")`);

-- now
CREATE UNIQUE INDEX `emailUniqueIndex` ON `users` (lower("email"));

Bug Fixes

  • [BUG]: multiple constraints not added (only the first one is generated) - #​2341
  • Drizzle Studio: Error: Connection terminated unexpectedly - #​435
  • Unable to run sqlite migrations local - #​432
  • error: unknown option '--config' - #​423

How push and generate works for indexes

Limitations
You should specify a name for your index manually if you have an index on at least one expression

Example

index().on(table.id, table.email) // will work well and name will be autogeneretaed
index('my_name').on(table.id, table.email) // will work well

// but

index().on(sql`lower(${table.email})`) // error
index('my_name').on(sql`lower(${table.email})`) // will work well
Push won't generate statements if these fields(list below) were changed in an existing index:
  • expressions inside .on() and .using()
  • .where() statements
  • operator classes .op() on columns

If you are using push workflows and want to change these fields in the index, you would need to:

  • Comment out the index
  • Push
  • Uncomment the index and change those fields
  • Push again

For the generate command, drizzle-kit will be triggered by any changes in the index for any property in the new drizzle indexes API, so there are no limitations here.

v0.21.4

Compare Source

bug fixes

  • fix node-pg pool connection halting, regression introduced in previous release while migrating from client to pool with max 1 connection

v0.21.3

Compare Source

Cloudflare D1 HTTP API support 🎉
Drizzle Chrome Extension now has support for Cloudflare D1!

Drizzle Kit now lets you run migrate, push, introspect and studio commands using Cloudflare D1 HTTP API, you just need to update connection params in drizzle.config.ts:

dialect: "sqlite",
+ driver: "d1-http",
dbCredentials: {
+  accountId: "...",
+  databaseId: "...",
+  token: "...",
}

You can find accountId, databaseId and token in Cloudflare dashboard
To get accountId go to Workers & Pages -> Overview -> copy Account ID from the right sidebar
To get databaseId open D1 database you want to connect to and copy Database ID
To get token go to My profile -> API Tokens and create token with D1 edit permissions

Bug fixes

v0.21.2

Compare Source

Bug fixes

A list of regressions after 0.21.0 that were fixed (there are more, and those should be fixed in the next patch releases):

  • SQLite generate and push were not detecting new columns added.
  • Timestamps with precision in Postgres were always detected as a change on push
  • Unique constraints for PostgreSQL were not generated and pushed
  • When adding columns to SQLite, table name was not escaped

Tickets that were closed

  • 🐛 [BUG]:"drizzle-kit generate" doesn't generate a migration file when a column is added - 2307
  • 🐛 [BUG]: Unique constraint is not added to the change - 2302
  • 🐛 [bug]: drizzle-kit push is not detecting changes correctly (Turso) - #​397

v0.21.1

Compare Source

Drizzle Studio support for per-database preferences

When connecting to different databases with Drizzle Local Studio, we will store all preferences such as selected tabs, hidden columns, pagination, etc., separately for each database

Drizzle Studio support for advanced bug report context

Now you can assist us in debugging Drizzle Studio errors. No more need to say, "Please share your schema with us"; just click a button, download the bug report, and send it to us!

image

image

v0.21.0

Compare Source

Breaking changes
❗ Snapshots Upgrade

All PostgreSQL and SQLite-generated snapshots will be upgraded to version 6. You will be prompted to upgrade them by running drizzle-kit up

❗ Removing :dialect from drizzle-kit cli commands

You can now just use commands, like:

  • drizzle-kit generate
  • drizzle-kit push
  • etc.

without specifying dialect. This param is moved to drizzle.config.ts

drizzle.config update
  • dialect is now mandatory; specify which database dialect you are connecting to. Options include mysql, postgresql, or sqlite.
  • driver has become optional and will have a specific driver, each with a different configuration of dbCredentials. Available drivers are:
    • aws-data-api
    • turso
    • d1-http - currently WIP
    • expo
  • url - a unified parameter for the previously existing connectionString and uri.
  • migrations - a new object parameter to specify a custom table and schema for the migrate command:
    • table - the custom table where drizzle will store migrations.
    • schema - the custom schema where drizzle will store migrations (Postgres only).

Usage examples for all new and updated commands

import { defineConfig } from "drizzle-kit"

export default defineConfig({
    dialect: "sqlite", // "postgresql" | "mysql"
    driver: "turso"
    dbCredentials: {
        url: ""
    },
    migration: {
        table: "migrations",
        schema: "public"
    }
})

Drizzle driver selection follows the current strategy:

If a driver is specified, use this driver for querying.

If no driver is specified:

  • For postgresql dialect, Drizzle will:

    • Check if the pg driver is installed and use it.
    • If not, try to find the postgres driver and use it.
    • If still not found, try to find @vercel/postgres.
    • Then try @neondatabase/serverless.
    • If nothing is found, an error will be thrown.
  • For mysql dialect, Drizzle will:

    • Check if the mysql2 driver is installed and use it.
    • If not, try to find @planetscale/database and use it.
    • If nothing is found, an error will be thrown.
  • For sqlite dialect, Drizzle will:

    • Check if the @libsql/client driver is installed and use it.
    • If not, try to find better-sqlite3 and use it.
    • If nothing is found, an error will be thrown
❗ MySQL schemas/database are no longer supported by drizzle-kit

Drizzle Kit won't handle any schema changes for additional schemas/databases in your drizzle schema file

New Features
🎉 Pull relations

Drizzle will now pull relations from the database by extracting foreign key information and translating it into a relations object. You can view the relations.ts file in the out folder after introspection is complete

For more info about relations, please check the docs

🎉 Custom name for generated migrations

To specify a name for your migration you should use --name <name>

Usage

drizzle-kit generate --name init_db
🎉 New command migrate

You can now apply generated migrations to your database directly from drizzle-kit

Usage

drizzle-kit migrate

By default, drizzle-kit will store migration data entries in the __drizzle_migrations table and, in the case of PostgreSQL, in a drizzle schema. If you want to change this, you will need to specify the modifications in drizzle.config.ts.

import { defineConfig } from "drizzle-kit"

export default defineConfig({
    migrations: {
        table: "migrations",
        schema: "public"
    }
})
How to migrate from 0.20.18 to 0.21.0
1. Remove all :dialect prefixes from your Drizzle-Kit commands.

Example: Change drizzle-kit push:mysql to drizzle-kit push.

2. Update your drizzle.config.ts file:
  • Add dialect to drizzle.config.ts. It is now mandatory and can be 'postgresql', 'mysql', or 'sqlite'.
  • Add driver to drizzle.config.ts ONLY if you are using aws-data-api, turso, d1-http(WIP), or expo. Otherwise, you can remove the driver from drizzle.config.ts.
  • If you were using connectionString or uri in dbCredentials, you should now use url.
import { defineConfig } from "drizzle-kit"

export default defineConfig({
    dialect: "sqlite", // "postgresql" | "mysql"
    driver: "turso" // optional and used only if `aws-data-api`, `turso`, `d1-http`(WIP) or `expo` are used
    dbCredentials: {
        url: ""
    }
})
3. If you are using PostgreSQL and had migrations generated in your project, please run drizzle-kit up so Drizzle can upgrade all the snapshots to version 6.
drizzle-team/drizzle-orm (drizzle-orm)

v0.32.0

Compare Source

Release notes for drizzle-orm@0.32.0 and drizzle-kit@0.23.0

It's not mandatory to upgrade both packages, but if you want to use the new features in both queries and migrations, you will need to upgrade both packages

New Features

🎉 MySQL $returningId() function

MySQL itself doesn't have native support for RETURNING after using INSERT. There is only one way to do it for primary keys with autoincrement (or serial) types, where you can access insertId and affectedRows fields. We've prepared an automatic way for you to handle such cases with Drizzle and automatically receive all inserted IDs as separate objects

import { boolean, int, text, mysqlTable } from 'drizzle-orm/mysql-core';

const usersTable = mysqlTable('users', {
  id: int('id').primaryKey(),
  name: text('name').notNull(),
  verified: boolean('verified').notNull().default(false),
});

const result = await db.insert(usersTable).values([{ name: 'John' }, { name: 'John1' }]).$returningId();
//    ^? { id: number }[]

Also with Drizzle, you can specify a primary key with $default function that will generate custom primary keys at runtime. We will also return those generated keys for you in the $returningId() call

import { varchar, text, mysqlTable } from 'drizzle-orm/mysql-core';
import { createId } from '@&#8203;paralleldrive/cuid2';

const usersTableDefFn = mysqlTable('users_default_fn', {
  customId: varchar('id', { length: 256 }).primaryKey().$defaultFn(createId),
  name: text('name').notNull(),
});

const result = await db.insert(usersTableDefFn).values([{ name: 'John' }, { name: 'John1' }]).$returningId();
//  ^? { customId: string }[]

If there is no primary keys -> type will be {}[] for such queries

🎉 PostgreSQL Sequences

You can now specify sequences in Postgres within any schema you need and define all the available properties

Example
import { pgSchema, pgSequence } from "drizzle-orm/pg-core";

// No params specified
export const customSequence = pgSequence("name");

// Sequence with params
export const customSequence = pgSequence("name", {
      startWith: 100,
      maxValue: 10000,
      minValue: 100,
      cycle: true,
      cache: 10,
      increment: 2
});

// Sequence in custom schema
export const customSchema = pgSchema('custom_schema');

export const customSequence = customSchema.sequence("name");
🎉 PostgreSQL Identity Columns

Source: As mentioned, the serial type in Postgres is outdated and should be deprecated. Ideally, you should not use it. Identity columns are the recommended way to specify sequences in your schema, which is why we are introducing the identity columns feature

Example
import { pgTable, integer, text } from 'drizzle-orm/pg-core' 

export const ingredients = pgTable("ingredients", {
  id: integer("id").primaryKey().generatedAlwaysAsIdentity({ startWith: 1000 }),
  name: text("name").notNull(),
  description: text("description"),
});

You can specify all properties available for sequences in the .generatedAlwaysAsIdentity() function. Additionally, you can specify custom names for these sequences

PostgreSQL docs reference.

🎉 PostgreSQL Generated Columns

You can now specify generated columns on any column supported by PostgreSQL to use with generated columns

Example with generated column for tsvector

Note: we will add tsVector column type before latest release

import { SQL, sql } from "drizzle-orm";
import { customType, index, integer, pgTable, text } from "drizzle-orm/pg-core";

const tsVector = customType<{ data: string }>({
  dataType() {
    return "tsvector";
  },
});

export const test = pgTable(
  "test",
  {
    id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
    content: text("content"),
    contentSearch: tsVector("content_search", {
      dimensions: 3,
    }).generatedAlwaysAs(
      (): SQL => sql`to_tsvector('english', ${test.content})`
    ),
  },
  (t) => ({
    idx: index("idx_content_search").using("gin", t.contentSearch),
  })
);

In case you don't need to reference any columns from your table, you can use just sql template or a string

export const users = pgTable("users", {
  id: integer("id"),
  name: text("name"),
  generatedName: text("gen_name").generatedAlwaysAs(sql`hello world!`),
  generatedName1: text("gen_name1").generatedAlwaysAs("hello world!"),
}),
🎉 MySQL Generated Columns

You can now specify generated columns on any column supported by MySQL to use with generated columns

You can specify both stored and virtual options, for more info you can check MySQL docs

Also MySQL has a few limitation for such columns usage, which is described here

Drizzle Kit will also have limitations for push command:

  1. You can't change the generated constraint expression and type using push. Drizzle-kit will ignore this change. To make it work, you would need to drop the column, push, and then add a column with a new expression. This was done due to the complex mapping from the database side, where the schema expression will be modified on the database side and, on introspection, we will get a different string. We can't be sure if you changed this expression or if it was changed and formatted by the database. As long as these are generated columns and push is mostly used for prototyping on a local database, it should be fast to drop and create generated columns. Since these columns are generated, all the data will be restored

  2. generate should have no limitations

Example
export const users = mysqlTable("users", {
  id: int("id"),
  id2: int("id2"),
  name: text("name"),
  generatedName: text("gen_name").generatedAlwaysAs(
    (): SQL => sql`${schema2.users.name} || 'hello'`,
    { mode: "stored" }
  ),
  generatedName1: text("gen_name1").generatedAlwaysAs(
    (): SQL => sql`${schema2.users.name} || 'hello'`,
    { mode: "virtual" }
  ),
}),

In case you don't need to reference any columns from your table, you can use just sql template or a string in .generatedAlwaysAs()

🎉 SQLite Generated Columns

You can now specify generated columns on any column supported by SQLite to use with generated columns

You can specify both stored and virtual options, for more info you can check SQLite docs

Also SQLite has a few limitation for such columns usage, which is described here

Drizzle Kit will also have limitations for push and generate command:

  1. You can't change the generated constraint expression with the stored type in an existing table. You would need to delete this table and create it again. This is due to SQLite limitations for such actions. We will handle this case in future releases (it will involve the creation of a new table with data migration).

  2. You can't add a stored generated expression to an existing column for the same reason as above. However, you can add a virtual expression to an existing column.

  3. You can't change a stored generated expression in an existing column for the same reason as above. However, you can change a virtual expression.

  4. You can't change the generated constraint type from virtual to stored for the same reason as above. However, you can change from stored to virtual.

New Drizzle Kit features

🎉 Migrations support for all the new orm features

PostgreSQL sequences, identity columns and generated columns for all dialects

🎉 New flag --force for drizzle-kit push

You can auto-accept all data-loss statements using the push command. It's only available in CLI parameters. Make sure you always use it if you are fine with running data-loss statements on your database

🎉 New migrations flag prefix

You can now customize migration file prefixes to make the format suitable for your migration tools:

  • index is the default type and will result in 0001_name.sql file names;
  • supabase and timestamp are equal and will result in 20240627123900_name.sql file names;
  • unix will result in unix seconds prefixes 1719481298_name.sql file names;
  • none will omit the prefix completely;
Example: Supabase migrations format
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "postgresql",
  migrations: {
    prefix: 'supabase'
  }
});

v0.31.4

Compare Source

  • Mark prisma clients package as optional - thanks @​Cherry

v0.31.3

Compare Source

Bug fixed
  • 🛠️ Fixed RQB behavior for tables with same names in different schemas
  • 🛠️ Fixed [BUG]: Mismatched type hints when using RDS Data API - #​2097
New Prisma-Drizzle extension
import { PrismaClient } from '@&#8203;prisma/client';
import { drizzle } from 'drizzle-orm/prisma/pg';
import { User } from './drizzle';

const prisma = new PrismaClient().$extends(drizzle());
const users = await prisma.$drizzle.select().from(User);

For more info, check docs: https://orm.drizzle.team/docs/prisma

v0.31.2

Compare Source

  • 🎉 Added support for TiDB Cloud Serverless driver:

    import { connect } from '@&#8203;tidbcloud/serverless';
    import { drizzle } from 'drizzle-orm/tidb-serverless';
    
    const client = connect({ url: '...' });
    const db = drizzle(client);
    await db.select().from(...);

v0.31.1

Compare Source

New Features

Live Queries 🎉

For a full explanation about Drizzle + Expo welcome to discussions

As of v0.31.1 Drizzle ORM now has native support for Expo SQLite Live Queries!
We've implemented a native useLiveQuery React Hook which observes necessary database changes and automatically re-runs database queries. It works with both SQL-like and Drizzle Queries:

import { useLiveQuery, drizzle } from 'drizzle-orm/expo-sqlite';
import { openDatabaseSync } from 'expo-sqlite/next';
import { users } from './schema';
import { Text } from 'react-native';

const expo = openDatabaseSync('db.db', { enableChangeListener: true }); // <-- enable change listeners
const db = drizzle(expo);

const App = () => {
  // Re-renders automatically when data changes
  const { data } = useLiveQuery(db.select().from(users));

  // const { data, error, updatedAt } = useLiveQuery(db.query.users.findFirst());
  // const { data, error, updatedAt } = useLiveQuery(db.query.users.findMany());

  return <Text>{JSON.stringify(data)}</Text>;
};

export default App;

We've intentionally not changed the API of ORM itself to stay with conventional React Hook API, so we have useLiveQuery(databaseQuery) as opposed to db.select().from(users).useLive() or db.query.users.useFindMany()

We've also decided to provide data, error and updatedAt fields as a result of hook for concise explicit error handling following practices of React Query and Electric SQL

v0.31.0

Compare Source

Breaking changes

Note: drizzle-orm@0.31.0 can be used with drizzle-kit@0.22.0 or higher. The same applies to Drizzle Kit. If you run a Drizzle Kit command, it will check and prompt you for an upgrade (if needed). You can check for Drizzle Kit updates. below

PostgreSQL indexes API was changed

The previous Drizzle+PostgreSQL indexes API was incorrect and was not aligned with the PostgreSQL documentation. The good thing is that it was not used in queries, and drizzle-kit didn't support all properties for indexes. This means we can now change the API to the correct one and provide full support for it in drizzle-kit

Previous API

  • No way to define SQL expressions inside .on.
  • .using and .on in our case are the same thing, so the API is incorrect here.
  • .asc(), .desc(), .nullsFirst(), and .nullsLast() should be specified for each column or expression on indexes, but not on an index itself.
// Index declaration reference
index('name')
  .on(table.column1, table.column2, ...) or .onOnly(table.column1, table.column2, ...)
  .concurrently()
  .using(sql``) // sql expression
  .asc() or .desc()
  .nullsFirst() or .nullsLast()
  .where(sql``) // sql expression

Current API

// First example, with `.on()`
index('name')
  .on(table.column1.asc(), table.column2.nullsFirst(), ...) or .onOnly(table.column1.desc().nullsLast(), table.column2, ...)
  .concurrently()
  .where(sql``)
  .with({ fillfactor: '70' })

// Second Example, with `.using()`
index('name')
  .using('btree', table.column1.asc(), sql`lower(${table.column2})`, table.column1.op('text_ops'))
  .where(sql``) // sql expression
  .with({ fillfactor: '70' })

New Features

🎉 "pg_vector" extension support

There is no specific code to create an extension inside the Drizzle schema. We assume that if you are using vector types, indexes, and queries, you have a PostgreSQL database with the pg_vector extension installed.

You can now specify indexes for pg_vector and utilize pg_vector functions for querying, ordering, etc.

Let's take a few examples of pg_vector indexes from the pg_vector docs and translate them to Drizzle

L2 distance, Inner product and Cosine distance
// CREATE INDEX ON items USING hnsw (embedding vector_l2_ops);
// CREATE INDEX ON items USING hnsw (embedding vector_ip_ops);
// CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops);

const table = pgTable('items', {
    embedding: vector('embedding', { dimensions: 3 })
}, (table) => ({
    l2: index('l2_index').using('hnsw', table.embedding.op('vector_l2_ops'))
    ip: index('ip_index').using('hnsw', table.embedding.op('vector_ip_ops'))
    cosine: index('cosine_index').using('hnsw', table.embedding.op('vector_cosine_ops'))
}))
L1 distance, Hamming distance and Jaccard distance - added in pg_vector 0.7.0 version
// CREATE INDEX ON items USING hnsw (embedding vector_l1_ops);
// CREATE INDEX ON items USING hnsw (embedding bit_hamming_ops);
// CREATE INDEX ON items USING hnsw (embedding bit_jaccard_ops);

const table = pgTable('table', {
    embedding: vector('embedding', { dimensions: 3 })
}, (table) => ({
    l1: index('l1_index').using('hnsw', table.embedding.op('vector_l1_ops'))
    hamming: index('hamming_index').using('hnsw', table.embedding.op('bit_hamming_ops'))
    bit: index('bit_jaccard_index').using('hnsw', table.embedding.op('bit_jaccard_ops'))
}))

For queries, you can use predefined functions for vectors or create custom ones using the SQL template operator.

You can also use the following helpers:

import { l2Distance, l1Distance, innerProduct, 
          cosineDistance, hammingDistance, jaccardDistance } from 'drizzle-orm'

l2Distance(table.column, [3, 1, 2]) // table.column <-> '[3, 1, 2]'
l1Distance(table.column, [3, 1, 2]) // table.column <+> '[3, 1, 2]'

innerProduct(table.column, [3, 1, 2]) // table.column <#> '[3, 1, 2]'
cosineDistance(table.column, [3, 1, 2]) // table.column <=> '[3, 1, 2]'

hammingDistance(table.column, '101') // table.column <~> '101'
jaccardDistance(table.column, '101') // table.column <%> '101'

If pg_vector has some other functions to use, you can replicate implimentation from existing one we have. Here is how it can be done

export function l2Distance(
  column: SQLWrapper | AnyColumn,
  value: number[] | string[] | TypedQueryBuilder<any> | string,
): SQL {
  if (is(value, TypedQueryBuilder<any>) || typeof value === 'string') {
    return sql`${column} <-> ${value}`;
  }
  return sql`${column} <-> ${JSON.stringify(value)}`;
}

Name it as you wish and change the operator. This example allows for a numbers array, strings array, string, or even a select query. Feel free to create any other type you want or even contribute and submit a PR

Examples

Let's take a few examples of pg_vector queries from the pg_vector docs and translate them to Drizzle

import { l2Distance } from 'drizzle-orm';

// SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;
db.select().from(items).orderBy(l2Distance(items.embedding, [3,1,2]))

// SELECT embedding <-> '[3,1,2]' AS distance FROM items;
db.select({ distance: l2Distance(items.embedding, [3,1,2]) })

// SELECT * FROM it

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am" in timezone Asia/Jakarta, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

 **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/KagChi/foresia).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNTEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQyNS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJtZXRhOiBkZXBlbmRlbmNpZXMiXX0=-->

Copy link

vercel bot commented May 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
foresia ❌ Failed (Inspect) Jul 12, 2024 7:26am

@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 7b5bfd8 to 94cc5e8 Compare May 10, 2024 12:41
@renovate renovate bot changed the title chore(deps): update dependency drizzle-kit to ^0.21.0 chore(deps): update all non-major dependencies May 10, 2024
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 94cc5e8 to 2d10bc7 Compare May 10, 2024 19:18
@renovate renovate bot changed the title chore(deps): update all non-major dependencies fix(deps): update all non-major dependencies May 10, 2024
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 2d10bc7 to 2d5a6bd Compare May 10, 2024 22:46
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 2d5a6bd to 11287e2 Compare May 11, 2024 12:03
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 11287e2 to 00fbc83 Compare May 13, 2024 18:15
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 00fbc83 to 350b452 Compare May 13, 2024 21:38
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 350b452 to f821462 Compare May 14, 2024 06:22
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from f821462 to b04607a Compare May 15, 2024 01:35
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from b04607a to 5d85566 Compare May 15, 2024 20:22
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 5d85566 to 71b5eb7 Compare May 16, 2024 19:41
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 71b5eb7 to 82806d4 Compare May 17, 2024 07:09
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 82806d4 to bd8e5bc Compare May 20, 2024 22:55
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from bd8e5bc to a3dc399 Compare May 21, 2024 11:59
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 395c6c6 to 1ccc806 Compare July 5, 2024 20:19
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 1ccc806 to 0bb20e2 Compare July 7, 2024 21:38
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 0bb20e2 to f6ca916 Compare July 8, 2024 11:44
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from f6ca916 to a726804 Compare July 8, 2024 14:42
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from a726804 to b084146 Compare July 8, 2024 17:32
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from b084146 to f865656 Compare July 8, 2024 19:43
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from f865656 to 4e8523f Compare July 9, 2024 10:07
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 4e8523f to 983be84 Compare July 9, 2024 16:59
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 983be84 to e81aa94 Compare July 9, 2024 18:55
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from e81aa94 to 01d45b1 Compare July 9, 2024 22:10
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 01d45b1 to db2cdbd Compare July 10, 2024 14:47
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from db2cdbd to 579df4e Compare July 10, 2024 17:25
@renovate renovate bot force-pushed the renovate/all-minor-patch branch from 579df4e to 246a5f9 Compare July 10, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants