vitest-dev/vitest (@vitest/coverage-v8)
### [`v2.1.4`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v2.1.4)
[Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v2.1.3...v2.1.4)
##### 🚀 Features
- **browser**: Allow custom HTML path, respect plugins `transformIndexHtml` - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6725](https://redirect.github.com/vitest-dev/vitest/issues/6725) [(16902)](https://redirect.github.com/vitest-dev/vitest/commit/169028f0)
##### 🐞 Bug Fixes
- Don't normalize drive case letter in root - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6792](https://redirect.github.com/vitest-dev/vitest/issues/6792) [(b28cd)](https://redirect.github.com/vitest-dev/vitest/commit/b28cd2e3)
- **browser**:
- Fix default browser port - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6700](https://redirect.github.com/vitest-dev/vitest/issues/6700) [(9c518)](https://redirect.github.com/vitest-dev/vitest/commit/9c518c14)
- Optimize expect-type - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6713](https://redirect.github.com/vitest-dev/vitest/issues/6713) [(07918)](https://redirect.github.com/vitest-dev/vitest/commit/07918538)
- Don't polyfill process.env - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6718](https://redirect.github.com/vitest-dev/vitest/issues/6718) [(da6d2)](https://redirect.github.com/vitest-dev/vitest/commit/da6d2ea7)
- Increment browser port automatically if there are several projects with browser.enabled - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6717](https://redirect.github.com/vitest-dev/vitest/issues/6717) [(a9397)](https://redirect.github.com/vitest-dev/vitest/commit/a939779f)
- Cleanup keyboard state - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6731](https://redirect.github.com/vitest-dev/vitest/issues/6731) [(19278)](https://redirect.github.com/vitest-dev/vitest/commit/19278f4c)
- Don't add `v=` queries to setup files imports - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6759](https://redirect.github.com/vitest-dev/vitest/issues/6759) [(b8258)](https://redirect.github.com/vitest-dev/vitest/commit/b82584c9)
- User event cleanup on retry - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6764](https://redirect.github.com/vitest-dev/vitest/issues/6764) [(bdd15)](https://redirect.github.com/vitest-dev/vitest/commit/bdd15dd1)
- Ignore non mocked msw requests - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6770](https://redirect.github.com/vitest-dev/vitest/issues/6770) [(9d9ba)](https://redirect.github.com/vitest-dev/vitest/commit/9d9bad5b)
- Initiate MSW in the same frame as tests - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6772](https://redirect.github.com/vitest-dev/vitest/issues/6772) [(2444f)](https://redirect.github.com/vitest-dev/vitest/commit/2444ff22)
- **deps**:
- Update dependency sirv to v3 - in [https://github.com/vitest-dev/vitest/issues/6701](https://redirect.github.com/vitest-dev/vitest/issues/6701) [(fde5d)](https://redirect.github.com/vitest-dev/vitest/commit/fde5d509)
- **expect**:
- Correct behavior of `toThrowError` with empty string parameter - by [@shulaoda](https://redirect.github.com/shulaoda) in [https://github.com/vitest-dev/vitest/issues/6710](https://redirect.github.com/vitest-dev/vitest/issues/6710) [(a6129)](https://redirect.github.com/vitest-dev/vitest/commit/a61293e9)
- **mocker**:
- Remove spy from peer dependencies - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6777](https://redirect.github.com/vitest-dev/vitest/issues/6777) [(3a8b5)](https://redirect.github.com/vitest-dev/vitest/commit/3a8b56bf)
- **vitest**:
- Clarify slowTestThreshold, print slow tests in non-TTY mode - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6715](https://redirect.github.com/vitest-dev/vitest/issues/6715) [(2e6aa)](https://redirect.github.com/vitest-dev/vitest/commit/2e6aa647)
- Print warnings form Vite plugins - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6724](https://redirect.github.com/vitest-dev/vitest/issues/6724) [(121b1)](https://redirect.github.com/vitest-dev/vitest/commit/121b161f)
- Don't fail if the working directory starts with a lowercase drive letter - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6779](https://redirect.github.com/vitest-dev/vitest/issues/6779) [(df6d7)](https://redirect.github.com/vitest-dev/vitest/commit/df6d750b)
- Silence import analysis warning - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6785](https://redirect.github.com/vitest-dev/vitest/issues/6785) [(39041)](https://redirect.github.com/vitest-dev/vitest/commit/39041ee5)
- **vitest,runner**:
- Simplify `test.extend` type exports - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6707](https://redirect.github.com/vitest-dev/vitest/issues/6707) [(e5c38)](https://redirect.github.com/vitest-dev/vitest/commit/e5c388f0)
##### 🏎 Performance
- Use `hash` to replace `createHash` - by [@btea](https://redirect.github.com/btea) in [https://github.com/vitest-dev/vitest/issues/6703](https://redirect.github.com/vitest-dev/vitest/issues/6703) [(5d07b)](https://redirect.github.com/vitest-dev/vitest/commit/5d07bba6)
##### [View changes on GitHub](https://redirect.github.com/vitest-dev/vitest/compare/v2.1.3...v2.1.4)
### [`v2.1.3`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v2.1.3)
[Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v2.1.2...v2.1.3)
##### 🐞 Bug Fixes
- Fix error diff of `toBeNaN, toBeUndefined, toBeNull, toBeTruthy, toBeFalsy` - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6697](https://redirect.github.com/vitest-dev/vitest/issues/6697) [(e0027)](https://redirect.github.com/vitest-dev/vitest/commit/e002758c)
- **browser**:
- Provide aria role intellisense - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6629](https://redirect.github.com/vitest-dev/vitest/issues/6629) [(f36ea)](https://redirect.github.com/vitest-dev/vitest/commit/f36eac77)
- Not.toBeInTheDocument works with locators API - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6634](https://redirect.github.com/vitest-dev/vitest/issues/6634) [(8bef5)](https://redirect.github.com/vitest-dev/vitest/commit/8bef5d2b)
- Use `/mockServiceWorker.js` instead of `/__vitest_msw__` - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6687](https://redirect.github.com/vitest-dev/vitest/issues/6687) [(4b2ce)](https://redirect.github.com/vitest-dev/vitest/commit/4b2ce07f)
- Don't override the esbuild option in the browser mode - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6692](https://redirect.github.com/vitest-dev/vitest/issues/6692) [(d131f)](https://redirect.github.com/vitest-dev/vitest/commit/d131fd64)
- **expect**:
- Preserve prototype in `toMatchObject` diff - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6620](https://redirect.github.com/vitest-dev/vitest/issues/6620) [(d289e)](https://redirect.github.com/vitest-dev/vitest/commit/d289e7eb)
- **mocker**:
- Specify correct spy dependency - by [@sheremet-va](https://redirect.github.com/sheremet-va) [(7e958)](https://redirect.github.com/vitest-dev/vitest/commit/7e9584aa)
- **runner**:
- Ensure sequential suite overrides sequence.concurrent - by [@dsyddall](https://redirect.github.com/dsyddall) and [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6653](https://redirect.github.com/vitest-dev/vitest/issues/6653) [(5e6de)](https://redirect.github.com/vitest-dev/vitest/commit/5e6de274)
- **vitest**:
- Deprecate UserConfig in favor of ViteUserConfig - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6626](https://redirect.github.com/vitest-dev/vitest/issues/6626) [(496bd)](https://redirect.github.com/vitest-dev/vitest/commit/496bd251)
- Don't hang with maxConcurrency 0 - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6627](https://redirect.github.com/vitest-dev/vitest/issues/6627) [(946d8)](https://redirect.github.com/vitest-dev/vitest/commit/946d8bb1)
- Deprecate old task types and node-reliant types - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6632](https://redirect.github.com/vitest-dev/vitest/issues/6632) [(00045)](https://redirect.github.com/vitest-dev/vitest/commit/000459a9)
- Fix `` logs when interleaving `console.log/error` - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6644](https://redirect.github.com/vitest-dev/vitest/issues/6644) [(9ece3)](https://redirect.github.com/vitest-dev/vitest/commit/9ece3952)
- Show rollup error details as test error - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6686](https://redirect.github.com/vitest-dev/vitest/issues/6686) [(47dde)](https://redirect.github.com/vitest-dev/vitest/commit/47dde76f)
- Always inline setup files - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6689](https://redirect.github.com/vitest-dev/vitest/issues/6689) [(19d64)](https://redirect.github.com/vitest-dev/vitest/commit/19d64e20)
- Use `fast-glob` instead of `tinyglobby` in Vitest - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6688](https://redirect.github.com/vitest-dev/vitest/issues/6688) [(70baa)](https://redirect.github.com/vitest-dev/vitest/commit/70baaaa9)
- **web-worker**:
- Share mocker with main executor - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6623](https://redirect.github.com/vitest-dev/vitest/issues/6623) [(fe7b8)](https://redirect.github.com/vitest-dev/vitest/commit/fe7b8aee)
##### 🏎 Performance
- Reuse full name in reported tasks, update generator types - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6666](https://redirect.github.com/vitest-dev/vitest/issues/6666) [(7a0de)](https://redirect.github.com/vitest-dev/vitest/commit/7a0de0a7)
##### [View changes on GitHub](https://redirect.github.com/vitest-dev/vitest/compare/v2.1.2...v2.1.3)
WiseLibs/better-sqlite3 (better-sqlite3)
### [`v11.5.0`](https://redirect.github.com/WiseLibs/better-sqlite3/releases/tag/v11.5.0)
[Compare Source](https://redirect.github.com/WiseLibs/better-sqlite3/compare/v11.4.0...v11.5.0)
#### What's Changed
- Added NodeJS 23 Support by [@neoxpert](https://redirect.github.com/neoxpert) in [https://github.com/WiseLibs/better-sqlite3/pull/1283](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1283)
- Update [SQLite to version 3.47.0](https://sqlite.org/releaselog/3\_47\_0.html) by [@mceachen](https://redirect.github.com/mceachen) in [https://github.com/WiseLibs/better-sqlite3/pull/1284](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1284)
**Full Changelog**: https://github.com/WiseLibs/better-sqlite3/compare/v11.4.0...v11.5.0
### [`v11.4.0`](https://redirect.github.com/WiseLibs/better-sqlite3/releases/tag/v11.4.0)
[Compare Source](https://redirect.github.com/WiseLibs/better-sqlite3/compare/v11.3.0...v11.4.0)
#### What's Changed
- Prebuild for Electron 33 by [@oliverschwendener](https://redirect.github.com/oliverschwendener) in [https://github.com/WiseLibs/better-sqlite3/pull/1279](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1279)
#### New Contributors
- [@oliverschwendener](https://redirect.github.com/oliverschwendener) made their first contribution in [https://github.com/WiseLibs/better-sqlite3/pull/1279](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1279)
**Full Changelog**: https://github.com/WiseLibs/better-sqlite3/compare/v11.3.0...v11.4.0
unjs/db0 (db0)
### [`v0.2.1`](https://redirect.github.com/unjs/db0/blob/HEAD/CHANGELOG.md#v021)
[Compare Source](https://redirect.github.com/unjs/db0/compare/v0.2.0...v0.2.1)
[compare changes](https://redirect.github.com/unjs/db0/compare/v0.2.0...v0.2.1)
##### 🩹 Fixes
- **sqlite:** Support `:memory:` ([1a40c4f](https://redirect.github.com/unjs/db0/commit/1a40c4f))
##### ❤️ Contributors
- Pooya Parsa ([@pi0](http://github.com/pi0))
drizzle-team/drizzle-orm (drizzle-orm)
### [`v0.36.0`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.36.0)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.3...0.36.0)
> This version of `drizzle-orm` requires `drizzle-kit@0.27.0` to enable all new features
### New Features
#### Row-Level Security (RLS)
With Drizzle, you can enable Row-Level Security (RLS) for any Postgres table, create policies with various options, and define and manage the roles those policies apply to.
Drizzle supports a raw representation of Postgres policies and roles that can be used in any way you want. This works with popular Postgres database providers such as `Neon` and `Supabase`.
In Drizzle, we have specific predefined RLS roles and functions for RLS with both database providers, but you can also define your own logic.
##### Enable RLS
If you just want to enable RLS on a table without adding policies, you can use `.enableRLS()`
As mentioned in the PostgreSQL documentation:
> If no policy exists for the table, a default-deny policy is used, meaning that no rows are visible or can be modified.
> Operations that apply to the whole table, such as TRUNCATE and REFERENCES, are not subject to row security.
```ts
import { integer, pgTable } from 'drizzle-orm/pg-core';
export const users = pgTable('users', {
id: integer(),
}).enableRLS();
```
> If you add a policy to a table, RLS will be enabled automatically. So, there’s no need to explicitly enable RLS when adding policies to a table.
##### Roles
Currently, Drizzle supports defining roles with a few different options, as shown below. Support for more options will be added in a future release.
```ts
import { pgRole } from 'drizzle-orm/pg-core';
export const admin = pgRole('admin', { createRole: true, createDb: true, inherit: true });
```
If a role already exists in your database, and you don’t want drizzle-kit to ‘see’ it or include it in migrations, you can mark the role as existing.
```ts
import { pgRole } from 'drizzle-orm/pg-core';
export const admin = pgRole('admin').existing();
```
##### Policies
To fully leverage RLS, you can define policies within a Drizzle table.
> In PostgreSQL, policies should be linked to an existing table. Since policies are always associated with a specific table, we decided that policy definitions should be defined as a parameter of `pgTable`
**Example of pgPolicy with all available properties**
```ts
import { sql } from 'drizzle-orm';
import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core';
export const admin = pgRole('admin');
export const users = pgTable('users', {
id: integer(),
}, (t) => [
pgPolicy('policy', {
as: 'permissive',
to: admin,
for: 'delete',
using: sql``,
withCheck: sql``,
}),
]);
```
**Link Policy to an existing table**
There are situations where you need to link a policy to an existing table in your database.
The most common use case is with database providers like `Neon` or `Supabase`, where you need to add a policy
to their existing tables. In this case, you can use the `.link()` API
```ts
import { sql } from "drizzle-orm";
import { pgPolicy } from "drizzle-orm/pg-core";
import { authenticatedRole, realtimeMessages } from "drizzle-orm/supabase";
export const policy = pgPolicy("authenticated role insert policy", {
for: "insert",
to: authenticatedRole,
using: sql``,
}).link(realtimeMessages);
```
##### Migrations
If you are using drizzle-kit to manage your schema and roles, there may be situations where you want to refer to roles that are not defined in your Drizzle schema. In such cases, you may want drizzle-kit to skip managing these roles without having to define each role in your drizzle schema and marking it with `.existing()`.
In these cases, you can use `entities.roles` in `drizzle.config.ts`. For a complete reference, refer to the the [`drizzle.config.ts`](https://orm.drizzle.team/docs/drizzle-config-file) documentation.
By default, `drizzle-kit` does not manage roles for you, so you will need to enable this feature in `drizzle.config.ts`.
```ts {12-14}
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: 'postgresql',
schema: "./drizzle/schema.ts",
dbCredentials: {
url: process.env.DATABASE_URL!
},
verbose: true,
strict: true,
entities: {
roles: true
}
});
```
In case you need additional configuration options, let's take a look at a few more examples.
**You have an `admin` role and want to exclude it from the list of manageable roles**
```ts
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
...
entities: {
roles: {
exclude: ['admin']
}
}
});
```
**You have an `admin` role and want to include it in the list of manageable roles**
```ts
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
...
entities: {
roles: {
include: ['admin']
}
}
});
```
**If you are using `Neon` and want to exclude Neon-defined roles, you can use the provider option**
```ts
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
...
entities: {
roles: {
provider: 'neon'
}
}
});
```
**If you are using `Supabase` and want to exclude Supabase-defined roles, you can use the provider option**
```ts
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
...
entities: {
roles: {
provider: 'supabase'
}
}
});
```
> You may encounter situations where Drizzle is slightly outdated compared to new roles specified by your database provider.
> In such cases, you can use the `provider` option and `exclude` additional roles:
```ts
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
...
entities: {
roles: {
provider: 'supabase',
exclude: ['new_supabase_role']
}
}
});
```
##### RLS on views
With Drizzle, you can also specify RLS policies on views. For this, you need to use `security_invoker` in the view's WITH options. Here is a small example:
```ts {5}
...
export const roomsUsersProfiles = pgView("rooms_users_profiles")
.with({
securityInvoker: true,
})
.as((qb) =>
qb
.select({
...getTableColumns(roomsUsers),
email: profiles.email,
})
.from(roomsUsers)
.innerJoin(profiles, eq(roomsUsers.userId, profiles.id))
);
```
##### Using with Neon
The Neon Team helped us implement their vision of a wrapper on top of our raw policies API. We defined a specific
`/neon` import with the `crudPolicy` function that includes predefined functions and Neon's default roles.
Here's an example of how to use the `crudPolicy` function:
```ts
import { crudPolicy } from 'drizzle-orm/neon';
import { integer, pgRole, pgTable } from 'drizzle-orm/pg-core';
export const admin = pgRole('admin');
export const users = pgTable('users', {
id: integer(),
}, (t) => [
crudPolicy({ role: admin, read: true, modify: false }),
]);
```
This policy is equivalent to:
```ts
import { sql } from 'drizzle-orm';
import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core';
export const admin = pgRole('admin');
export const users = pgTable('users', {
id: integer(),
}, (t) => [
pgPolicy(`crud-${admin.name}-policy-insert`, {
for: 'insert',
to: admin,
withCheck: sql`false`,
}),
pgPolicy(`crud-${admin.name}-policy-update`, {
for: 'update',
to: admin,
using: sql`false`,
withCheck: sql`false`,
}),
pgPolicy(`crud-${admin.name}-policy-delete`, {
for: 'delete',
to: admin,
using: sql`false`,
}),
pgPolicy(`crud-${admin.name}-policy-select`, {
for: 'select',
to: admin,
using: sql`true`,
}),
]);
```
`Neon` exposes predefined `authenticated` and `anaonymous` roles and related functions. If you are using `Neon` for RLS, you can use these roles, which are marked as existing, and the related functions in your RLS queries.
```ts
// drizzle-orm/neon
export const authenticatedRole = pgRole('authenticated').existing();
export const anonymousRole = pgRole('anonymous').existing();
export const authUid = (userIdColumn: AnyPgColumn) => sql`(select auth.user_id() = ${userIdColumn})`;
```
For example, you can use the `Neon` predefined roles and functions like this:
```ts
import { sql } from 'drizzle-orm';
import { authenticatedRole } from 'drizzle-orm/neon';
import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core';
export const admin = pgRole('admin');
export const users = pgTable('users', {
id: integer(),
}, (t) => [
pgPolicy(`policy-insert`, {
for: 'insert',
to: authenticatedRole,
withCheck: sql`false`,
}),
]);
```
##### Using with Supabase
We also have a `/supabase` import with a set of predefined roles marked as existing, which you can use in your schema.
This import will be extended in a future release with more functions and helpers to make using RLS and `Supabase` simpler.
```ts
// drizzle-orm/supabase
export const anonRole = pgRole('anon').existing();
export const authenticatedRole = pgRole('authenticated').existing();
export const serviceRole = pgRole('service_role').existing();
export const postgresRole = pgRole('postgres_role').existing();
export const supabaseAuthAdminRole = pgRole('supabase_auth_admin').existing();
```
For example, you can use the `Supabase` predefined roles like this:
```ts
import { sql } from 'drizzle-orm';
import { serviceRole } from 'drizzle-orm/supabase';
import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core';
export const admin = pgRole('admin');
export const users = pgTable('users', {
id: integer(),
}, (t) => [
pgPolicy(`policy-insert`, {
for: 'insert',
to: serviceRole,
withCheck: sql`false`,
}),
]);
```
The `/supabase` import also includes predefined tables and functions that you can use in your application
```ts
// drizzle-orm/supabase
const auth = pgSchema('auth');
export const authUsers = auth.table('users', {
id: uuid().primaryKey().notNull(),
});
const realtime = pgSchema('realtime');
export const realtimeMessages = realtime.table(
'messages',
{
id: bigserial({ mode: 'bigint' }).primaryKey(),
topic: text().notNull(),
extension: text({
enum: ['presence', 'broadcast', 'postgres_changes'],
}).notNull(),
},
);
export const authUid = sql`(select auth.uid())`;
export const realtimeTopic = sql`realtime.topic()`;
```
This allows you to use it in your code, and Drizzle Kit will treat them as existing databases,
using them only as information to connect to other entities
```ts
import { foreignKey, pgPolicy, pgTable, text, uuid } from "drizzle-orm/pg-core";
import { sql } from "drizzle-orm/sql";
import { authenticatedRole, authUsers } from "drizzle-orm/supabase";
export const profiles = pgTable(
"profiles",
{
id: uuid().primaryKey().notNull(),
email: text().notNull(),
},
(table) => [
foreignKey({
columns: [table.id],
// reference to the auth table from Supabase
foreignColumns: [authUsers.id],
name: "profiles_id_fk",
}).onDelete("cascade"),
pgPolicy("authenticated can view all profiles", {
for: "select",
// using predefined role from Supabase
to: authenticatedRole,
using: sql`true`,
}),
]
);
```
Let's check an example of adding a policy to a table that exists in `Supabase`
```ts
import { sql } from "drizzle-orm";
import { pgPolicy } from "drizzle-orm/pg-core";
import { authenticatedRole, realtimeMessages } from "drizzle-orm/supabase";
export const policy = pgPolicy("authenticated role insert policy", {
for: "insert",
to: authenticatedRole,
using: sql``,
}).link(realtimeMessages);
```
### Bug fixes
- [\[BUG\]: postgres-js driver throws error when using new { client } constructor arguments ](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3176)
### [`v0.35.3`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.3)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.2...0.35.3)
### New LibSQL driver modules
Drizzle now has native support for all `@libsql/client` driver variations:
1. `@libsql/client` - defaults to node import, automatically changes to web if target or platform is set for bundler, e.g. `esbuild --platform=browser`
```ts
import { drizzle } from 'drizzle-orm/libsql';
const db = drizzle({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
```
2. `@libsql/client/node` node compatible module, supports :memory:, file, wss, http and turso connection protocols
```ts
import { drizzle } from 'drizzle-orm/libsql/node';
const db = drizzle({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
```
3. `@libsql/client/web` module for fullstack web frameworks like next, nuxt, astro, etc.
```ts
import { drizzle } from 'drizzle-orm/libsql/web';
const db = drizzle({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
```
4. `@libsql/client/http` module for http and https connection protocols
```ts
import { drizzle } from 'drizzle-orm/libsql/http';
const db = drizzle({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
```
5. `@libsql/client/ws` module for ws and wss connection protocols
```ts
import { drizzle } from 'drizzle-orm/libsql/ws';
const db = drizzle({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
```
6. `@libsql/client/sqlite3` module for :memory: and file connection protocols
```ts
import { drizzle } from 'drizzle-orm/libsql/wasm';
const db = drizzle({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
```
7. `@libsql/client-wasm` Separate experimental package for WASM
```ts
import { drizzle } from 'drizzle-orm/libsql';
const db = drizzle({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
```
### [`v0.35.2`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.2)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.1...0.35.2)
- Fix issues with importing in several environments after updating the Drizzle driver implementation
We've added approximately 240 tests to check the ESM and CJS builds for all the drivers we have. You can check them [here](https://redirect.github.com/drizzle-team/drizzle-orm/tree/main/integration-tests/js-tests/driver-init)
- Fixed [\[BUG\]: Type Error in PgTransaction Missing $client Property After Upgrading to drizzle-orm@0.35.1](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3140)
- Fixed [\[BUG\]: New critical Build error drizzle 0.35.0 deploying on Cloudflare ](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3137)
### [`v0.35.1`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.1)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.0...0.35.1)
- Updated internal versions for the drizzle-kit and drizzle-orm packages. Changes were introduced in the last minor release, and you are required to upgrade both packages to ensure they work as expected
### [`v0.35.0`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.0)
[Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.34.1...0.35.0)
### Important change after 0.34.0 release
#### Updated the init Drizzle database API
The API from version 0.34.0 turned out to be unusable and needs to be changed. You can read more about our decisions in [this discussion](https://redirect.github.com/drizzle-team/drizzle-orm/discussions/3097)
If you still want to use the new API introduced in 0.34.0, which can create driver clients for you under the hood, you can now do so
```ts
import { drizzle } from "drizzle-orm/node-postgres";
const db = drizzle(process.env.DATABASE_URL);
// or
const db = drizzle({
connection: process.env.DATABASE_URL
});
const db = drizzle({
connection: {
user: "...",
password: "...",
host: "...",
port: 4321,
db: "...",
},
});
// if you need to pass logger or schema
const db = drizzle({
connection: process.env.DATABASE_URL,
logger: true,
schema: schema,
});
```
in order to not introduce breaking change - we will still leave support for deprecated API until V1 release.
It will degrade autocomplete performance in connection params due to `DatabaseDriver` | `ConnectionParams` types collision,
but that's a decent compromise against breaking changes
```ts
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
const client = new Pool({ connectionString: process.env.DATABASE_URL });
const db = drizzle(client); // deprecated but available
// new version
const db = drizzle({
client: client,
});
```
### New Features
#### New .orderBy() and .limit() functions in update and delete statements SQLite and MySQL
You now have more options for the `update` and `delete` query builders in MySQL and SQLite
**Example**
```ts
await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name));
await db.delete(usersTable).where(eq(usersTable.verified, false)).limit(1).orderBy(asc(usersTable.name));
```
#### New `drizzle.mock()` function
There were cases where you didn't need to provide a driver to the Drizzle object, and this served as a workaround
```ts
const db = drizzle({} as any)
```
Now you can do this using a mock function
```ts
const db = drizzle.mock()
```
There is no valid production use case for this, but we used it in situations where we needed to check types, etc., without making actual database calls or dealing with driver creation. If anyone was using it, please switch to using mocks now
### Internal updates
- Upgraded TS in codebase to the version 5.6.3
### Bug fixes
- [\[BUG\]: New $count API error with @neondatabase/serverless](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3081)
eslint/eslint (eslint)
### [`v9.14.0`](https://redirect.github.com/eslint/eslint/compare/v9.13.0...db0b844a66ee25483f9619d04346de1a2a0d79fa)
[Compare Source](https://redirect.github.com/eslint/eslint/compare/v9.13.0...v9.14.0)
### [`v9.13.0`](https://redirect.github.com/eslint/eslint/compare/v9.12.0...1a7cdbfad8d3355132aab3201c7dd3f2e879b19d)
[Compare Source](https://redirect.github.com/eslint/eslint/compare/v9.12.0...v9.13.0)
unjs/jiti (jiti)
### [`v2.4.0`](https://redirect.github.com/unjs/jiti/blob/HEAD/CHANGELOG.md#v240)
[Compare Source](https://redirect.github.com/unjs/jiti/compare/v2.3.3...v2.4.0)
[compare changes](https://redirect.github.com/unjs/jiti/compare/v2.3.3...v2.4.0)
##### 🚀 Enhancements
- Support generic type for `jiti.import` ([#331](https://redirect.github.com/unjs/jiti/pull/331))
##### 🩹 Fixes
- Try to resolve `.ts` files with `.js` extension from js files ([#337](https://redirect.github.com/unjs/jiti/pull/337))
##### 🏡 Chore
- Update renovate.json ([86f11b3](https://redirect.github.com/unjs/jiti/commit/86f11b3))
- Update deps and lockfile ([5dfb0ec](https://redirect.github.com/unjs/jiti/commit/5dfb0ec))
- Add nvmrc ([899a782](https://redirect.github.com/unjs/jiti/commit/899a782))
##### 🤖 CI
- Deno v2 compat ([f4d0062](https://redirect.github.com/unjs/jiti/commit/f4d0062))
##### ❤️ Contributors
- Pooya Parsa ([@pi0](http://github.com/pi0))
- Lars Kappert ([@webpro](http://github.com/webpro))
- Alexander brianc/node-postgres (pg)
### [`v8.13.1`](https://redirect.github.com/brianc/node-postgres/compare/pg@8.13.0...pg@8.13.1)
[Compare Source](https://redirect.github.com/brianc/node-postgres/compare/pg@8.13.0...pg@8.13.1)
pnpm/pnpm (pnpm)
### [`v9.12.3`](https://redirect.github.com/pnpm/pnpm/blob/HEAD/pnpm/CHANGELOG.md#9123)
[Compare Source](https://redirect.github.com/pnpm/pnpm/compare/v9.12.2...v9.12.3)
##### Patch Changes
- Don't purge `node_modules`, when typing "n" in the prompt that asks whether to remove `node_modules` before installation [#8655](https://redirect.github.com/pnpm/pnpm/pull/8655).
- Fix a bug causing pnpm to infinitely spawn itself when `manage-package-manager-versions=true` is set and the `.tools` directory is corrupt.
- Use `crypto.hash`, when available, for improved performance [#8629](https://redirect.github.com/pnpm/pnpm/pull/8629).
- Fixed a race condition in temporary file creation in the store by including worker thread ID in filename. Previously, multiple worker threads could attempt to use the same temporary file. Temporary files now include both process ID and thread ID for uniqueness [#8703](https://redirect.github.com/pnpm/pnpm/pull/8703).
- All commands should read settings from the `package.json` at the root of the workspace [#8667](https://redirect.github.com/pnpm/pnpm/issues/8667).
- When `manage-package-manager-versions` is set to `true`, errors spawning a self-managed version of `pnpm` will now be shown (instead of being silent).
- Pass the find command to npm, it is an alias for npm search
### [`v9.12.2`](https://redirect.github.com/pnpm/pnpm/blob/HEAD/pnpm/CHANGELOG.md#9122)
[Compare Source](https://redirect.github.com/pnpm/pnpm/compare/v9.12.1...v9.12.2)
##### Patch Changes
- When checking whether a file in the store has executable permissions, the new approach checks if at least one of the executable bits (owner, group, and others) is set to 1. Previously, a file was incorrectly considered executable only when all the executable bits were set to 1. This fix ensures that files with any executable permission, regardless of the user class, are now correctly identified as executable [#8546](https://redirect.github.com/pnpm/pnpm/issues/8546).
Configuration
📅 Schedule: Branch creation - "after 2am and before 3am" (UTC), Automerge - "after 1am and before 2am" (UTC).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
[ ] If you want to rebase/retry this PR, check this box
This PR contains the following updates:
^1.1.11
->^1.1.13
^2.1.2
->^2.1.4
^11.3.0
->^11.5.0
^0.2.0
->^0.2.1
^0.34.1
->^0.36.0
^9.12.0
->^9.14.0
^2.3.3
->^2.4.0
^8.13.0
->^8.13.1
9.12.1
->9.12.3
^2.1.2
->^2.1.4
Release Notes
vitest-dev/vitest (@vitest/coverage-v8)
### [`v2.1.4`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v2.1.4) [Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v2.1.3...v2.1.4) ##### 🚀 Features - **browser**: Allow custom HTML path, respect plugins `transformIndexHtml` - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6725](https://redirect.github.com/vitest-dev/vitest/issues/6725) [(16902)](https://redirect.github.com/vitest-dev/vitest/commit/169028f0) ##### 🐞 Bug Fixes - Don't normalize drive case letter in root - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6792](https://redirect.github.com/vitest-dev/vitest/issues/6792) [(b28cd)](https://redirect.github.com/vitest-dev/vitest/commit/b28cd2e3) - **browser**: - Fix default browser port - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6700](https://redirect.github.com/vitest-dev/vitest/issues/6700) [(9c518)](https://redirect.github.com/vitest-dev/vitest/commit/9c518c14) - Optimize expect-type - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6713](https://redirect.github.com/vitest-dev/vitest/issues/6713) [(07918)](https://redirect.github.com/vitest-dev/vitest/commit/07918538) - Don't polyfill process.env - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6718](https://redirect.github.com/vitest-dev/vitest/issues/6718) [(da6d2)](https://redirect.github.com/vitest-dev/vitest/commit/da6d2ea7) - Increment browser port automatically if there are several projects with browser.enabled - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6717](https://redirect.github.com/vitest-dev/vitest/issues/6717) [(a9397)](https://redirect.github.com/vitest-dev/vitest/commit/a939779f) - Cleanup keyboard state - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6731](https://redirect.github.com/vitest-dev/vitest/issues/6731) [(19278)](https://redirect.github.com/vitest-dev/vitest/commit/19278f4c) - Don't add `v=` queries to setup files imports - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6759](https://redirect.github.com/vitest-dev/vitest/issues/6759) [(b8258)](https://redirect.github.com/vitest-dev/vitest/commit/b82584c9) - User event cleanup on retry - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6764](https://redirect.github.com/vitest-dev/vitest/issues/6764) [(bdd15)](https://redirect.github.com/vitest-dev/vitest/commit/bdd15dd1) - Ignore non mocked msw requests - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6770](https://redirect.github.com/vitest-dev/vitest/issues/6770) [(9d9ba)](https://redirect.github.com/vitest-dev/vitest/commit/9d9bad5b) - Initiate MSW in the same frame as tests - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6772](https://redirect.github.com/vitest-dev/vitest/issues/6772) [(2444f)](https://redirect.github.com/vitest-dev/vitest/commit/2444ff22) - **deps**: - Update dependency sirv to v3 - in [https://github.com/vitest-dev/vitest/issues/6701](https://redirect.github.com/vitest-dev/vitest/issues/6701) [(fde5d)](https://redirect.github.com/vitest-dev/vitest/commit/fde5d509) - **expect**: - Correct behavior of `toThrowError` with empty string parameter - by [@shulaoda](https://redirect.github.com/shulaoda) in [https://github.com/vitest-dev/vitest/issues/6710](https://redirect.github.com/vitest-dev/vitest/issues/6710) [(a6129)](https://redirect.github.com/vitest-dev/vitest/commit/a61293e9) - **mocker**: - Remove spy from peer dependencies - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6777](https://redirect.github.com/vitest-dev/vitest/issues/6777) [(3a8b5)](https://redirect.github.com/vitest-dev/vitest/commit/3a8b56bf) - **vitest**: - Clarify slowTestThreshold, print slow tests in non-TTY mode - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6715](https://redirect.github.com/vitest-dev/vitest/issues/6715) [(2e6aa)](https://redirect.github.com/vitest-dev/vitest/commit/2e6aa647) - Print warnings form Vite plugins - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6724](https://redirect.github.com/vitest-dev/vitest/issues/6724) [(121b1)](https://redirect.github.com/vitest-dev/vitest/commit/121b161f) - Don't fail if the working directory starts with a lowercase drive letter - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6779](https://redirect.github.com/vitest-dev/vitest/issues/6779) [(df6d7)](https://redirect.github.com/vitest-dev/vitest/commit/df6d750b) - Silence import analysis warning - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6785](https://redirect.github.com/vitest-dev/vitest/issues/6785) [(39041)](https://redirect.github.com/vitest-dev/vitest/commit/39041ee5) - **vitest,runner**: - Simplify `test.extend` type exports - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6707](https://redirect.github.com/vitest-dev/vitest/issues/6707) [(e5c38)](https://redirect.github.com/vitest-dev/vitest/commit/e5c388f0) ##### 🏎 Performance - Use `hash` to replace `createHash` - by [@btea](https://redirect.github.com/btea) in [https://github.com/vitest-dev/vitest/issues/6703](https://redirect.github.com/vitest-dev/vitest/issues/6703) [(5d07b)](https://redirect.github.com/vitest-dev/vitest/commit/5d07bba6) ##### [View changes on GitHub](https://redirect.github.com/vitest-dev/vitest/compare/v2.1.3...v2.1.4) ### [`v2.1.3`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v2.1.3) [Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v2.1.2...v2.1.3) ##### 🐞 Bug Fixes - Fix error diff of `toBeNaN, toBeUndefined, toBeNull, toBeTruthy, toBeFalsy` - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6697](https://redirect.github.com/vitest-dev/vitest/issues/6697) [(e0027)](https://redirect.github.com/vitest-dev/vitest/commit/e002758c) - **browser**: - Provide aria role intellisense - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6629](https://redirect.github.com/vitest-dev/vitest/issues/6629) [(f36ea)](https://redirect.github.com/vitest-dev/vitest/commit/f36eac77) - Not.toBeInTheDocument works with locators API - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6634](https://redirect.github.com/vitest-dev/vitest/issues/6634) [(8bef5)](https://redirect.github.com/vitest-dev/vitest/commit/8bef5d2b) - Use `/mockServiceWorker.js` instead of `/__vitest_msw__` - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6687](https://redirect.github.com/vitest-dev/vitest/issues/6687) [(4b2ce)](https://redirect.github.com/vitest-dev/vitest/commit/4b2ce07f) - Don't override the esbuild option in the browser mode - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6692](https://redirect.github.com/vitest-dev/vitest/issues/6692) [(d131f)](https://redirect.github.com/vitest-dev/vitest/commit/d131fd64) - **expect**: - Preserve prototype in `toMatchObject` diff - by [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6620](https://redirect.github.com/vitest-dev/vitest/issues/6620) [(d289e)](https://redirect.github.com/vitest-dev/vitest/commit/d289e7eb) - **mocker**: - Specify correct spy dependency - by [@sheremet-va](https://redirect.github.com/sheremet-va) [(7e958)](https://redirect.github.com/vitest-dev/vitest/commit/7e9584aa) - **runner**: - Ensure sequential suite overrides sequence.concurrent - by [@dsyddall](https://redirect.github.com/dsyddall) and [@hi-ogawa](https://redirect.github.com/hi-ogawa) in [https://github.com/vitest-dev/vitest/issues/6653](https://redirect.github.com/vitest-dev/vitest/issues/6653) [(5e6de)](https://redirect.github.com/vitest-dev/vitest/commit/5e6de274) - **vitest**: - Deprecate UserConfig in favor of ViteUserConfig - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6626](https://redirect.github.com/vitest-dev/vitest/issues/6626) [(496bd)](https://redirect.github.com/vitest-dev/vitest/commit/496bd251) - Don't hang with maxConcurrency 0 - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6627](https://redirect.github.com/vitest-dev/vitest/issues/6627) [(946d8)](https://redirect.github.com/vitest-dev/vitest/commit/946d8bb1) - Deprecate old task types and node-reliant types - by [@sheremet-va](https://redirect.github.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/6632](https://redirect.github.com/vitest-dev/vitest/issues/6632) [(00045)](https://redirect.github.com/vitest-dev/vitest/commit/000459a9) - Fix `WiseLibs/better-sqlite3 (better-sqlite3)
### [`v11.5.0`](https://redirect.github.com/WiseLibs/better-sqlite3/releases/tag/v11.5.0) [Compare Source](https://redirect.github.com/WiseLibs/better-sqlite3/compare/v11.4.0...v11.5.0) #### What's Changed - Added NodeJS 23 Support by [@neoxpert](https://redirect.github.com/neoxpert) in [https://github.com/WiseLibs/better-sqlite3/pull/1283](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1283) - Update [SQLite to version 3.47.0](https://sqlite.org/releaselog/3\_47\_0.html) by [@mceachen](https://redirect.github.com/mceachen) in [https://github.com/WiseLibs/better-sqlite3/pull/1284](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1284) **Full Changelog**: https://github.com/WiseLibs/better-sqlite3/compare/v11.4.0...v11.5.0 ### [`v11.4.0`](https://redirect.github.com/WiseLibs/better-sqlite3/releases/tag/v11.4.0) [Compare Source](https://redirect.github.com/WiseLibs/better-sqlite3/compare/v11.3.0...v11.4.0) #### What's Changed - Prebuild for Electron 33 by [@oliverschwendener](https://redirect.github.com/oliverschwendener) in [https://github.com/WiseLibs/better-sqlite3/pull/1279](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1279) #### New Contributors - [@oliverschwendener](https://redirect.github.com/oliverschwendener) made their first contribution in [https://github.com/WiseLibs/better-sqlite3/pull/1279](https://redirect.github.com/WiseLibs/better-sqlite3/pull/1279) **Full Changelog**: https://github.com/WiseLibs/better-sqlite3/compare/v11.3.0...v11.4.0unjs/db0 (db0)
### [`v0.2.1`](https://redirect.github.com/unjs/db0/blob/HEAD/CHANGELOG.md#v021) [Compare Source](https://redirect.github.com/unjs/db0/compare/v0.2.0...v0.2.1) [compare changes](https://redirect.github.com/unjs/db0/compare/v0.2.0...v0.2.1) ##### 🩹 Fixes - **sqlite:** Support `:memory:` ([1a40c4f](https://redirect.github.com/unjs/db0/commit/1a40c4f)) ##### ❤️ Contributors - Pooya Parsa ([@pi0](http://github.com/pi0))drizzle-team/drizzle-orm (drizzle-orm)
### [`v0.36.0`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.36.0) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.3...0.36.0) > This version of `drizzle-orm` requires `drizzle-kit@0.27.0` to enable all new features ### New Features #### Row-Level Security (RLS) With Drizzle, you can enable Row-Level Security (RLS) for any Postgres table, create policies with various options, and define and manage the roles those policies apply to. Drizzle supports a raw representation of Postgres policies and roles that can be used in any way you want. This works with popular Postgres database providers such as `Neon` and `Supabase`. In Drizzle, we have specific predefined RLS roles and functions for RLS with both database providers, but you can also define your own logic. ##### Enable RLS If you just want to enable RLS on a table without adding policies, you can use `.enableRLS()` As mentioned in the PostgreSQL documentation: > If no policy exists for the table, a default-deny policy is used, meaning that no rows are visible or can be modified. > Operations that apply to the whole table, such as TRUNCATE and REFERENCES, are not subject to row security. ```ts import { integer, pgTable } from 'drizzle-orm/pg-core'; export const users = pgTable('users', { id: integer(), }).enableRLS(); ``` > If you add a policy to a table, RLS will be enabled automatically. So, there’s no need to explicitly enable RLS when adding policies to a table. ##### Roles Currently, Drizzle supports defining roles with a few different options, as shown below. Support for more options will be added in a future release. ```ts import { pgRole } from 'drizzle-orm/pg-core'; export const admin = pgRole('admin', { createRole: true, createDb: true, inherit: true }); ``` If a role already exists in your database, and you don’t want drizzle-kit to ‘see’ it or include it in migrations, you can mark the role as existing. ```ts import { pgRole } from 'drizzle-orm/pg-core'; export const admin = pgRole('admin').existing(); ``` ##### Policies To fully leverage RLS, you can define policies within a Drizzle table. > In PostgreSQL, policies should be linked to an existing table. Since policies are always associated with a specific table, we decided that policy definitions should be defined as a parameter of `pgTable` **Example of pgPolicy with all available properties** ```ts import { sql } from 'drizzle-orm'; import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core'; export const admin = pgRole('admin'); export const users = pgTable('users', { id: integer(), }, (t) => [ pgPolicy('policy', { as: 'permissive', to: admin, for: 'delete', using: sql``, withCheck: sql``, }), ]); ``` **Link Policy to an existing table** There are situations where you need to link a policy to an existing table in your database. The most common use case is with database providers like `Neon` or `Supabase`, where you need to add a policy to their existing tables. In this case, you can use the `.link()` API ```ts import { sql } from "drizzle-orm"; import { pgPolicy } from "drizzle-orm/pg-core"; import { authenticatedRole, realtimeMessages } from "drizzle-orm/supabase"; export const policy = pgPolicy("authenticated role insert policy", { for: "insert", to: authenticatedRole, using: sql``, }).link(realtimeMessages); ``` ##### Migrations If you are using drizzle-kit to manage your schema and roles, there may be situations where you want to refer to roles that are not defined in your Drizzle schema. In such cases, you may want drizzle-kit to skip managing these roles without having to define each role in your drizzle schema and marking it with `.existing()`. In these cases, you can use `entities.roles` in `drizzle.config.ts`. For a complete reference, refer to the the [`drizzle.config.ts`](https://orm.drizzle.team/docs/drizzle-config-file) documentation. By default, `drizzle-kit` does not manage roles for you, so you will need to enable this feature in `drizzle.config.ts`. ```ts {12-14} // drizzle.config.ts import { defineConfig } from "drizzle-kit"; export default defineConfig({ dialect: 'postgresql', schema: "./drizzle/schema.ts", dbCredentials: { url: process.env.DATABASE_URL! }, verbose: true, strict: true, entities: { roles: true } }); ``` In case you need additional configuration options, let's take a look at a few more examples. **You have an `admin` role and want to exclude it from the list of manageable roles** ```ts // drizzle.config.ts import { defineConfig } from "drizzle-kit"; export default defineConfig({ ... entities: { roles: { exclude: ['admin'] } } }); ``` **You have an `admin` role and want to include it in the list of manageable roles** ```ts // drizzle.config.ts import { defineConfig } from "drizzle-kit"; export default defineConfig({ ... entities: { roles: { include: ['admin'] } } }); ``` **If you are using `Neon` and want to exclude Neon-defined roles, you can use the provider option** ```ts // drizzle.config.ts import { defineConfig } from "drizzle-kit"; export default defineConfig({ ... entities: { roles: { provider: 'neon' } } }); ``` **If you are using `Supabase` and want to exclude Supabase-defined roles, you can use the provider option** ```ts // drizzle.config.ts import { defineConfig } from "drizzle-kit"; export default defineConfig({ ... entities: { roles: { provider: 'supabase' } } }); ``` > You may encounter situations where Drizzle is slightly outdated compared to new roles specified by your database provider. > In such cases, you can use the `provider` option and `exclude` additional roles: ```ts // drizzle.config.ts import { defineConfig } from "drizzle-kit"; export default defineConfig({ ... entities: { roles: { provider: 'supabase', exclude: ['new_supabase_role'] } } }); ``` ##### RLS on views With Drizzle, you can also specify RLS policies on views. For this, you need to use `security_invoker` in the view's WITH options. Here is a small example: ```ts {5} ... export const roomsUsersProfiles = pgView("rooms_users_profiles") .with({ securityInvoker: true, }) .as((qb) => qb .select({ ...getTableColumns(roomsUsers), email: profiles.email, }) .from(roomsUsers) .innerJoin(profiles, eq(roomsUsers.userId, profiles.id)) ); ``` ##### Using with Neon The Neon Team helped us implement their vision of a wrapper on top of our raw policies API. We defined a specific `/neon` import with the `crudPolicy` function that includes predefined functions and Neon's default roles. Here's an example of how to use the `crudPolicy` function: ```ts import { crudPolicy } from 'drizzle-orm/neon'; import { integer, pgRole, pgTable } from 'drizzle-orm/pg-core'; export const admin = pgRole('admin'); export const users = pgTable('users', { id: integer(), }, (t) => [ crudPolicy({ role: admin, read: true, modify: false }), ]); ``` This policy is equivalent to: ```ts import { sql } from 'drizzle-orm'; import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core'; export const admin = pgRole('admin'); export const users = pgTable('users', { id: integer(), }, (t) => [ pgPolicy(`crud-${admin.name}-policy-insert`, { for: 'insert', to: admin, withCheck: sql`false`, }), pgPolicy(`crud-${admin.name}-policy-update`, { for: 'update', to: admin, using: sql`false`, withCheck: sql`false`, }), pgPolicy(`crud-${admin.name}-policy-delete`, { for: 'delete', to: admin, using: sql`false`, }), pgPolicy(`crud-${admin.name}-policy-select`, { for: 'select', to: admin, using: sql`true`, }), ]); ``` `Neon` exposes predefined `authenticated` and `anaonymous` roles and related functions. If you are using `Neon` for RLS, you can use these roles, which are marked as existing, and the related functions in your RLS queries. ```ts // drizzle-orm/neon export const authenticatedRole = pgRole('authenticated').existing(); export const anonymousRole = pgRole('anonymous').existing(); export const authUid = (userIdColumn: AnyPgColumn) => sql`(select auth.user_id() = ${userIdColumn})`; ``` For example, you can use the `Neon` predefined roles and functions like this: ```ts import { sql } from 'drizzle-orm'; import { authenticatedRole } from 'drizzle-orm/neon'; import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core'; export const admin = pgRole('admin'); export const users = pgTable('users', { id: integer(), }, (t) => [ pgPolicy(`policy-insert`, { for: 'insert', to: authenticatedRole, withCheck: sql`false`, }), ]); ``` ##### Using with Supabase We also have a `/supabase` import with a set of predefined roles marked as existing, which you can use in your schema. This import will be extended in a future release with more functions and helpers to make using RLS and `Supabase` simpler. ```ts // drizzle-orm/supabase export const anonRole = pgRole('anon').existing(); export const authenticatedRole = pgRole('authenticated').existing(); export const serviceRole = pgRole('service_role').existing(); export const postgresRole = pgRole('postgres_role').existing(); export const supabaseAuthAdminRole = pgRole('supabase_auth_admin').existing(); ``` For example, you can use the `Supabase` predefined roles like this: ```ts import { sql } from 'drizzle-orm'; import { serviceRole } from 'drizzle-orm/supabase'; import { integer, pgPolicy, pgRole, pgTable } from 'drizzle-orm/pg-core'; export const admin = pgRole('admin'); export const users = pgTable('users', { id: integer(), }, (t) => [ pgPolicy(`policy-insert`, { for: 'insert', to: serviceRole, withCheck: sql`false`, }), ]); ``` The `/supabase` import also includes predefined tables and functions that you can use in your application ```ts // drizzle-orm/supabase const auth = pgSchema('auth'); export const authUsers = auth.table('users', { id: uuid().primaryKey().notNull(), }); const realtime = pgSchema('realtime'); export const realtimeMessages = realtime.table( 'messages', { id: bigserial({ mode: 'bigint' }).primaryKey(), topic: text().notNull(), extension: text({ enum: ['presence', 'broadcast', 'postgres_changes'], }).notNull(), }, ); export const authUid = sql`(select auth.uid())`; export const realtimeTopic = sql`realtime.topic()`; ``` This allows you to use it in your code, and Drizzle Kit will treat them as existing databases, using them only as information to connect to other entities ```ts import { foreignKey, pgPolicy, pgTable, text, uuid } from "drizzle-orm/pg-core"; import { sql } from "drizzle-orm/sql"; import { authenticatedRole, authUsers } from "drizzle-orm/supabase"; export const profiles = pgTable( "profiles", { id: uuid().primaryKey().notNull(), email: text().notNull(), }, (table) => [ foreignKey({ columns: [table.id], // reference to the auth table from Supabase foreignColumns: [authUsers.id], name: "profiles_id_fk", }).onDelete("cascade"), pgPolicy("authenticated can view all profiles", { for: "select", // using predefined role from Supabase to: authenticatedRole, using: sql`true`, }), ] ); ``` Let's check an example of adding a policy to a table that exists in `Supabase` ```ts import { sql } from "drizzle-orm"; import { pgPolicy } from "drizzle-orm/pg-core"; import { authenticatedRole, realtimeMessages } from "drizzle-orm/supabase"; export const policy = pgPolicy("authenticated role insert policy", { for: "insert", to: authenticatedRole, using: sql``, }).link(realtimeMessages); ``` ### Bug fixes - [\[BUG\]: postgres-js driver throws error when using new { client } constructor arguments ](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3176) ### [`v0.35.3`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.3) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.2...0.35.3) ### New LibSQL driver modules Drizzle now has native support for all `@libsql/client` driver variations: 1. `@libsql/client` - defaults to node import, automatically changes to web if target or platform is set for bundler, e.g. `esbuild --platform=browser` ```ts import { drizzle } from 'drizzle-orm/libsql'; const db = drizzle({ connection: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }}); ``` 2. `@libsql/client/node` node compatible module, supports :memory:, file, wss, http and turso connection protocols ```ts import { drizzle } from 'drizzle-orm/libsql/node'; const db = drizzle({ connection: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }}); ``` 3. `@libsql/client/web` module for fullstack web frameworks like next, nuxt, astro, etc. ```ts import { drizzle } from 'drizzle-orm/libsql/web'; const db = drizzle({ connection: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }}); ``` 4. `@libsql/client/http` module for http and https connection protocols ```ts import { drizzle } from 'drizzle-orm/libsql/http'; const db = drizzle({ connection: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }}); ``` 5. `@libsql/client/ws` module for ws and wss connection protocols ```ts import { drizzle } from 'drizzle-orm/libsql/ws'; const db = drizzle({ connection: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }}); ``` 6. `@libsql/client/sqlite3` module for :memory: and file connection protocols ```ts import { drizzle } from 'drizzle-orm/libsql/wasm'; const db = drizzle({ connection: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }}); ``` 7. `@libsql/client-wasm` Separate experimental package for WASM ```ts import { drizzle } from 'drizzle-orm/libsql'; const db = drizzle({ connection: { url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }}); ``` ### [`v0.35.2`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.2) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.1...0.35.2) - Fix issues with importing in several environments after updating the Drizzle driver implementation We've added approximately 240 tests to check the ESM and CJS builds for all the drivers we have. You can check them [here](https://redirect.github.com/drizzle-team/drizzle-orm/tree/main/integration-tests/js-tests/driver-init) - Fixed [\[BUG\]: Type Error in PgTransaction Missing $client Property After Upgrading to drizzle-orm@0.35.1](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3140) - Fixed [\[BUG\]: New critical Build error drizzle 0.35.0 deploying on Cloudflare ](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3137) ### [`v0.35.1`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.1) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.35.0...0.35.1) - Updated internal versions for the drizzle-kit and drizzle-orm packages. Changes were introduced in the last minor release, and you are required to upgrade both packages to ensure they work as expected ### [`v0.35.0`](https://redirect.github.com/drizzle-team/drizzle-orm/releases/tag/0.35.0) [Compare Source](https://redirect.github.com/drizzle-team/drizzle-orm/compare/0.34.1...0.35.0) ### Important change after 0.34.0 release #### Updated the init Drizzle database API The API from version 0.34.0 turned out to be unusable and needs to be changed. You can read more about our decisions in [this discussion](https://redirect.github.com/drizzle-team/drizzle-orm/discussions/3097) If you still want to use the new API introduced in 0.34.0, which can create driver clients for you under the hood, you can now do so ```ts import { drizzle } from "drizzle-orm/node-postgres"; const db = drizzle(process.env.DATABASE_URL); // or const db = drizzle({ connection: process.env.DATABASE_URL }); const db = drizzle({ connection: { user: "...", password: "...", host: "...", port: 4321, db: "...", }, }); // if you need to pass logger or schema const db = drizzle({ connection: process.env.DATABASE_URL, logger: true, schema: schema, }); ``` in order to not introduce breaking change - we will still leave support for deprecated API until V1 release. It will degrade autocomplete performance in connection params due to `DatabaseDriver` | `ConnectionParams` types collision, but that's a decent compromise against breaking changes ```ts import { drizzle } from "drizzle-orm/node-postgres"; import { Pool } from "pg"; const client = new Pool({ connectionString: process.env.DATABASE_URL }); const db = drizzle(client); // deprecated but available // new version const db = drizzle({ client: client, }); ``` ### New Features #### New .orderBy() and .limit() functions in update and delete statements SQLite and MySQL You now have more options for the `update` and `delete` query builders in MySQL and SQLite **Example** ```ts await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)); await db.delete(usersTable).where(eq(usersTable.verified, false)).limit(1).orderBy(asc(usersTable.name)); ``` #### New `drizzle.mock()` function There were cases where you didn't need to provide a driver to the Drizzle object, and this served as a workaround ```ts const db = drizzle({} as any) ``` Now you can do this using a mock function ```ts const db = drizzle.mock() ``` There is no valid production use case for this, but we used it in situations where we needed to check types, etc., without making actual database calls or dealing with driver creation. If anyone was using it, please switch to using mocks now ### Internal updates - Upgraded TS in codebase to the version 5.6.3 ### Bug fixes - [\[BUG\]: New $count API error with @neondatabase/serverless](https://redirect.github.com/drizzle-team/drizzle-orm/issues/3081)eslint/eslint (eslint)
### [`v9.14.0`](https://redirect.github.com/eslint/eslint/compare/v9.13.0...db0b844a66ee25483f9619d04346de1a2a0d79fa) [Compare Source](https://redirect.github.com/eslint/eslint/compare/v9.13.0...v9.14.0) ### [`v9.13.0`](https://redirect.github.com/eslint/eslint/compare/v9.12.0...1a7cdbfad8d3355132aab3201c7dd3f2e879b19d) [Compare Source](https://redirect.github.com/eslint/eslint/compare/v9.12.0...v9.13.0)unjs/jiti (jiti)
### [`v2.4.0`](https://redirect.github.com/unjs/jiti/blob/HEAD/CHANGELOG.md#v240) [Compare Source](https://redirect.github.com/unjs/jiti/compare/v2.3.3...v2.4.0) [compare changes](https://redirect.github.com/unjs/jiti/compare/v2.3.3...v2.4.0) ##### 🚀 Enhancements - Support generic type for `jiti.importbrianc/node-postgres (pg)
### [`v8.13.1`](https://redirect.github.com/brianc/node-postgres/compare/pg@8.13.0...pg@8.13.1) [Compare Source](https://redirect.github.com/brianc/node-postgres/compare/pg@8.13.0...pg@8.13.1)pnpm/pnpm (pnpm)
### [`v9.12.3`](https://redirect.github.com/pnpm/pnpm/blob/HEAD/pnpm/CHANGELOG.md#9123) [Compare Source](https://redirect.github.com/pnpm/pnpm/compare/v9.12.2...v9.12.3) ##### Patch Changes - Don't purge `node_modules`, when typing "n" in the prompt that asks whether to remove `node_modules` before installation [#8655](https://redirect.github.com/pnpm/pnpm/pull/8655). - Fix a bug causing pnpm to infinitely spawn itself when `manage-package-manager-versions=true` is set and the `.tools` directory is corrupt. - Use `crypto.hash`, when available, for improved performance [#8629](https://redirect.github.com/pnpm/pnpm/pull/8629). - Fixed a race condition in temporary file creation in the store by including worker thread ID in filename. Previously, multiple worker threads could attempt to use the same temporary file. Temporary files now include both process ID and thread ID for uniqueness [#8703](https://redirect.github.com/pnpm/pnpm/pull/8703). - All commands should read settings from the `package.json` at the root of the workspace [#8667](https://redirect.github.com/pnpm/pnpm/issues/8667). - When `manage-package-manager-versions` is set to `true`, errors spawning a self-managed version of `pnpm` will now be shown (instead of being silent). - Pass the find command to npm, it is an alias for npm search ### [`v9.12.2`](https://redirect.github.com/pnpm/pnpm/blob/HEAD/pnpm/CHANGELOG.md#9122) [Compare Source](https://redirect.github.com/pnpm/pnpm/compare/v9.12.1...v9.12.2) ##### Patch Changes - When checking whether a file in the store has executable permissions, the new approach checks if at least one of the executable bits (owner, group, and others) is set to 1. Previously, a file was incorrectly considered executable only when all the executable bits were set to 1. This fix ensures that files with any executable permission, regardless of the user class, are now correctly identified as executable [#8546](https://redirect.github.com/pnpm/pnpm/issues/8546).Configuration
📅 Schedule: Branch creation - "after 2am and before 3am" (UTC), Automerge - "after 1am and before 2am" (UTC).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR was generated by Mend Renovate. View the repository job log.