Eddy Vinck
DTDrizzle Team
•Created by Eddy Vinck on 10/25/2024 in #help
aggregation core queries in extras?
2 replies
DTDrizzle Team
•Created by Eddy Vinck on 6/13/2024 in #help
How to do an UPDATE with a JOIN in Drizzle ORM?
Something like this
https://stackoverflow.com/questions/7869592/how-to-do-an-update-join-in-postgresql
I have this schema where I want to do an update on the "user_usage" table, but only if
users.subscriptionId
is a certain string or in a set of string values .
I think what I want here is an UPDATE with a JOIN. Could not quite figure out how to do this with Drizzle ORM.
Something like this from StackOverflow:
But maybe a common table expression (CTE) could work like this example from StackOverflow?
Schema in next post5 replies
DTDrizzle Team
•Created by Eddy Vinck on 4/18/2024 in #help
Drizzle schema vs SQL when migrating serial id to uuid?
I have a Postgres DB and I want to migrate serial primary key IDs to UUIDs, and I'm running into some potential issues here.
I've already added the
uuid
columns and user_uuid
, thing_uuid
relation columns to my tables via my Drizzle schema. Using PgAdmin I verified that the various uuid
columns are not empty, and I've filled the relational UUIDs with queries like this one:
Problem 1:
To prevent having to update my whole application code, I want to basically swap the ID and UUID columns and let them keep the id
and user_id
column names, but with uuid
primary keys of course.
Is this something I can solve by editing my schema, or would this be something I need to do by running SQL queries?
Problem 2:
If I need to do this via SQL queries, how do I then reflect this new state in my Drizzle schema? Maybe introspecting would be a good option here?
Or maybe I should just change my schema, generate a migration and then edit the migration by hand before running it?
Note: this is a development database migration, so this is essentially practice for whenever I might need to do something similar in prod50 replies
DTDrizzle Team
•Created by Eddy Vinck on 3/1/2024 in #help
feedback wanted: subquery in update
This is what I'm trying to do. I still need to make a few other adjustments to my app before I can run it, but are there any things I should be doing differently here?
I want to use a subquery to avoid the network roundtrip of just a bunch of user IDs
I'm using MySQL if that makes a difference.
1 replies