terryball
terryball
Explore posts from servers
DTDrizzle Team
Created by terryball on 6/3/2024 in #help
Ok to delete old migration files?
Thanks @Xazu - what if they have been applied on production? It's not a huge deal, I just have a couple hundred migration files and am hoping to clean things up a bit.
5 replies
DTDrizzle Team
Created by terryball on 3/14/2024 in #help
Type error working with Postgres dates in v.0.30.1
Interesting, ok thanks @nateeo
9 replies
DTDrizzle Team
Created by terryball on 3/14/2024 in #help
Type error working with Postgres dates in v.0.30.1
Giving this a quick bump to see if anyone else has experienced this or has any tips to solve. It's currently blocking me from upgrading to v 0.30.x, so I'm very curious. Thanks!
9 replies
DTDrizzle Team
Created by terryball on 11/15/2023 in #help
Chaining/combining $dynamic query functions
In this line: const sortOrder = order === 'asc' ? asc : desc asc and desc are the drizzle-provided sort functions
10 replies
DTDrizzle Team
Created by terryball on 11/15/2023 in #help
Chaining/combining $dynamic query functions
Sure - I can't promise that this is the best way to do it but here you go: export function withOrderBy<T extends PgSelect>( query: T, { order = 'asc', orderBy, sortMap, nullsLast = true, }: { order?: 'asc' | 'desc' orderBy?: string sortMap: Record<string, PgColumn | SQL | SQL.Aliased> & Record<'default', PgColumn | SQL> nullsLast?: boolean } ) { const sortOrder = order === 'asc' ? asc : desc const orderBySql = orderBy ? sortMap[orderBy] || sortMap.default : sortMap.default return query.orderBy( sortOrder(orderBySql).append( sql.raw( nulls ${nullsLast ? 'last' : 'first'}) ) ) } And here's how I use it withTableFeatures(qb, { order: 'desc', orderBy: params.orderBy, sortMap: { firstName: users.firstName, timestamp: sessions.timestamp, vendorName: vendors.name, default: sessions.timestamp, }, }) Where qb is any drizzle query ending with .$dynamic()
10 replies
DTDrizzle Team
Created by terryball on 11/15/2023 in #help
Chaining/combining $dynamic query functions
Yep, this is what I stuck with
10 replies
DTDrizzle Team
Created by terryball on 1/25/2024 in #help
SELECT DISTINCT error in Drizzle query but not in raw query
Got it, thank you so much @solo I'll give that a shot
5 replies
DTDrizzle Team
Created by terryball on 1/25/2024 in #help
SELECT DISTINCT error in Drizzle query but not in raw query
Yes:
const searchFn = sqlsimilarity(${vendors.name}, ${query})
5 replies
DTDrizzle Team
Created by terryball on 1/16/2024 in #help
Safe to delete migration files?
Besides general cleanup / organization, I'm also noticing that my drizzle-kit operations and migrations are taking much longer, which I imagine is due in part to the fact that I have hundreds of migration files. I'd love to be able to consolidate them into just 1 or 2 files, but I'm not sure of the implications of deleting the migration files and then re-running drizzle-kit generate
6 replies
DTDrizzle Team
Created by terryball on 1/16/2024 in #help
Safe to delete migration files?
Thank you @deadlinecode that's very helpful. Good tip on generating one final migration after developing - I have lots of quick reversions/edits in my migration history which adds to the bloat.
6 replies