chore(deps): update dependency drizzle-orm to v0.33.0 - autoclosed #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.30.9
->0.33.0
Release Notes
drizzle-team/drizzle-orm (drizzle-orm)
v0.33.0
Compare Source
Breaking changes (for some of postgres.js users)
Bugs fixed for this breaking change
If you were using
postgres-js
withjsonb
fields, you might have seen stringified objects in your database, while drizzle insert and select operations were working as expected.You need to convert those fields from strings to actual JSON objects. To do this, you can use the following query to update your database:
if you are using jsonb:
if you are using json:
We've tested it in several cases, and it worked well, but only if all stringified objects are arrays or objects. If you have primitives like strings, numbers, booleans, etc., you can use this query to update all the fields
if you are using jsonb:
if you are using json:
If nothing works for you and you are blocked, please reach out to me @AndriiSherman. I will try to help you!
Bug Fixes
v0.32.2
Compare Source
AnySQLiteUpdate
- thanks @veloiiv0.32.1
Compare Source
v0.32.0
Compare Source
Release notes for
drizzle-orm@0.32.0
anddrizzle-kit@0.23.0
New Features
🎉 MySQL
$returningId()
functionMySQL itself doesn't have native support for
RETURNING
after usingINSERT
. There is only one way to do it forprimary keys
withautoincrement
(orserial
) types, where you can accessinsertId
andaffectedRows
fields. We've prepared an automatic way for you to handle such cases with Drizzle and automatically receive all inserted IDs as separate objectsAlso with Drizzle, you can specify a
primary key
with$default
function that will generate custom primary keys at runtime. We will also return those generated keys for you in the$returningId()
call🎉 PostgreSQL Sequences
You can now specify sequences in Postgres within any schema you need and define all the available properties
Example
🎉 PostgreSQL Identity Columns
Source: As mentioned, the
serial
type in Postgres is outdated and should be deprecated. Ideally, you should not use it.Identity columns
are the recommended way to specify sequences in your schema, which is why we are introducing theidentity columns
featureExample
You can specify all properties available for sequences in the
.generatedAlwaysAsIdentity()
function. Additionally, you can specify custom names for these sequencesPostgreSQL docs reference.
🎉 PostgreSQL Generated Columns
You can now specify generated columns on any column supported by PostgreSQL to use with generated columns
Example with generated column for
tsvector
In case you don't need to reference any columns from your table, you can use just
sql
template or astring
🎉 MySQL Generated Columns
You can now specify generated columns on any column supported by MySQL to use with generated columns
You can specify both
stored
andvirtual
options, for more info you can check MySQL docsAlso MySQL has a few limitation for such columns usage, which is described here
Drizzle Kit will also have limitations for
push
command:You can't change the generated constraint expression and type using
push
. Drizzle-kit will ignore this change. To make it work, you would need todrop the column
,push
, and thenadd a column with a new expression
. This was done due to the complex mapping from the database side, where the schema expression will be modified on the database side and, on introspection, we will get a different string. We can't be sure if you changed this expression or if it was changed and formatted by the database. As long as these are generated columns andpush
is mostly used for prototyping on a local database, it should be fast todrop
andcreate
generated columns. Since these columns aregenerated
, all the data will be restoredgenerate
should have no limitationsExample
In case you don't need to reference any columns from your table, you can use just
sql
template or astring
in.generatedAlwaysAs()
🎉 SQLite Generated Columns
You can now specify generated columns on any column supported by SQLite to use with generated columns
You can specify both
stored
andvirtual
options, for more info you can check SQLite docsAlso SQLite has a few limitation for such columns usage, which is described here
Drizzle Kit will also have limitations for
push
andgenerate
command:You can't change the generated constraint expression with the stored type in an existing table. You would need to delete this table and create it again. This is due to SQLite limitations for such actions. We will handle this case in future releases (it will involve the creation of a new table with data migration).
You can't add a
stored
generated expression to an existing column for the same reason as above. However, you can add avirtual
expression to an existing column.You can't change a
stored
generated expression in an existing column for the same reason as above. However, you can change avirtual
expression.You can't change the generated constraint type from
virtual
tostored
for the same reason as above. However, you can change fromstored
tovirtual
.New Drizzle Kit features
🎉 Migrations support for all the new orm features
PostgreSQL sequences, identity columns and generated columns for all dialects
🎉 New flag
--force
fordrizzle-kit push
You can auto-accept all data-loss statements using the push command. It's only available in CLI parameters. Make sure you always use it if you are fine with running data-loss statements on your database
🎉 New
migrations
flagprefix
You can now customize migration file prefixes to make the format suitable for your migration tools:
index
is the default type and will result in0001_name.sql
file names;supabase
andtimestamp
are equal and will result in20240627123900_name.sql
file names;unix
will result in unix seconds prefixes1719481298_name.sql
file names;none
will omit the prefix completely;Example: Supabase migrations format
v0.31.4
Compare Source
v0.31.3
Compare Source
Bug fixed
New Prisma-Drizzle extension
For more info, check docs: https://orm.drizzle.team/docs/prisma
v0.31.2
Compare Source
🎉 Added support for TiDB Cloud Serverless driver:
v0.31.1
Compare Source
New Features
Live Queries 🎉
As of
v0.31.1
Drizzle ORM now has native support for Expo SQLite Live Queries!We've implemented a native
useLiveQuery
React Hook which observes necessary database changes and automatically re-runs database queries. It works with both SQL-like and Drizzle Queries:We've intentionally not changed the API of ORM itself to stay with conventional React Hook API, so we have
useLiveQuery(databaseQuery)
as opposed todb.select().from(users).useLive()
ordb.query.users.useFindMany()
We've also decided to provide
data
,error
andupdatedAt
fields as a result of hook for concise explicit error handling following practices ofReact Query
andElectric SQL
v0.31.0
Compare Source
Breaking changes
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
.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
You can now specify indexes for
pg_vector
and utilizepg_vector
functions for querying, ordering, etc.Let's take a few examples of
pg_vector
indexes from thepg_vector
docs and translate them to DrizzleL2 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 doneName 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 thepg_vector
docs and translate them to Drizzle🎉 New PostgreSQL types:
point
,line
You can now use
point
andline
from PostgreSQL Geometric TypesType
point
has 2 modes for mappings from the database:tuple
andxy
.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 drizzleType
line
has 2 modes for mappings from the database:tuple
andabc
.tuple
will be accepted for insert and mapped on select to a tuple. So, the database Line{1,2,3} 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 Line{1,2,3} will be typed as{ a: 1, b: 2, c: 3 }
with drizzle.🎉 Basic "postgis" extension support
geometry
type from postgis extension:mode
Type
geometry
has 2 modes for mappings from the database:tuple
andxy
.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 drizzletype
The current release has a predefined type:
point
, which is thegeometry(Point)
type in the PostgreSQL PostGIS extension. You can specify any string there if you want to use some other typeDrizzle Kit updates:
drizzle-kit@0.22.0
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 usepush
orintrospect
, all those tables will be included indiff
operations. In this case, you would need to specifytablesFilter
, 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 thepublic
schema.The
postgis
option will skip thegeography_columns
,geometry_columns
, andspatial_ref_sys
tablesImprovements
Update zod schemas for database credentials and write tests to all the positive/negative cases
Normilized SQLite urls for
libsql
andbetter-sqlite3
driversThose 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
How
push
andgenerate
works for indexesLimitations
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:
.on()
and.using()
.where()
statements.op()
on columnsIf you are using
push
workflows and want to change these fields in the index, you would need to:For the
generate
command,drizzle-kit
will be triggered by any changes in the index for any property in the new drizzle indexes API, so there are no limitations here.v0.30.10
Compare Source
New Features
🎉
.if()
function added to all WHERE expressionsSelect all users after cursors if a cursor value was provided
Bug Fixes
.all
,.values
,.execute
functions in AWS DataAPIConfiguration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - "before 4am on Monday" (UTC).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.