migs
migs
Explore posts from servers
DTDrizzle Team
Created by migs on 6/14/2024 in #help
TypeError: Cannot read properties of undefined (reading 'columns') - SQLite TursoDB
pnpm db:push

> project@0.1.0 db:push C:\Users\migue\project
> dotenv drizzle-kit push

drizzle-kit: v0.22.7
drizzle-orm: v0.31.2

No config path provided, using default path
Reading config file 'C:\Users\migue\project\drizzle.config.ts'
[✓] Pulling schema from database...
TypeError: Cannot read properties of undefined (reading 'columns')
at _moveDataStatements (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:120565:65)
at logSuggestionsAndReturn2 (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:120787:45)
at sqlitePush (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:122591:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _Command.<anonymous> (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:129691:7)
pnpm db:push

> project@0.1.0 db:push C:\Users\migue\project
> dotenv drizzle-kit push

drizzle-kit: v0.22.7
drizzle-orm: v0.31.2

No config path provided, using default path
Reading config file 'C:\Users\migue\project\drizzle.config.ts'
[✓] Pulling schema from database...
TypeError: Cannot read properties of undefined (reading 'columns')
at _moveDataStatements (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:120565:65)
at logSuggestionsAndReturn2 (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:120787:45)
at sqlitePush (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:122591:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _Command.<anonymous> (C:\Users\migue\project\node_modules\.pnpm\drizzle-kit@0.22.7\node_modules\drizzle-kit\bin.cjs:129691:7)
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
[next-auth][error][adapter_error_createUser]
https://next-auth.js.org/errors#adapter_error_createuser Field 'email' doesn't have a default value {
message: "Field 'email' doesn't have a default value",
stack: "Error: Field 'email' doesn't have a default value\n" +
' at PromisePool.query (/app/node_modules/.pnpm/mysql2@3.9.2/node_modules/mysql2/promise.js:356:22)\n' +
' at MySql2PreparedQuery.execute (file:///app/node_modules/.pnpm/drizzle-orm@0.30.8_@planetscale+database@1.11.0_@types+react@18.2.37_mysql2@3.9.2_react@18.2.0/node_modules/drizzle-orm/mysql2/session.js:48:21)\n' +
' at QueryPromise.execute (file:///app/node_modules/.pnpm/drizzle-orm@0.30.8_@planetscale+database@1.11.0_@types+react@18.2.37_mysql2@3.9.2_react@18.2.0/node_modules/drizzle-orm/mysql-core/query-builders/insert.js:90:27)\n' +
' at QueryPromise.then (file:///app/node_modules/.pnpm/drizzle-orm@0.30.8_@planetscale+database@1.11.0_@types+react@18.2.37_mysql2@3.9.2_react@18.2.0/node_modules/drizzle-orm/query-promise.js:21:17)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
name: 'Error'
}
[next-auth][error][adapter_error_createUser]
https://next-auth.js.org/errors#adapter_error_createuser Field 'email' doesn't have a default value {
message: "Field 'email' doesn't have a default value",
stack: "Error: Field 'email' doesn't have a default value\n" +
' at PromisePool.query (/app/node_modules/.pnpm/mysql2@3.9.2/node_modules/mysql2/promise.js:356:22)\n' +
' at MySql2PreparedQuery.execute (file:///app/node_modules/.pnpm/drizzle-orm@0.30.8_@planetscale+database@1.11.0_@types+react@18.2.37_mysql2@3.9.2_react@18.2.0/node_modules/drizzle-orm/mysql2/session.js:48:21)\n' +
' at QueryPromise.execute (file:///app/node_modules/.pnpm/drizzle-orm@0.30.8_@planetscale+database@1.11.0_@types+react@18.2.37_mysql2@3.9.2_react@18.2.0/node_modules/drizzle-orm/mysql-core/query-builders/insert.js:90:27)\n' +
' at QueryPromise.then (file:///app/node_modules/.pnpm/drizzle-orm@0.30.8_@planetscale+database@1.11.0_@types+react@18.2.37_mysql2@3.9.2_react@18.2.0/node_modules/drizzle-orm/query-promise.js:21:17)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
name: 'Error'
}
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