Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update dependency drizzle-kit to ^0.23.0 #93

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

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented May 9, 2024

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
drizzle-kit ^0.20.17 -> ^0.23.0 age adoption passing confidence

Release Notes

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

v0.23.0

Compare Source

v0.22.8: 0.22.8

Compare Source

v0.22.7

Compare Source

v0.22.6: 0.22.6

Compare Source

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

v0.22.5: 0.22.5

Compare Source

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

v0.22.4: 0.22.4

Compare Source

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

v0.22.3: 0.22.3

Compare Source

  • πŸ› Fix Cannot use 'in' operator to search for 'default' in undefined error on push and generate

v0.22.2: 0.22.2

Compare Source

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

v0.22.1: 0.22.1

Compare Source

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

  • πŸŽ‰ Refactor the d1-http driver to properly show the table row count

v0.22.0: 0.22.0

Compare Source

New Features

πŸŽ‰ Full support for indexes in PostgreSQL

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

Previous API

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

Current API

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

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

πŸŽ‰ Support for new types

Drizzle Kit can now handle:

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

πŸŽ‰ New param in drizzle.config - extensionsFilters

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

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

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

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

import { defineConfig } from 'drizzle-kit'

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

Improvements

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

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

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

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

πŸ‘ Updated MySQL and SQLite index-as-expression behavior

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

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

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

Bug Fixes

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

How push and generate works for indexes

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

Example

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

// but

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

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

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

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

v0.21.4

Compare Source

bug fixes

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

v0.21.3

Compare Source

Cloudflare D1 HTTP API support πŸŽ‰
Drizzle Chrome Extension now has support for Cloudflare D1!

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

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

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

Bug fixes

v0.21.2

Compare Source

Bug fixes

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

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

Tickets that were closed

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

v0.21.1

Compare Source

Drizzle Studio support for per-database preferences

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

Drizzle Studio support for advanced bug report context

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

image

image

v0.21.0

Compare Source

Breaking changes
❗ Snapshots Upgrade

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

❗ Removing :dialect from drizzle-kit cli commands

You can now just use commands, like:

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

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

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

Usage examples for all new and updated commands

import { defineConfig } from "drizzle-kit"

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

Drizzle driver selection follows the current strategy:

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

If no driver is specified:

  • For postgresql dialect, Drizzle will:

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

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

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

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

New Features
πŸŽ‰ Pull relations

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

For more info about relations, please check the docs

πŸŽ‰ Custom name for generated migrations

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

Usage

drizzle-kit generate --name init_db
πŸŽ‰ New command migrate

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

Usage

drizzle-kit migrate

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

import { defineConfig } from "drizzle-kit"

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

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

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

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

Configuration

πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

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

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

πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the dependencies Pull requests that update a dependency file label May 9, 2024
Copy link

vercel bot commented May 9, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pokezoo ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 1:49pm

@renovate renovate bot force-pushed the renovate/drizzle-kit-0.x branch 2 times, most recently from 52f0d5d to 6531d30 Compare May 10, 2024 07:08
@renovate renovate bot force-pushed the renovate/drizzle-kit-0.x branch from 6531d30 to 208cc76 Compare May 31, 2024 10:02
@renovate renovate bot changed the title Update dependency drizzle-kit to ^0.21.0 Update dependency drizzle-kit to ^0.22.0 May 31, 2024
@renovate renovate bot force-pushed the renovate/drizzle-kit-0.x branch from 208cc76 to aad1bb0 Compare June 9, 2024 05:26
@renovate renovate bot force-pushed the renovate/drizzle-kit-0.x branch from aad1bb0 to b11a4af Compare July 10, 2024 13:49
@renovate renovate bot changed the title Update dependency drizzle-kit to ^0.22.0 Update dependency drizzle-kit to ^0.23.0 Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant