chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# Release flow
|
||||
|
||||
- Push feature branch
|
||||
- GitHub workflow publishes new feature tag to NPM
|
||||
- Bump package versions manually
|
||||
- (Optional) Create and merge PR to beta
|
||||
- (Optional) GitHub workflow publishes new beta version to NPM
|
||||
- Create PR to main
|
||||
- TODO: GitHub workflow checks if changelog is present for every package version
|
||||
- Resolve all conflicts, bump versions if necessary
|
||||
- Merge PR
|
||||
- GitHub workflow publishes new latest version to NPM and removes feature tag from NPM
|
||||
@@ -0,0 +1,53 @@
|
||||
`drizzle-arktype` is a plugin for [Drizzle ORM](https://github.com/drizzle-team/drizzle-orm) that allows you to generate [arktype](https://arktype.io/) schemas from Drizzle ORM schemas.
|
||||
|
||||
**Features**
|
||||
|
||||
- Create a select schema for tables, views and enums.
|
||||
- Create insert and update schemas for tables.
|
||||
- Supports all dialects: PostgreSQL, MySQL and SQLite.
|
||||
|
||||
# Usage
|
||||
|
||||
```ts
|
||||
import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
|
||||
import { createInsertSchema, createSelectSchema } from 'drizzle-arktype';
|
||||
import { type } from 'arktype';
|
||||
|
||||
const users = pgTable('users', {
|
||||
id: serial('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
email: text('email').notNull(),
|
||||
role: text('role', { enum: ['admin', 'user'] }).notNull(),
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
});
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
const insertUserSchema = createInsertSchema(users);
|
||||
|
||||
// Schema for updating a user - can be used to validate API requests
|
||||
const updateUserSchema = createUpdateSchema(users);
|
||||
|
||||
// Schema for selecting a user - can be used to validate API responses
|
||||
const selectUserSchema = createSelectSchema(users);
|
||||
|
||||
// Overriding the fields
|
||||
const insertUserSchema = createInsertSchema(users, {
|
||||
role: type('string'),
|
||||
});
|
||||
|
||||
// Refining the fields - useful if you want to change the fields before they become nullable/optional in the final schema
|
||||
const insertUserSchema = createInsertSchema(users, {
|
||||
id: (schema) => schema.atLeast(1),
|
||||
role: type('string'),
|
||||
});
|
||||
|
||||
// Usage
|
||||
|
||||
const isUserValid = parse(insertUserSchema, {
|
||||
name: 'John Doe',
|
||||
email: 'johndoe@test.com',
|
||||
role: 'admin',
|
||||
});
|
||||
```
|
||||
|
||||
thanks @L-Mario564
|
||||
@@ -0,0 +1,3 @@
|
||||
- TS language server performance improvements
|
||||
- Fixed [Buffer is not defined using drizzle-arktype client side with vite](https://github.com/drizzle-team/drizzle-orm/issues/4383)
|
||||
- Fixed [[BUG]: drizzle-arktype Buffer is undefined](https://github.com/drizzle-team/drizzle-orm/issues/4371)
|
||||
@@ -0,0 +1,2 @@
|
||||
- Fixed a bug in PostgreSQL with push and introspect where the `schemaFilter` object was passed. It was detecting enums even in schemas that were not defined in the schemaFilter.
|
||||
- Fixed the `drizzle-kit up` command to work as expected, starting from the sequences release.
|
||||
@@ -0,0 +1,24 @@
|
||||
## Breaking changes (for SQLite users)
|
||||
|
||||
#### Fixed [Composite primary key order is not consistent](https://github.com/drizzle-team/drizzle-kit-mirror/issues/342) by removing `sort` in SQLite and to be consistant with the same logic in PostgreSQL and MySQL
|
||||
|
||||
The issue that may arise for SQLite users with any driver using composite primary keys is that the order in the database may differ from the Drizzle schema.
|
||||
|
||||
- If you are using `push`, you **MAY** be prompted to update your table with a new order of columns in the composite primary key. You will need to either change it manually in the database or push the changes, but this may lead to data loss, etc.
|
||||
|
||||
- If you are using `generate`, you **MAY** also be prompted to update your table with a new order of columns in the composite primary key. You can either keep that migration or skip it by emptying the SQL migration file.
|
||||
|
||||
If nothing works for you and you are blocked, please reach out to me @AndriiSherman. I will try to help you!
|
||||
|
||||
|
||||
## Bug fixes
|
||||
|
||||
- [[BUG] When using double type columns, import is not inserted](https://github.com/drizzle-team/drizzle-kit-mirror/issues/403) - thanks @Karibash
|
||||
- [[BUG] A number value is specified as the default for a column of type char](https://github.com/drizzle-team/drizzle-kit-mirror/issues/404) - thanks @Karibash
|
||||
- [[BUG]: Array default in migrations are wrong](https://github.com/drizzle-team/drizzle-orm/issues/2621) - thanks @L-Mario564
|
||||
- [[FEATURE]: Simpler default array fields](https://github.com/drizzle-team/drizzle-orm/issues/2709) - thanks @L-Mario564
|
||||
- [[BUG]: drizzle-kit generate succeeds but generates invalid SQL for default([]) - Postgres](https://github.com/drizzle-team/drizzle-orm/issues/2432) - thanks @L-Mario564
|
||||
- [[BUG]: Incorrect type for array column default value](https://github.com/drizzle-team/drizzle-orm/issues/2334) - thanks @L-Mario564
|
||||
- [[BUG]: error: column is of type integer[] but default expression is of type integer](https://github.com/drizzle-team/drizzle-orm/issues/2224) - thanks @L-Mario564
|
||||
- [[BUG]: Default value in array generating wrong migration file](https://github.com/drizzle-team/drizzle-orm/issues/1003) - thanks @L-Mario564
|
||||
- [[BUG]: enum as array, not possible?](https://github.com/drizzle-team/drizzle-orm/issues/1564) - thanks @L-Mario564
|
||||
@@ -0,0 +1,32 @@
|
||||
## Bug fixes
|
||||
|
||||
> Big thanks to @L-Mario564 for his [PR](https://github.com/drizzle-team/drizzle-orm/pull/2804). It conflicted in most cases with a PR that was merged, but we incorporated some of his logic. Merging it would have caused more problems and taken more time to resolve, so we just took a few things from his PR, like removing "::<type>" mappings in introspect and some array type default handlers
|
||||
|
||||
### What was fixed
|
||||
|
||||
1. The Drizzle Kit CLI was not working properly for the `introspect` command.
|
||||
2. Added the ability to use column names with special characters for all dialects.
|
||||
3. Included PostgreSQL sequences in the introspection process.
|
||||
4. Reworked array type introspection and added all test cases.
|
||||
5. Fixed all (we hope) default issues in PostgreSQL, where `::<type>` was included in the introspected output.
|
||||
6. `preserve` casing option was broken
|
||||
|
||||
### Tickets that were closed
|
||||
|
||||
- [[BUG]: invalid schema generation with drizzle-kit introspect:pg](https://github.com/drizzle-team/drizzle-orm/issues/1210)
|
||||
- [[BUG][mysql introspection]: TS error when introspect column including colon](https://github.com/drizzle-team/drizzle-orm/issues/1928)
|
||||
- [[BUG]: Unhandled defaults when introspecting postgres db](https://github.com/drizzle-team/drizzle-orm/issues/1625)
|
||||
- [[BUG]: PostgreSQL Enum Naming and Schema Typing Issue](https://github.com/drizzle-team/drizzle-orm/issues/2315)
|
||||
- [[BUG]: drizzle-kit instrospect command generates syntax error on varchar column types](https://github.com/drizzle-team/drizzle-orm/issues/2714)
|
||||
- [[BUG]: Introspecting varchar[] type produces syntactically invalid schema.ts](https://github.com/drizzle-team/drizzle-orm/issues/1633)
|
||||
- [[BUG]: introspect:pg column not using generated enum name](https://github.com/drizzle-team/drizzle-orm/issues/1648)
|
||||
- [[BUG]: drizzle-kit introspect casing "preserve" config not working](https://github.com/drizzle-team/drizzle-orm/issues/2773)
|
||||
- [[BUG]: drizzle-kit introspect fails on required param that is defined](https://github.com/drizzle-team/drizzle-orm/issues/2719)
|
||||
- [[BUG]: Error when running npx drizzle-kit introspect: "Expected object, received string"](https://github.com/drizzle-team/drizzle-orm/issues/2657)
|
||||
- [[BUG]: Missing index names when running introspect command [MYSQL]](https://github.com/drizzle-team/drizzle-orm/issues/2525)
|
||||
- [[BUG]: drizzle-kit introspect TypeError: Cannot read properties of undefined (reading 'toLowerCase')](https://github.com/drizzle-team/drizzle-orm/issues/2338)
|
||||
- [[BUG]: Wrong column name when using PgEnum.array()](https://github.com/drizzle-team/drizzle-orm/issues/2100)
|
||||
- [[BUG]: Incorrect Schema Generated when introspecting extisting pg database](https://github.com/drizzle-team/drizzle-orm/issues/1985)
|
||||
- [[⚠️🐞BUG]: index() missing argument after introspection, causes tsc error that fails the build](https://github.com/drizzle-team/drizzle-orm/issues/1870)
|
||||
- [[BUG]: drizzle-kit introspect small errors](https://github.com/drizzle-team/drizzle-orm/issues/1738)
|
||||
- [[BUG]: Missing bigint import in drizzle-kit introspect](https://github.com/drizzle-team/drizzle-orm/issues/1020)
|
||||
@@ -0,0 +1,24 @@
|
||||
## New Features
|
||||
|
||||
### 🎉 Support for `pglite` driver
|
||||
|
||||
You can now use pglite with all drizzle-kit commands, including Drizzle Studio!
|
||||
|
||||
```ts
|
||||
import { defineConfig } from "drizzle-kit";
|
||||
|
||||
export default defineConfig({
|
||||
dialect: "postgresql",
|
||||
driver: "pglite",
|
||||
schema: "./schema.ts",
|
||||
dbCredentials: {
|
||||
url: "local-pg.db",
|
||||
},
|
||||
verbose: true,
|
||||
strict: true,
|
||||
});
|
||||
```
|
||||
|
||||
## Bug fixes
|
||||
|
||||
- mysql-kit: fix GENERATED ALWAYS AS ... NOT NULL - [#2824](https://github.com/drizzle-team/drizzle-orm/pull/2824)
|
||||
@@ -0,0 +1,180 @@
|
||||
## Breaking changes and migrate guide for Turso users
|
||||
|
||||
If you are using Turso and libsql, you will need to upgrade your `drizzle.config` and `@libsql/client` package.
|
||||
|
||||
1. This version of drizzle-orm will only work with `@libsql/client@0.10.0` or higher if you are using the `migrate` function. For other use cases, you can continue using previous versions(But the suggestion is to upgrade)
|
||||
To install the latest version, use the command:
|
||||
|
||||
```bash
|
||||
npm i @libsql/client@latest
|
||||
```
|
||||
|
||||
2. Previously, we had a common `drizzle.config` for SQLite and Turso users, which allowed a shared strategy for both dialects. Starting with this release, we are introducing the turso dialect in drizzle-kit. We will evolve and improve Turso as a separate dialect with its own migration strategies.
|
||||
|
||||
**Before**
|
||||
|
||||
```ts
|
||||
import { defineConfig } from "drizzle-kit";
|
||||
|
||||
export default defineConfig({
|
||||
dialect: "sqlite",
|
||||
schema: "./schema.ts",
|
||||
out: "./drizzle",
|
||||
dbCredentials: {
|
||||
url: "database.db",
|
||||
},
|
||||
breakpoints: true,
|
||||
verbose: true,
|
||||
strict: true,
|
||||
});
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```ts
|
||||
import { defineConfig } from "drizzle-kit";
|
||||
|
||||
export default defineConfig({
|
||||
dialect: "turso",
|
||||
schema: "./schema.ts",
|
||||
out: "./drizzle",
|
||||
dbCredentials: {
|
||||
url: "database.db",
|
||||
},
|
||||
breakpoints: true,
|
||||
verbose: true,
|
||||
strict: true,
|
||||
});
|
||||
```
|
||||
|
||||
If you are using only SQLite, you can use `dialect: "sqlite"`
|
||||
|
||||
## LibSQL/Turso and Sqlite migration updates
|
||||
|
||||
### SQLite "generate" and "push" statements updates
|
||||
|
||||
Starting from this release, we will no longer generate comments like this:
|
||||
|
||||
```sql
|
||||
'/*\n SQLite does not support "Changing existing column type" out of the box, we do not generate automatic migration for that, so it has to be done manually'
|
||||
+ '\n Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php'
|
||||
+ '\n https://www.sqlite.org/lang_altertable.html'
|
||||
+ '\n https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3'
|
||||
+ "\n\n Due to that we don't generate migration automatically and it has to be done manually"
|
||||
+ '\n*/'
|
||||
```
|
||||
|
||||
We will generate a set of statements, and you can decide if it's appropriate to create data-moving statements instead. Here is an example of the SQL file you'll receive now:
|
||||
|
||||
```sql
|
||||
PRAGMA foreign_keys=OFF;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `__new_worker` (
|
||||
`id` integer PRIMARY KEY NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`salary` text NOT NULL,
|
||||
`job_id` integer,
|
||||
FOREIGN KEY (`job_id`) REFERENCES `job`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_worker`("id", "name", "salary", "job_id") SELECT "id", "name", "salary", "job_id" FROM `worker`;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE `worker`;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE `__new_worker` RENAME TO `worker`;
|
||||
--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;
|
||||
```
|
||||
|
||||
### LibSQL/Turso "generate" and "push" statements updates
|
||||
|
||||
Since LibSQL supports more ALTER statements than SQLite, we can generate more statements without recreating your schema and moving all the data, which can be potentially dangerous for production environments.
|
||||
|
||||
LibSQL and Turso will now have a separate dialect in the Drizzle config file, meaning that we will evolve Turso and LibSQL independently from SQLite and will aim to support as many features as Turso/LibSQL offer.
|
||||
|
||||
With the updated LibSQL migration strategy, you will have the ability to:
|
||||
|
||||
- **Change Data Type**: Set a new data type for existing columns.
|
||||
- **Set and Drop Default Values**: Add or remove default values for existing columns.
|
||||
- **Set and Drop NOT NULL**: Add or remove the NOT NULL constraint on existing columns.
|
||||
- **Add References to Existing Columns**: Add foreign key references to existing columns
|
||||
|
||||
You can find more information in the [LibSQL documentation](https://github.com/tursodatabase/libsql/blob/main/libsql-sqlite3/doc/libsql_extensions.md#altering-columns)
|
||||
|
||||
### LIMITATIONS
|
||||
|
||||
- Dropping or altering an index will cause table recreation.
|
||||
|
||||
This is because LibSQL/Turso does not support dropping this type of index.
|
||||
|
||||
```sql
|
||||
CREATE TABLE `users` (
|
||||
`id` integer NOT NULL,
|
||||
`name` integer,
|
||||
`age` integer PRIMARY KEY NOT NULL
|
||||
FOREIGN KEY (`name`) REFERENCES `users1`("id") ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
```
|
||||
|
||||
- If the table has indexes, altering columns will cause table recreation.
|
||||
- Drizzle-Kit will drop the indexes, modify the columns, and then recreate the indexes.
|
||||
- Adding or dropping composite foreign keys is not supported and will cause table recreation
|
||||
|
||||
### NOTES
|
||||
|
||||
- You can create a reference on any column type, but if you want to insert values, the referenced column must have a unique index or primary key.
|
||||
|
||||
```sql
|
||||
CREATE TABLE parent(a PRIMARY KEY, b UNIQUE, c, d, e, f);
|
||||
CREATE UNIQUE INDEX i1 ON parent(c, d);
|
||||
CREATE INDEX i2 ON parent(e);
|
||||
CREATE UNIQUE INDEX i3 ON parent(f COLLATE nocase);
|
||||
|
||||
CREATE TABLE child1(f, g REFERENCES parent(a)); -- Ok
|
||||
CREATE TABLE child2(h, i REFERENCES parent(b)); -- Ok
|
||||
CREATE TABLE child3(j, k, FOREIGN KEY(j, k) REFERENCES parent(c, d)); -- Ok
|
||||
CREATE TABLE child4(l, m REFERENCES parent(e)); -- Error!
|
||||
CREATE TABLE child5(n, o REFERENCES parent(f)); -- Error!
|
||||
CREATE TABLE child6(p, q, FOREIGN KEY(p, q) REFERENCES parent(b, c)); -- Error!
|
||||
CREATE TABLE child7(r REFERENCES parent(c)); -- Error!
|
||||
```
|
||||
|
||||
> **NOTE**: The foreign key for the table child5 is an error because, although the parent key column has a unique index, the index uses a different collating sequence.
|
||||
|
||||
See more: https://www.sqlite.org/foreignkeys.html
|
||||
|
||||
## New `casing` param in `drizzle-orm` and `drizzle-kit`
|
||||
|
||||
There are more improvements you can make to your schema definition. The most common way to name your variables in a database and in TypeScript code is usually `snake_case` in the database and `camelCase` in the code. For this case, in Drizzle, you can now define a naming strategy in your database to help Drizzle map column keys automatically. Let's take a table from the previous example and make it work with the new casing API in Drizzle
|
||||
|
||||
Table can now become:
|
||||
```ts
|
||||
import { pgTable } from "drizzle-orm/pg-core";
|
||||
|
||||
export const ingredients = pgTable("ingredients", (t) => ({
|
||||
id: t.uuid().defaultRandom().primaryKey(),
|
||||
name: t.text().notNull(),
|
||||
description: t.text(),
|
||||
inStock: t.boolean().default(true),
|
||||
}));
|
||||
```
|
||||
As you can see, `inStock` doesn't have a database name alias, but by defining the casing configuration at the connection level, all queries will automatically map it to `snake_case`
|
||||
|
||||
```ts
|
||||
const db = await drizzle('node-postgres', { connection: '', casing: 'snake_case' })
|
||||
```
|
||||
|
||||
For `drizzle-kit` migrations generation you should also specify `casing` param in drizzle config, so you can be sure you casing strategy will be applied to drizzle-kit as well
|
||||
|
||||
```ts
|
||||
import { defineConfig } from "drizzle-kit";
|
||||
|
||||
export default defineConfig({
|
||||
dialect: "postgresql",
|
||||
schema: "./schema.ts",
|
||||
dbCredentials: {
|
||||
url: "postgresql://postgres:password@localhost:5432/db",
|
||||
},
|
||||
casing: "snake_case",
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,122 @@
|
||||
# New Features
|
||||
|
||||
## Checks support in `drizzle-kit`
|
||||
|
||||
You can use drizzle-kit to manage your `check` constraint defined in drizzle-orm schema definition
|
||||
|
||||
For example current drizzle table:
|
||||
|
||||
```ts
|
||||
import { sql } from "drizzle-orm";
|
||||
import { check, pgTable } from "drizzle-orm/pg-core";
|
||||
|
||||
export const users = pgTable(
|
||||
"users",
|
||||
(c) => ({
|
||||
id: c.uuid().defaultRandom().primaryKey(),
|
||||
username: c.text().notNull(),
|
||||
age: c.integer(),
|
||||
}),
|
||||
(table) => ({
|
||||
checkConstraint: check("age_check", sql`${table.age} > 21`),
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
will be generated into
|
||||
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS "users" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"username" text NOT NULL,
|
||||
"age" integer,
|
||||
CONSTRAINT "age_check" CHECK ("users"."age" > 21)
|
||||
);
|
||||
```
|
||||
|
||||
The same is supported in all dialects
|
||||
|
||||
### Limitations
|
||||
|
||||
- `generate` will work as expected for all check constraint changes.
|
||||
- `push` will detect only check renames and will recreate the constraint. All other changes to SQL won't be detected and will be ignored.
|
||||
|
||||
So, if you want to change the constraint's SQL definition using only `push`, you would need to manually comment out the constraint, `push`, then put it back with the new SQL definition and `push` one more time.
|
||||
|
||||
## Views support in `drizzle-kit`
|
||||
|
||||
You can use drizzle-kit to manage your `views` defined in drizzle-orm schema definition. It will work with all existing dialects and view options
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
For example current drizzle table:
|
||||
|
||||
```ts
|
||||
import { sql } from "drizzle-orm";
|
||||
import {
|
||||
check,
|
||||
pgMaterializedView,
|
||||
pgTable,
|
||||
pgView,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
export const users = pgTable(
|
||||
"users",
|
||||
(c) => ({
|
||||
id: c.uuid().defaultRandom().primaryKey(),
|
||||
username: c.text().notNull(),
|
||||
age: c.integer(),
|
||||
}),
|
||||
(table) => ({
|
||||
checkConstraint: check("age_check", sql`${table.age} > 21`),
|
||||
})
|
||||
);
|
||||
|
||||
export const simpleView = pgView("simple_users_view").as((qb) =>
|
||||
qb.select().from(users)
|
||||
);
|
||||
|
||||
export const materializedView = pgMaterializedView(
|
||||
"materialized_users_view"
|
||||
).as((qb) => qb.select().from(users));
|
||||
```
|
||||
|
||||
will be generated into
|
||||
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS "users" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"username" text NOT NULL,
|
||||
"age" integer,
|
||||
CONSTRAINT "age_check" CHECK ("users"."age" > 21)
|
||||
);
|
||||
|
||||
CREATE VIEW "public"."simple_users_view" AS (select "id", "username", "age" from "users");
|
||||
|
||||
CREATE MATERIALIZED VIEW "public"."materialized_users_view" AS (select "id", "username", "age" from "users");
|
||||
```
|
||||
|
||||
Views supported in all dialects, but materialized views are supported only in PostgreSQL
|
||||
|
||||
#### Limitations
|
||||
|
||||
- `generate` will work as expected for all view changes
|
||||
- `push` limitations:
|
||||
|
||||
1. If you want to change the view's SQL definition using only `push`, you would need to manually comment out the view, `push`, then put it back with the new SQL definition and `push` one more time.
|
||||
|
||||
## Updates for PostgreSQL enums behavior
|
||||
|
||||
We've updated enum behavior in Drizzle with PostgreSQL:
|
||||
|
||||
- Add value after or before in enum: With this change, Drizzle will now respect the order of values in the enum and allow adding new values after or before a specific one.
|
||||
|
||||
- Support for dropping a value from an enum: In this case, Drizzle will attempt to alter all columns using the enum to text, then drop the existing enum and create a new one with the updated set of values. After that, all columns previously using the enum will be altered back to the new enum.
|
||||
|
||||
> If the deleted enum value was used by a column, this process will result in a database error.
|
||||
|
||||
- Support for dropping an enum
|
||||
|
||||
- Support for moving enums between schemas
|
||||
|
||||
- Support for renaming enums
|
||||
@@ -0,0 +1 @@
|
||||
- Fix `data is malformed` for views
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +1,421 @@
|
||||
> This version of `drizzle-jit` requires `drizzle-orm@0.36.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]: Studio + mysql default mode, wrong format related timezone](https://github.com/drizzle-team/drizzle-orm/issues/2747)
|
||||
- [[BUG]: Drizzle Studio CORS error](https://github.com/drizzle-team/drizzle-orm/issues/1857)
|
||||
- [[BUG]: TIMESTAMPS showing up incorrectly on drizzle studio](https://github.com/drizzle-team/drizzle-orm/issues/2549)
|
||||
@@ -0,0 +1 @@
|
||||
- Fix: [[BUG]: When using RLS policies and Views, the view is the last clause generated](https://github.com/drizzle-team/drizzle-orm/issues/3378)
|
||||
@@ -0,0 +1,3 @@
|
||||
- Fix [[BUG]: Undefined properties when using drizzle-kit push](https://github.com/drizzle-team/drizzle-orm/issues/3391)
|
||||
- Fix TypeError: Cannot read properties of undefined (reading 'isRLSEnabled')
|
||||
- Fix push bugs, when pushing a schema with linked policy to a table from `drizzle-orm/supabase`
|
||||
@@ -0,0 +1,28 @@
|
||||
# Improvements
|
||||
|
||||
- Added an OHM static imports checker to identify unexpected imports within a chain of imports in the drizzle-kit repo. For example, it checks if drizzle-orm is imported before drizzle-kit and verifies if the drizzle-orm import is available in your project.
|
||||
- [Adding more columns to Supabase auth.users table schema](https://github.com/drizzle-team/drizzle-orm/issues/3327) - thanks @nicholasdly
|
||||
|
||||
# Bug Fixes
|
||||
|
||||
- [[BUG]: [drizzle-kit]: Fix breakpoints option cannot be disabled](https://github.com/drizzle-team/drizzle-orm/issues/2828) - thanks @klotztech
|
||||
- [[BUG]: drizzle-kit introspect: SMALLINT import missing and incorrect DECIMAL UNSIGNED handling](https://github.com/drizzle-team/drizzle-orm/issues/2950) - thanks @L-Mario564
|
||||
- [Unsigned tinyints preventing migrations](https://github.com/drizzle-team/drizzle-orm/issues/1571) - thanks @L-Mario564
|
||||
- [[BUG]: Can't parse float(8,2) from database (precision and scale and/or unsigned breaks float types)](https://github.com/drizzle-team/drizzle-orm/issues/3285) - thanks @L-Mario564
|
||||
- [[BUG]: PgEnum generated migration doesn't escape single quotes](https://github.com/drizzle-team/drizzle-orm/issues/1272) - thanks @L-Mario564
|
||||
- [[BUG]: single quote not escaped correctly in migration file](https://github.com/drizzle-team/drizzle-orm/issues/2184) - thanks @L-Mario564
|
||||
- [[BUG]: Migrations does not escape single quotes](https://github.com/drizzle-team/drizzle-orm/issues/1765) - thanks @L-Mario564
|
||||
- [[BUG]: Issue with quoted default string values](https://github.com/drizzle-team/drizzle-orm/issues/2122) - thanks @L-Mario564
|
||||
- [[BUG]: SQl commands in wrong roder](https://github.com/drizzle-team/drizzle-orm/issues/2390) - thanks @L-Mario564
|
||||
- [[BUG]: Time with precision in drizzle-orm/pg-core adds double-quotes around type](https://github.com/drizzle-team/drizzle-orm/issues/1804) - thanks @L-Mario564
|
||||
- [[BUG]: Postgres push fails due to lack of quotes](https://github.com/drizzle-team/drizzle-orm/issues/2396) - thanks @L-Mario564
|
||||
- [[BUG]: TypeError: Cannot read properties of undefined (reading 'compositePrimaryKeys')](https://github.com/drizzle-team/drizzle-orm/issues/2344) - thanks @L-Mario564
|
||||
- [[BUG]: drizzle-kit introspect generates CURRENT_TIMESTAMP without sql operator on date column](https://github.com/drizzle-team/drizzle-orm/issues/2899) - thanks @L-Mario564
|
||||
- [[BUG]: Drizzle-kit introspect doesn't pull correct defautl statement](https://github.com/drizzle-team/drizzle-orm/issues/2905) - thanks @L-Mario564
|
||||
- [[BUG]: Problem on MacBook - This statement does not return data. Use run() instead](https://github.com/drizzle-team/drizzle-orm/issues/2623) - thanks @L-Mario564
|
||||
- [[BUG]: Enum column names that are used as arrays are not quoted](https://github.com/drizzle-team/drizzle-orm/issues/2598) - thanks @L-Mario564
|
||||
- [[BUG]: drizzle-kit generate ignores index operators](https://github.com/drizzle-team/drizzle-orm/issues/2935) - thanks @L-Mario564
|
||||
- [dialect param config error message is wrong](https://github.com/drizzle-team/drizzle-orm/issues/3427) - thanks @L-Mario564
|
||||
- [[BUG]: Error setting default enum field values](https://github.com/drizzle-team/drizzle-orm/issues/2299) - thanks @L-Mario564
|
||||
- [[BUG]: drizzle-kit does not respect the order of columns configured in primaryKey()](https://github.com/drizzle-team/drizzle-orm/issues/2326) - thanks @L-Mario564
|
||||
- [[BUG]: Cannot drop Unique Constraint MySQL](https://github.com/drizzle-team/drizzle-orm/issues/998) - thanks @L-Mario564
|
||||
@@ -0,0 +1,4 @@
|
||||
# Bug fixes
|
||||
|
||||
- Fixed typos in repository: thanks @armandsalle, @masto, @wackbyte, @Asher-JH, @MaxLeiter
|
||||
- [fix: wrong dialect set in mysql/sqlite introspect](https://github.com/drizzle-team/drizzle-orm/pull/2865)
|
||||
@@ -0,0 +1,40 @@
|
||||
# New Dialects
|
||||
|
||||
### 🎉 `SingleStore` dialect is now available in Drizzle
|
||||
|
||||
Thanks to the SingleStore team for creating a PR with all the necessary changes to support the MySQL-compatible part of SingleStore. You can already start using it with Drizzle. The SingleStore team will also help us iterate through updates and make more SingleStore-specific features available in Drizzle
|
||||
|
||||
```ts
|
||||
import 'dotenv/config';
|
||||
import { defineConfig } from 'drizzle-kit';
|
||||
|
||||
export default defineConfig({
|
||||
dialect: 'singlestore',
|
||||
out: './drizzle',
|
||||
schema: './src/db/schema.ts',
|
||||
dbCredentials: {
|
||||
url: process.env.DATABASE_URL!,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
You can check out our [Getting started guides](https://orm.drizzle.team/docs/get-started/singlestore-new) to try SingleStore!
|
||||
|
||||
# New Drivers
|
||||
|
||||
### 🎉 `SQLite Durable Objects` driver is now available in Drizzle
|
||||
|
||||
You can now query SQLite Durable Objects in Drizzle!
|
||||
|
||||
For the full example, please check our [Get Started](https://orm.drizzle.team/docs/get-started/do-new) Section
|
||||
|
||||
```ts
|
||||
import 'dotenv/config';
|
||||
import { defineConfig } from 'drizzle-kit';
|
||||
export default defineConfig({
|
||||
out: './drizzle',
|
||||
schema: './src/db/schema.ts',
|
||||
dialect: 'sqlite',
|
||||
driver: 'durable-sqlite',
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
- Fix SingleStore generate migrations command
|
||||
@@ -0,0 +1,7 @@
|
||||
Starting from this update, the PostgreSQL dialect will align with the behavior of all other dialects. It will no longer include `IF NOT EXISTS`, `$DO`, or similar statements, which could cause incorrect DDL statements to not fail when an object already exists in the database and should actually fail.
|
||||
|
||||
This change marks our first step toward several major upgrades we are preparing:
|
||||
|
||||
- An updated and improved migration workflow featuring commutative migrations, a revised folder structure, and enhanced collaboration capabilities for migrations.
|
||||
- Better support for Xata migrations.
|
||||
- Compatibility with CockroachDB (achieving full compatibility will only require removing serial fields from the migration folder).
|
||||
@@ -0,0 +1,35 @@
|
||||
# New Features
|
||||
|
||||
### `drizzle-kit export`
|
||||
|
||||
To make drizzle-kit integration with other migration tools, like Atlas much easier, we've prepared a new command called `export`. It will translate your drizzle schema in SQL representation(DDL) statements and outputs to the console
|
||||
|
||||
```ts
|
||||
// schema.ts
|
||||
import { pgTable, serial, text } from 'drizzle-orm/pg-core'
|
||||
|
||||
export const users = pgTable('users', {
|
||||
id: serial('id').primaryKey(),
|
||||
email: text('email').notNull(),
|
||||
name: text('name')
|
||||
});
|
||||
```
|
||||
Running
|
||||
```bash
|
||||
npx drizzle-kit export
|
||||
```
|
||||
|
||||
will output this string to console
|
||||
```bash
|
||||
CREATE TABLE "users" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"name" text
|
||||
);
|
||||
```
|
||||
|
||||
By default, the only option for now is `--sql`, so the output format will be SQL DDL statements. In the future, we will support additional output formats to accommodate more migration tools
|
||||
|
||||
```bash
|
||||
npx drizzle-kit export --sql
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
- Fix certificates generation utility for Drizzle Studio; [[BUG]: [drizzle-kit]: drizzle-kit dependency on drizzle-studio perms error](https://github.com/drizzle-team/drizzle-orm/issues/3729)
|
||||
@@ -0,0 +1,7 @@
|
||||
# SingleStore `push` and `generate` improvements
|
||||
|
||||
As SingleStore did not support certain DDL statements before this release, you might encounter an error indicating that some schema changes cannot be applied due to a database issue. Starting from this version, drizzle-kit will detect such cases and initiate table recreation with data transfer between the tables
|
||||
|
||||
# Bug fixes
|
||||
|
||||
- [[BUG] If the index name is the same as the generated name, it will be empty and a type error will occur](https://github.com/drizzle-team/drizzle-orm/issues/3420)
|
||||
@@ -0,0 +1,2 @@
|
||||
- Fix bug that generates incorrect syntax when introspect in mysql
|
||||
- Fix a bug that caused incorrect syntax output when introspect in unsigned columns
|
||||
@@ -0,0 +1,30 @@
|
||||
# New Features
|
||||
|
||||
## Added `Gel` dialect support and `gel-js` client support
|
||||
|
||||
Drizzle is getting a new `Gel` dialect with its own types and Gel-specific logic. In this first iteration, almost all query-building features have been copied from the `PostgreSQL` dialect since Gel is fully PostgreSQL-compatible. The only change in this iteration is the data types. The Gel dialect has a different set of available data types, and all mappings for these types have been designed to avoid any extra conversions on Drizzle's side. This means you will insert and select exactly the same data as supported by the Gel protocol.
|
||||
|
||||
Drizzle + Gel integration will work only through `drizzle-kit pull`. Drizzle won't support `generate`, `migrate`, or `push` features in this case. Instead, drizzle-kit is used solely to pull the Drizzle schema from the Gel database, which can then be used in your `drizzle-orm` queries.
|
||||
|
||||
The Gel + Drizzle workflow:
|
||||
|
||||
1. Use the `gel` CLI to manage your schema.
|
||||
2. Use the `gel` CLI to generate and apply migrations to the database.
|
||||
3. Use drizzle-kit to pull the Gel database schema into a Drizzle schema.
|
||||
4. Use drizzle-orm with gel-js to query the Gel database.
|
||||
|
||||
On the drizzle-kit side you can now use `dialect: "gel"`
|
||||
|
||||
```ts
|
||||
// drizzle.config.ts
|
||||
import { defineConfig } from 'drizzle-kit';
|
||||
|
||||
export default defineConfig({
|
||||
dialect: 'gel',
|
||||
});
|
||||
```
|
||||
|
||||
For a complete Get Started tutorial you can use our new guides:
|
||||
|
||||
- [Get Started with Drizzle and Gel in a new project](https://orm.drizzle.team/docs/get-started/gel-new)
|
||||
- [Get Started with Drizzle and Gel in a existing project](https://orm.drizzle.team/docs/get-started/gel-existing)
|
||||
@@ -0,0 +1,4 @@
|
||||
### Bug fixes
|
||||
|
||||
- [[BUG]: d1 push locally is not working](https://github.com/drizzle-team/drizzle-orm/issues/4099) - thanks @mabels and @RomanNabukhotnyi
|
||||
- [[BUG] Cloudflare D1: drizzle-kit push is not working (error 7500 SQLITE_AUTH)](https://github.com/drizzle-team/drizzle-orm/issues/3728) - thanks @mabels and @RomanNabukhotnyi
|
||||
@@ -0,0 +1,31 @@
|
||||
## Features and improvements
|
||||
|
||||
### Enum DDL improvements
|
||||
|
||||
For situations where you drop an `enum` value or reorder values in an `enum`, there is no native way to do this in PostgreSQL. To handle these cases, `drizzle-kit` used to:
|
||||
|
||||
- Change the column data types from the enum to text
|
||||
- Drop the old enum
|
||||
- Add the new enum
|
||||
- Change the column data types back to the new enum
|
||||
|
||||
However, there were a few scenarios that weren’t covered: `PostgreSQL` wasn’t updating default expressions for columns when their data types changed
|
||||
|
||||
Therefore, for cases where you either change a column’s data type from an `enum` to some other type, drop an `enum` value, or reorder `enum` values, we now do the following:
|
||||
|
||||
- Change the column data types from the enum to text
|
||||
- Set the default using the ::text expression
|
||||
- Drop the old enum
|
||||
- Add the new enum
|
||||
- Change the column data types back to the new enum
|
||||
- Set the default using the ::<new_enum> expression
|
||||
|
||||
### `esbuild` version upgrade
|
||||
|
||||
For `drizzle-kit` we upgraded the version to latest (`0.25.2`), thanks @paulmarsicloud
|
||||
|
||||
## Bug fixes
|
||||
|
||||
- [[BUG]: Error on Malformed Array Literal](https://github.com/drizzle-team/drizzle-orm/issues/2715) - thanks @Kratious
|
||||
- [[BUG]: Postgres drizzle-kit: Error while pulling indexes from a table with json/jsonb deep field index](https://github.com/drizzle-team/drizzle-orm/issues/2744) - thanks @Kratious
|
||||
- [goog-vulnz flags CVE-2024-24790 in esbuild 0.19.7](https://github.com/drizzle-team/drizzle-orm/issues/4045)
|
||||
@@ -0,0 +1,18 @@
|
||||
### Fixed `drizzle-kit pull` bugs when using Gel extensions.
|
||||
|
||||
Because Gel extensions create schema names containing `::` (for example, `ext::auth`), Drizzle previously handled these names incorrectly. Starting with this release, you can use Gel extensions without any problems. Here’s what you should do:
|
||||
|
||||
1. Enable extensions schemas in `drizzle.config.ts`
|
||||
|
||||
```ts
|
||||
import { defineConfig } from "drizzle-kit";
|
||||
|
||||
export default defineConfig({
|
||||
dialect: 'gel',
|
||||
schemaFilter: ['ext::auth', 'public']
|
||||
});
|
||||
```
|
||||
|
||||
2. Run `drizzle-kit pull`
|
||||
|
||||
3. Done!
|
||||
@@ -0,0 +1,3 @@
|
||||
- Updated to `hanji@0.0.8` - native bun `stringWidth`, `stripANSI` support, errors for non-TTY environments
|
||||
- We've migrated away from `esbuild-register` to `tsx` loader, it will now allow to use `drizzle-kit` seamlessly with both `ESM` and `CJS` modules
|
||||
- We've also added native `Bun` and `Deno` launch support, which will not trigger `tsx` loader and utilise native `bun` and `deno` imports capabilities and faster startup times
|
||||
@@ -0,0 +1,3 @@
|
||||
### Bug fixes
|
||||
|
||||
- Fixed relations extraction to not interfere with Drizzle Studio.
|
||||
@@ -0,0 +1 @@
|
||||
- Internal changes to Studio context. Added `databaseName` and `packageName` properties for Studio
|
||||
@@ -0,0 +1 @@
|
||||
- Fixed `halfvec`, `bit` and `sparsevec` type generation bug in drizzle-kit
|
||||
@@ -0,0 +1 @@
|
||||
- Add casing support to studio configuration and related functions
|
||||
@@ -0,0 +1,3 @@
|
||||
### Bug fixes
|
||||
|
||||
- [[BUG]: Importing drizzle-kit/api fails in ESM modules](https://github.com/drizzle-team/drizzle-orm/issues/2853)
|
||||
@@ -0,0 +1,3 @@
|
||||
### Bug fixes
|
||||
|
||||
- [[BUG]: Drizzle Kit push to Postgres 18 produces unecessary DROP SQL when the schema was NOT changed](https://github.com/drizzle-team/drizzle-orm/issues/4944)
|
||||
@@ -0,0 +1,4 @@
|
||||
### Bug fixes
|
||||
|
||||
- Fixed `algorythm` => `algorithm` typo.
|
||||
- Fixed external dependencies in build configuration.
|
||||
@@ -0,0 +1 @@
|
||||
- drizzle-kit api improvements for D1 connections
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.14.1
|
||||
|
||||
- Release support for mysql. Currently mysql module is up-to-date with `pg` and `sqlite`
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.14.2
|
||||
|
||||
- Bumped everything to 0.14.2
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.14.3
|
||||
|
||||
- Fill author field in package.json
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.15.0
|
||||
|
||||
- Bumped everything to 0.15.0
|
||||
@@ -0,0 +1,88 @@
|
||||
# drizzle-orm-mysql 0.15.1
|
||||
|
||||
Add support for schemas -> [MySQL schemas](https://dev.mysql.com/doc/refman/8.0/en/create-database.html)
|
||||
|
||||
|
||||
> **Warning**
|
||||
> If you will have tables with same names in different schemas then drizzle will respond with `never[]` error in result types and error from database
|
||||
>
|
||||
> In this case you may use [alias syntax](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-mysql#join-aliases-and-self-joins)
|
||||
|
||||
---
|
||||
|
||||
Usage example
|
||||
```typescript
|
||||
// Table in default schema
|
||||
const publicUsersTable = mysqlTable('users', {
|
||||
id: serial('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
verified: boolean('verified').notNull().default(false),
|
||||
jsonb: json<string[]>('jsonb'),
|
||||
createdAt: timestamp('created_at', { fsp: 2 }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
|
||||
// Table in custom schema
|
||||
const mySchema = mysqlSchema('mySchema');
|
||||
|
||||
const mySchemaUsersTable = mySchema('users', {
|
||||
id: serial('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
verified: boolean('verified').notNull().default(false),
|
||||
jsonb: json<string[]>('jsonb'),
|
||||
createdAt: timestamp('created_at', { fsp: 2 }).notNull().defaultNow(),
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Breaking changes
|
||||
- `foreignKey()` function api changes. Previously you need to pass callback function with table columns for FK. Right now no need for callback, just object with data for FK
|
||||
|
||||
#### Before
|
||||
```typescript
|
||||
export const usersTable = mysqlTable('userstest', {
|
||||
id: serial('id').primaryKey(),
|
||||
homeCity: text('name').notNull(),
|
||||
createdAt: timestamp('created_at', { fsp: 2 }).notNull().defaultNow(),
|
||||
}, (users) => ({
|
||||
// foreignKey has a callback as param
|
||||
usersCityFK: foreignKey(() => { columns: [users.homeCity], foreignColumns: [cities.id] }),
|
||||
}));
|
||||
```
|
||||
|
||||
#### Now
|
||||
```typescript
|
||||
export const usersTable = mysqlTable('userstest', {
|
||||
id: serial('id').primaryKey(),
|
||||
homeCity: text('name').notNull(),
|
||||
createdAt: timestamp('created_at', { fsp: 2 }).notNull().defaultNow(),
|
||||
}, (users) => ({
|
||||
// foreignKey has a callback as param
|
||||
usersCityFK: foreignKey({ columns: [users.homeCity], foreignColumns: [cities.id] }),
|
||||
}));
|
||||
```
|
||||
---
|
||||
|
||||
- Change enum initializing strategy for mysql
|
||||
|
||||
You should use
|
||||
``` typescript
|
||||
mysqlEnum('popularity', ['unknown', 'known', 'popular']).notNull().default('known')
|
||||
```
|
||||
|
||||
instead of
|
||||
``` typescript
|
||||
export const popularityEnum = mysqlEnum('popularity', ['unknown', 'known', 'popular']);
|
||||
popularityEnum('column_name');
|
||||
```
|
||||
|
||||
Usage example in table schema
|
||||
``` typescript
|
||||
const tableWithEnums = mysqlTable('enums_test_case', {
|
||||
id: serial('id').primaryKey(),
|
||||
enum1: mysqlEnum('enum1', ['a', 'b', 'c']).notNull(),
|
||||
enum2: mysqlEnum('enum2', ['a', 'b', 'c']).default('a'),
|
||||
enum3: mysqlEnum('enum3', ['a', 'b', 'c']).notNull().default('b'),
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.15.2
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.15.3
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.16.0
|
||||
|
||||
- Bump all packages to 0.16.0
|
||||
@@ -0,0 +1,19 @@
|
||||
# drizzle-orm-mysql 0.16.1
|
||||
|
||||
- Add possibility to define database custom data types
|
||||
|
||||
Example usage:
|
||||
|
||||
```typescript
|
||||
const customText = customType<{ data: string }>({
|
||||
dataType() {
|
||||
return 'text';
|
||||
},
|
||||
});
|
||||
|
||||
const usersTable = mysqlTable('users', {
|
||||
name: customText('name').notNull(),
|
||||
});
|
||||
```
|
||||
|
||||
For more examples please check [docs](https://github.com/drizzle-team/drizzle-orm/blob/main/docs/custom-types.lite.md)
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-mysql 0.16.2
|
||||
|
||||
- Fix peer dependency error for >=0.16 drizzle packages
|
||||
@@ -0,0 +1,8 @@
|
||||
# drizzle-orm-pg 0.12.0-beta.40
|
||||
|
||||
- Added prepared statements and placeholders support.
|
||||
- Refactored `.select().fields()` to allow fields from joined tables and nested objects structure, removed partial selects from joins.
|
||||
- Allowed passing query builders to `db.execute`.
|
||||
- Optimized INSERT query generation for single values by skipping columns without values.
|
||||
- Exposed `table` property from index config.
|
||||
- Removed testing utils.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.13.0
|
||||
|
||||
- Release 🎉
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.13.1
|
||||
|
||||
- Implemented node-pg prepared statements usage via adding `name` argument to `.prepare()` method.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.13.2
|
||||
|
||||
- Fix prepared statements usage.
|
||||
@@ -0,0 +1,4 @@
|
||||
# drizzle-orm-pg 0.13.3
|
||||
|
||||
- Implemented NeonDB serverless driver support.
|
||||
- (internal) Added `session.all()` and `session.values()` methods.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.13.4
|
||||
|
||||
- Fixed types for IndexBuilder.
|
||||
@@ -0,0 +1,8 @@
|
||||
# drizzle-orm-pg 0.14.0
|
||||
|
||||
- Separated migrations functionality to a separate import:
|
||||
```typescript
|
||||
import { migrate } from 'drizzle-orm-pg/node/migrate';
|
||||
```
|
||||
- Replaced `await new PgConnector(client).connect()` with `drizzle(client)`.
|
||||
- `import { PgConnector } from 'drizzle-orm-pg` -> `import { drizzle } from 'drizzle-orm-pg/node`.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.14.1
|
||||
|
||||
- Bumped everything to 0.14.1.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.14.2
|
||||
|
||||
- Bumped everything to 0.14.2
|
||||
@@ -0,0 +1,6 @@
|
||||
# drizzle-orm-pg 0.14.3
|
||||
|
||||
- Fixed `.onConflict` statement query builder. In previous versions target column was mapped together with table name
|
||||
- Added documentation examples for `onConflict`
|
||||
- Added documentation examples for returning statements for insert/update/delete
|
||||
- Add more tests for `onConflict` query builder
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.14.4
|
||||
|
||||
- Fill author field in package.json
|
||||
@@ -0,0 +1,41 @@
|
||||
# drizzle-orm-pg 0.15.0
|
||||
|
||||
- Set `notNull` to `true` in runtime, when `.primaryKey()` function was used in `ColumnBuilder`
|
||||
- Set `no action` for `OnDelete` and `OnUpdate` in runtime by default
|
||||
- Add internal version for ORM api
|
||||
- Index name now becomes optional. You can write either `index('usersNameIdx')` or `index()`. In last case, drizzle will generate index name automatically based on table and column index was created on
|
||||
|
||||
## Breaking changes
|
||||
`foreignKey()` function api changes. Previosuly you need to pass callback function with table columns for FK. Right now no need for callback, just object with data for FK
|
||||
|
||||
#### Before
|
||||
```typescript
|
||||
export const usersTable = pgTable(
|
||||
'users_table',
|
||||
{
|
||||
id: serial('id').primaryKey(),
|
||||
uuid: uuid('uuid').defaultRandom().notNull(),
|
||||
homeCity: integer('home_city').notNull()
|
||||
},
|
||||
(users) => ({
|
||||
// foreignKey had a callback as param
|
||||
usersCityFK: foreignKey(() => ({ columns: [users.homeCity], foreignColumns: [cities.id] })),
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
#### Now
|
||||
```typescript
|
||||
export const usersTable = pgTable(
|
||||
'users_table',
|
||||
{
|
||||
id: serial('id').primaryKey(),
|
||||
uuid: uuid('uuid').defaultRandom().notNull(),
|
||||
homeCity: integer('home_city').notNull()
|
||||
},
|
||||
(users) => ({
|
||||
// foreignKey doesn't have a callback as param
|
||||
usersCityFK: foreignKey({ columns: [users.homeCity], foreignColumns: [cities.id] }),
|
||||
}),
|
||||
);
|
||||
```
|
||||
@@ -0,0 +1,39 @@
|
||||
# drizzle-orm-pg 0.15.1
|
||||
|
||||
Add support for schemas -> [PostgreSQL schemas](https://www.postgresql.org/docs/current/ddl-schemas.html)
|
||||
|
||||
---
|
||||
Drizzle won't append any schema before table definition by default. So if your tables are in `public` schema drizzle generate -> `select * from "users"`
|
||||
|
||||
But if you will specify any custom schema you want, then drizzle will generate -> `select * from "custom_schema"."users"`
|
||||
|
||||
> **Warning**
|
||||
> If you will have tables with same names in different schemas then drizzle will respond with `never[]` error in result types and error from database
|
||||
>
|
||||
> In this case you may use [alias syntax](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-pg#join-aliases-and-self-joins)
|
||||
|
||||
---
|
||||
|
||||
Usage example
|
||||
```typescript
|
||||
// Table in default schema
|
||||
const publicUsersTable = pgTable('users', {
|
||||
id: serial('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
verified: boolean('verified').notNull().default(false),
|
||||
jsonb: jsonb<string[]>('jsonb'),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
|
||||
// Table in custom schema
|
||||
const mySchema = pgSchema('mySchema');
|
||||
|
||||
const usersTable = mySchema('users', {
|
||||
id: serial('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
verified: boolean('verified').notNull().default(false),
|
||||
jsonb: jsonb<string[]>('jsonb'),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.15.2
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.15.3
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.16.0
|
||||
|
||||
- Implemented [postgres.js](https://github.com/porsager/postgres) driver support ([docs](/drizzle-orm-pg/src/postgres-js/README.md))
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.16.1
|
||||
|
||||
- Fix documentation links
|
||||
@@ -0,0 +1,17 @@
|
||||
- Add possibility to define database custom data types
|
||||
|
||||
Example usage:
|
||||
|
||||
```typescript
|
||||
const customText = customType<{ data: string }>({
|
||||
dataType() {
|
||||
return 'text';
|
||||
},
|
||||
});
|
||||
|
||||
const usersTable = pgTable('users', {
|
||||
name: customText('name').notNull(),
|
||||
});
|
||||
```
|
||||
|
||||
For more examples please check [docs](https://github.com/drizzle-team/drizzle-orm/blob/main/docs/custom-types.lite.md)
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-pg 0.16.3
|
||||
|
||||
- Fix peer dependency error for >=0.16 drizzle packages
|
||||
@@ -0,0 +1,4 @@
|
||||
# drizzle-orm-sqlite 0.12.0-beta.17
|
||||
|
||||
- Refactored `.select().fields()` to allow fields from joined tables and nested objects structure, removed partial selects from joins.
|
||||
- Replaced `.execute()` in query builders and prepared statements with `.run()`, `.all()`, `.get()`, `.values()`.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.12.0-beta.18
|
||||
|
||||
- Updated `better-sqlite3` and `@types/better-sqlite3` peer dependency from `<8` to `<9`.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.12.0-beta.19
|
||||
|
||||
- Fix bug with running migrations. `Error: SqliteError: near "SCHEMA": syntax error` was fixed
|
||||
@@ -0,0 +1,4 @@
|
||||
# drizzle-orm-sqlite 0.12.0-beta.20
|
||||
|
||||
- Fix bug with running migrations for async driver. `Error: SqliteError: near "SCHEMA": syntax error` was fixed
|
||||
- Fix `Statement does not return any data - use run()` error, when no fields were provided to prepared statement
|
||||
@@ -0,0 +1,6 @@
|
||||
# drizzle-orm-sqlite 0.12.0-beta.21
|
||||
|
||||
- Fixed `db.all` logic for all drivers.
|
||||
- Allowed passing query builders to raw query execution methods.
|
||||
- Optimized INSERT query generation for single values by skipping columns without values.
|
||||
- Exposed `table` property from index config.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.13.0
|
||||
|
||||
- Release 🎉
|
||||
@@ -0,0 +1,8 @@
|
||||
# drizzle-orm-sqlite 0.14.1
|
||||
|
||||
- Separated migrations functionality to a separate import:
|
||||
```typescript
|
||||
import { migrate } from 'drizzle-orm-sqlite/better-sqlite3/migrate';
|
||||
```
|
||||
- Replaced `await new SQLiteConnector(client).connect()` with `drizzle(client)`.
|
||||
- `import { SQLiteConnector } from 'drizzle-orm-sqlite` -> `import { drizzle } from 'drizzle-orm-pg/better-sqlite3`.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.14.2
|
||||
|
||||
- Bumped everything to 0.14.2
|
||||
@@ -0,0 +1,19 @@
|
||||
# drizzle-orm-sqlite 0.14.3
|
||||
|
||||
- `RangeError: The supplied SQL string contains more than one statement` error on migrations was fixed
|
||||
|
||||
Created `.exec()` method for session, that will run query without prepared statments
|
||||
|
||||
- Fix `defaultNow()` method query generation by adding missin `"()"`.
|
||||
|
||||
Previously default value was generated as
|
||||
```sql
|
||||
cast((julianday('now') - 2440587.5)*86400000 as integer)
|
||||
```
|
||||
|
||||
Currently default value looks like
|
||||
```sql
|
||||
(cast((julianday('now') - 2440587.5)*86400000 as integer))
|
||||
```
|
||||
|
||||
- Create test cases for both issues
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.14.4
|
||||
|
||||
- Fix adding autoincrement to `drizzle-kit` migrations
|
||||
@@ -0,0 +1,4 @@
|
||||
# drizzle-orm-sqlite 0.14.5
|
||||
|
||||
- Remove upper bound restriction from `@cloudflare/workers-types` peer dependency
|
||||
- Fill author field in package.json
|
||||
@@ -0,0 +1,14 @@
|
||||
# drizzle-orm-sqlite 0.15.0
|
||||
|
||||
- Add composite PK's on table schema definition
|
||||
|
||||
#### Usage example
|
||||
```typescript
|
||||
const pkExample = sqliteTable('pk_example', {
|
||||
id: integer('id'),
|
||||
name: text('name').notNull(),
|
||||
email: text('email').notNull(),
|
||||
}, (table) => ({
|
||||
compositePk: primaryKey(table.id, table.name)
|
||||
}));
|
||||
```
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.15.2
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.15.3
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.15.4
|
||||
|
||||
- Implemented [sql.js](https://github.com/sql-js/sql.js/) driver support (allows you to use SQLite in the browser)
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.16.0
|
||||
|
||||
- Bump all packages to 0.16.0
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm-sqlite 0.16.1
|
||||
|
||||
- Fix peer dependency error for >=0.16 drizzle packages
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.12.0-beta.23
|
||||
|
||||
- Added new row mapping mechanism as `mapResultRowV2`, `mapResultRow` will be replaced by it in the future.
|
||||
@@ -0,0 +1,5 @@
|
||||
# drizzle-orm 0.12.0-beta.24
|
||||
|
||||
- Made `.execute()` method public in query builders.
|
||||
- Added `name()` function for escaping entity names inside queries.
|
||||
- (internal) Removed old row mapper implementation.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.13.0
|
||||
|
||||
- Release 🎉
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.13.1
|
||||
|
||||
- Fix mysql peer dependency range
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.14.1
|
||||
|
||||
- Bumped everything to 0.14.1.
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.14.2
|
||||
|
||||
- Bumped everything to 0.14.2
|
||||
@@ -0,0 +1,4 @@
|
||||
# drizzle-orm 0.15.0
|
||||
|
||||
- Minor upgrade for all modules, due to adding version for api
|
||||
- Add internal version for ORM api and npm version
|
||||
@@ -0,0 +1,4 @@
|
||||
# drizzle-orm 0.15.1
|
||||
|
||||
- Add schema symbol to table
|
||||
- Append schema before table name in SQLWrapper if it exists
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.15.2
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.15.3
|
||||
|
||||
Internal release
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.16.0
|
||||
|
||||
- Bump all packages to 0.16.0
|
||||
@@ -0,0 +1,3 @@
|
||||
# drizzle-orm 0.16.0
|
||||
|
||||
- Fix peer dependency error for >=0.16 drizzle packages
|
||||
@@ -0,0 +1,25 @@
|
||||
## ❗ All ORM packages are now merged into `drizzle-orm`
|
||||
|
||||
Starting from release `0.17.0` and onwards, all dialect-specific packages are merged into `drizzle-orm`. Legacy ORM packages will be archived.
|
||||
|
||||
### Import paths changes
|
||||
|
||||
#### PostgreSQL
|
||||
|
||||
- `import { ... } from 'drizzle-orm-pg'` -> `import { ... } from 'drizzle-orm/pg-core'`
|
||||
- `import { ... } from 'drizzle-orm-pg/node'` -> `import { ... } from 'drizzle-orm/node-postgres'`
|
||||
- `import { ... } from 'drizzle-orm-pg/neondb'` -> `import { ... } from 'drizzle-orm/neon'`
|
||||
- `import { ... } from 'drizzle-orm-pg/postgres.js'` -> `import { ... } from 'drizzle-orm/postgres.js'`
|
||||
|
||||
#### MySQL
|
||||
|
||||
- `import { ... } from 'drizzle-orm-mysql'` -> `import { ... } from 'drizzle-orm/mysql-core'`
|
||||
- `import { ... } from 'drizzle-orm-mysql/mysql2'` -> `import { ... } from 'drizzle-orm/mysql2'`
|
||||
|
||||
#### SQLite
|
||||
|
||||
- `import { ... } from 'drizzle-orm-sqlite'` -> `import { ... } from 'drizzle-orm/sqlite-core'`
|
||||
- `import { ... } from 'drizzle-orm-sqlite/better-sqlite3'` -> `import { ... } from 'drizzle-orm/better-sqlite3'`
|
||||
- `import { ... } from 'drizzle-orm-sqlite/d1'` -> `import { ... } from 'drizzle-orm/d1'`
|
||||
- `import { ... } from 'drizzle-orm-sqlite/bun'` -> `import { ... } from 'drizzle-orm/bun-sqlite'`
|
||||
- `import { ... } from 'drizzle-orm-sqlite/sql.js'` -> `import { ... } from 'drizzle-orm/sql.js'`
|
||||
@@ -0,0 +1 @@
|
||||
- Added feature showcase section to README
|
||||
@@ -0,0 +1 @@
|
||||
- Fixed package.json require path in 'drizzle-orm/version'
|
||||
@@ -0,0 +1,22 @@
|
||||
We have released [AWS Data API support](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) for PostgreSQL
|
||||
|
||||
---
|
||||
|
||||
Connection example
|
||||
|
||||
```typescript
|
||||
import { drizzle, migrate } from 'drizzle-orm/aws-data-api/pg';
|
||||
|
||||
const rdsClient = new RDSDataClient({});
|
||||
|
||||
const db = drizzle(rdsClient, {
|
||||
database: '',
|
||||
secretArn: '',
|
||||
resourceArn: '',
|
||||
});
|
||||
|
||||
await migrate(db, { migrationsFolder: '' });
|
||||
```
|
||||
|
||||
> **Note**:
|
||||
> All drizzle pg data types are working well with data api, except of `interval`. This type is not yet mapped in proper way
|
||||
@@ -0,0 +1,23 @@
|
||||
We have released [SQLite Proxy Driver](https://github.com/drizzle-team/drizzle-orm/tree/main/examples/sqlite-proxy)
|
||||
|
||||
---
|
||||
|
||||
Perfect way to setup custom logic for database calls instead of predefined drivers
|
||||
|
||||
Should work well with serverless apps 🚀
|
||||
|
||||
```typescript
|
||||
// Custom Proxy HTTP driver
|
||||
const db = drizzle(async (sql, params, method) => {
|
||||
try {
|
||||
const rows = await axios.post('http://localhost:3000/query', { sql, params, method });
|
||||
|
||||
return { rows: rows.data };
|
||||
} catch (e: any) {
|
||||
console.error('Error from sqlite proxy server: ', e.response.data)
|
||||
return { rows: [] };
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
> For more example you can check [full documentation](https://github.com/drizzle-team/drizzle-orm/tree/main/examples/sqlite-proxy)
|
||||
@@ -0,0 +1,19 @@
|
||||
We have released [Planetscale Serverless](https://github.com/planetscale/database-js) driver support
|
||||
|
||||
---
|
||||
|
||||
Usage example:
|
||||
|
||||
```typescript
|
||||
import { drizzle } from 'drizzle-orm/planetscale-serverless';
|
||||
import { connect } from '@planetscale/database';
|
||||
|
||||
// create the connection
|
||||
const connection = connect({
|
||||
host: process.env['DATABASE_HOST'],
|
||||
username: process.env['DATABASE_USERNAME'],
|
||||
password: process.env['DATABASE_PASSWORD'],
|
||||
});
|
||||
|
||||
const db = drizzle(connection);
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user