Drizzle Team

DT

Drizzle Team

Join the community to ask questions about Drizzle Team and get answers from other members.

Join
DDerock4/23/2024

SQLite: set fk constraint to be "DEFERRABLE INITIALLY DEFERRED"

I would like to use this feature of sqlite, but I don't see it mentioned anywhere in the docs. A quick search shows that there's an open issue (#1429) but no progress has been made. Are there any temporary workarounds to this? Like can I add in my own SQL to the end of a column definition?...
TTAINCER4/23/2024

Drizzle wants to truncate my tables when not needed

I have this schema: ```ts export const users = sqliteTable('users', { id: text('id').notNull().primaryKey(), username: text('username').notNull(),...
PPramus4/23/2024

SQLean's uuid4() in SQLite CREATE TABLE

I'm using Turso, enabled SQLean uuid extension and I would like to generate a table via drizzle-kit with a following id:
id: text("id")
.primaryKey()
.default(sql`uuid4()`),
id: text("id")
.primaryKey()
.default(sql`uuid4()`),
...
AAaroned4/23/2024

How can we specify COLLATE on the schema?

There is a feature request here: https://github.com/drizzle-team/drizzle-orm/issues/638 For adding support for COLLATE to the schema. This seems like a fairly simple feature request, but very useful, especially for case insensitive queries. How can we get it on the roadmap?...
Ppineappaul4/23/2024

Drizzle pg client throwing `scanner_yyerror` on push

Getting the following error upon running drizzle-kit push:pg to my local postgres. Drizzle-Kit version 0.20.17 Drizzle-ORM version 0.30.9 using pg version 8.11.3 ...
Hhkg4/22/2024

DrizzleError: Rollback is being rethrown unexpectedly

No matter which error I throw for the rollback - it doesn't work as indented because it bleeds outside the transaction as postgres-js is rethrowing it. ```ts const mute = await db.transaction(async (tx) => { await tx.rollback();...
Cchimelli4/22/2024

Id being required in types when using insert and values

Hello! I' been following the tutorial and I'm having a issue with the following function: ```js export const addTodo = async (text: string) => { await db.insert(todo).values({ text: text,...
JJakesdoc4/22/2024

Failed push to planetscale

Every time I try to push my schema to Planetscale, I get the following error: ``` if (unsquashed.columns.length === 1 && currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]].type === "serial" && prevSchema.tables[statement.tableName].columns[unsquashed.columns[0]].type === "serial" && currentSchema.tables[statement.tableName].columns[unsquashed.columns[0]].name === unsquashed.columns[0]) { ^ ...
JJakesdoc4/22/2024

Select parent rows where child exists

I want to use a relational query to select all users and their posts where users have at least one post.
Hhirefrank4/22/2024

Creating a View with Turso/Sqlite

```export const jobsView = sqliteView("jobsView").as((qb) => qb .select({ id: job.id, title: job.title,...
EEmirhan4/22/2024

How to update "updated_at" column automaticly when related row is updated?

Hello. I'm using PostgreSQL as a dbms. So driver is pg. I want to update the "updated_at" column when the row is updated. Is this implementation is ok for the feature. ...
MJIMd Jahidul Islam milon4/22/2024

wrap migrations in transaction

does drizzle wrap migrations in transaction?
Ssan4d4/22/2024

Error with Nested Transactions

I'm experiencing an issue with nested transactions on neon serverless 0.9.1, drizzle-orm 0.30.9, and ws 8.16.0. The following works locally but not in production: ```javascript async function createOrGet<T>(...
RRep.4/22/2024

Supabase branching w/ Drizzle?

Does anyone know if it is possible to get Supabase branching working with Drizzle migrations? (https://supabase.com/docs/guides/platform/branching)
Ppeterg46664/22/2024

Type inference is not working when findFirst is extracted

Hey typescript wizards, could anyone spot what I'm doing wrong here? ```ts type OrgTableQueryParams = Parameters< typeof db.query.organizationTable.findFirst...
Jjjjrmy4/22/2024

Drizzle Query, Relationship Sub-Query

I have Domains and Products, and a pivot between them (DomainProducts). I'd like to query (findFirst) the DomainProducts where DomainProducts.Slug='hello-world' and DomainProducts.Domain.Url='mydomain.com' Is that possible? It seems like it's not possible to do it with the Query, instead I have to use it like a normal Select and manually do the join?...
BDBot Dev4/21/2024

MariaDB driver and generate migrations

The company im working for insists on using MariaDB but im having issues generating migrations for my mariaDB. For schemas i am using 'drizzle-orm/mysql-core' and i create tables with mysqlTable() and for generating the migrations im using drizzle-kit generate:mysql. In the drizzle.config.ts i set the driver to this driver: 'mysql2' when i now want to run drizzle-kit push:mysql i get this error message...
BDBot Dev4/21/2024

Naming Migrations

how do i set a name for a new migration when running drizzle-kit generate:mysql ? i tried setting a flag like --tag=new_migration or --name=new_migration. i wouldn't want to rename them manually afterwards everytime 😄
Ffranek.stodulski4/21/2024

[postgres][zod] createInsertSchema

Hey! Trying to make my Sveltekit form schema. Here is my example: ```export const userAccessesFormSchema = createInsertSchema(usersTable, { id: z.string().min(1), hasDatabase: z.boolean(),...
No description
Next