migs
Explore posts from serversDTDrizzle Team
•Created by migs on 6/14/2024 in #help
TypeError: Cannot read properties of undefined (reading 'columns') - SQLite TursoDB
I've seen this problem mentioned here before, but apparently its still present in the newest version of drizzle. I just updated drizzle kit to 0.22.7 and orm to 0.31.2 (latest versions) and the problem persists. Using turso DB
8 replies
DTDrizzle Team
•Created by migs on 4/21/2024 in #help
Field 'email' doesn't have a default with connection pool in MySQL
Im getting this error since switching to a connection pool from single connection. This happens when creating a new user in my app with next-auth.
I tried changing to connection pool because I kept getting the " Can't add new command when connection is in closed state. " when leaving the app open for a while, as others mentioned before.
Using normal Mysql (despite the logs mentioning planetscale -Im not using planetscale)
For some reason this is not happening when running locally, only on prod.
Does somebody know what this is ?
2 replies
TTCTheo's Typesafe Cult
•Created by migs on 1/31/2024 in #questions
TRPC Security/ Authorization Concerns
Hey guys, I'm a bit worried the default protected procedure isn't enough to secure data in my app. As I understand it, if someone just logs in my app, he'll have a valid session, and could potentially reverse engineer the trpc queries and access other users data, is there something I'm missing here ?
I'm also incredibly confused by TRPC context, should I be querying my db in the context to check if user has authorization for the data he's requesting ? Every example I find is only passing session and db connection, haven't seen any type of authorization method here.
13 replies
TTCTheo's Typesafe Cult
•Created by migs on 1/22/2024 in #questions
How do I change my schema without data loss in MySQL ?
Hey everyone, I'm pretty new to SQL so I'm having some disturbing questions in my mind.
How should I proceed when I need to add a new and notNull column to a schema without losing data?
Do I need to set a default ? But then I can't remove the default because it causes data-loss, so I might aswell not use a notNull field, but what if I have to ?
I've been reading about migrations, but I don't really see a big difference between a migration and a db:push (I'm using drizzle + planetscale)
What is the correct way to approach this problem?
Thank you!
3 replies
DTDrizzle Team
•Created by migs on 11/24/2023 in #help
Querying table based on a field of a related table
Hey everyone, I have no idea what im doing wrong, but the goal here is to get every subscription which its related plan, has the spaceId field according to an input. Here's what I got after reading the docs:
const subscriptions = await ctx.db.query.subscriptions.findMany({
with: {
plan: {
where: (plan, { eq }) => eq(plans.spaceId, input.spaceId),
},
},
});
Typescript is complaining on the "where" , saying I can't use it here. I saw a very similar example on the docs:
await db.query.posts.findMany({
where: (posts, { eq }) => (eq(posts.id, 1)),
with: {
comments: {
where: (comments, { lt }) => lt(comments.createdAt, new Date()),
},
},
});
The only difference is the type of relation, where in my case subscription has a relation with one plan, and the example on the docs the posts have a relation of many comments. Should I be querying for plans and filtering the subscriptions from there? Doesn't feel right when in fact what I want is the subscriptions.
4 replies