Breaking changes
Note:
[email protected]
can be used with[email protected]
or higher. The same applies to Drizzle Kit. If you run a Drizzle Kit command, it will check and prompt you for an upgrade (if needed). You can check for Drizzle Kit updates. below
PostgreSQL indexes API was changed
The previous Drizzle+PostgreSQL indexes API was incorrect and was not aligned with the PostgreSQL documentation. The good thing is that it was not used in queries, and drizzle-kit didn’t support all properties for indexes. This means we can now change the API to the correct one and provide full support for it in drizzle-kit
Previous API
- No way to define SQL expressions inside
.on
. .using
and.on
in our case are the same thing, so the API is incorrect here..asc()
,.desc()
,.nullsFirst()
, and.nullsLast()
should be specified for each column or expression on indexes, but not on an index itself.
Current API
New Features
🎉 “pg_vector” extension support
There is no specific code to create an extension inside the Drizzle schema. We assume that if you are using vector types, indexes, and queries, you have a PostgreSQL database with the
pg_vector
extension installed.
You can now specify indexes for pg_vector
and utilize pg_vector
functions for querying, ordering, etc.
Let’s take a few examples of pg_vector
indexes from the pg_vector
docs and translate them to Drizzle
L2 distance, Inner product and Cosine distance
L1 distance, Hamming distance and Jaccard distance - added in pg_vector 0.7.0 version
For queries, you can use predefined functions for vectors or create custom ones using the SQL template operator.
You can also use the following helpers:
If pg_vector
has some other functions to use, you can replicate implimentation from existing one we have. Here is how it can be done
Name it as you wish and change the operator. This example allows for a numbers array, strings array, string, or even a select query. Feel free to create any other type you want or even contribute and submit a PR
Examples
Let’s take a few examples of pg_vector
queries from the pg_vector
docs and translate them to Drizzle
🎉 New PostgreSQL types: point
, line
You can now use point
and line
from PostgreSQL Geometric Types
Type point
has 2 modes for mappings from the database: tuple
and xy
.
-
tuple
will be accepted for insert and mapped on select to a tuple. So, the database Point(1,2) will be typed as [1,2] with drizzle. -
xy
will be accepted for insert and mapped on select to an object with x, y coordinates. So, the database Point(1,2) will be typed as{ x: 1, y: 2 }
with drizzle
Type line
has 2 modes for mappings from the database: tuple
and abc
.
-
tuple
will be accepted for insert and mapped on select to a tuple. So, the database Line3 will be typed as [1,2,3] with drizzle. -
abc
will be accepted for insert and mapped on select to an object with a, b, and c constants from the equationAx + By + C = 0
. So, the database Line3 will be typed as{ a: 1, b: 2, c: 3 }
with drizzle.
🎉 Basic “postgis” extension support
There is no specific code to create an extension inside the Drizzle schema. We assume that if you are using postgis types, indexes, and queries, you have a PostgreSQL database with the
postgis
extension installed.
geometry
type from postgis extension:
mode
Type geometry
has 2 modes for mappings from the database: tuple
and xy
.
tuple
will be accepted for insert and mapped on select to a tuple. So, the database geometry will be typed as [1,2] with drizzle.xy
will be accepted for insert and mapped on select to an object with x, y coordinates. So, the database geometry will be typed as{ x: 1, y: 2 }
with drizzle
type
The current release has a predefined type: point
, which is the geometry(Point)
type in the PostgreSQL PostGIS extension. You can specify any string there if you want to use some other type
Drizzle Kit updates: [email protected]
Release notes here are partially duplicated from [email protected]
New Features
🎉 Support for new types
Drizzle Kit can now handle:
point
andline
from PostgreSQLvector
from the PostgreSQLpg_vector
extensiongeometry
from the PostgreSQLPostGIS
extension
🎉 New param in drizzle.config - extensionsFilters
The PostGIS extension creates a few internal tables in the public
schema. This means that if you have a database with the PostGIS extension and use push
or introspect
, all those tables will be included in diff
operations. In this case, you would need to specify tablesFilter
, find all tables created by the extension, and list them in this parameter.
We have addressed this issue so that you won’t need to take all these steps. Simply specify extensionsFilters
with the name of the extension used, and Drizzle will skip all the necessary tables.
Currently, we only support the postgis
option, but we plan to add more extensions if they create tables in the public
schema.
The postgis
option will skip the geography_columns
, geometry_columns
, and spatial_ref_sys
tables
Improvements
Update zod schemas for database credentials and write tests to all the positive/negative cases
- support full set of SSL params in kit config, provide types from node:tls connection
Normilized SQLite urls for libsql
and better-sqlite3
drivers
Those drivers have different file path patterns, and Drizzle Kit will accept both and create a proper file path format for each
Updated MySQL and SQLite index-as-expression behavior
In this release MySQL and SQLite will properly map expressions into SQL query. Expressions won’t be escaped in string but columns will be
Bug Fixes
- [BUG]: multiple constraints not added (only the first one is generated) - #2341
- Drizzle Studio: Error: Connection terminated unexpectedly - #435
- Unable to run sqlite migrations local - #432
- error: unknown option ‘—config’ - #423
How push
and generate
works for indexes
Limitations
You should specify a name for your index manually if you have an index on at least one expression
Example
Push won’t generate statements if these fields(list below) were changed in an existing index:
- expressions inside
.on()
and.using()
.where()
statements- operator classes
.op()
on columns
If you are using push
workflows and want to change these fields in the index, you would need to:
- Comment out the index
- Push
- Uncomment the index and change those fields
- Push again
For the generate
command, drizzle-kit
will be triggered by any changes in the index for any property in the new drizzle indexes API, so there are no limitations here.