Jack
Jack
Explore posts from servers
DTDrizzle Team
Created by Jack on 2/8/2025 in #help
Complex seeding tasks
Heyo, I am just transitioning to drizzle-seed, but I am struggling to replicate the power I had with my monolithic file of for loops. One example is we have a table called week_number_systems which holds things like ISO 8601, US Sunday etc. Then, we run a task to populate another table called week_definitions. The week definitions table has each row represent a week, and a week number system can have many week definitions (one to many). This is so that our app's schedule is dynamic, and can support any type of week. The week definition has a starts_at and ends_at, as well as a year and week (because 1 day, can have have a different week number or year as per ISO 8601 or US Sunday). I am thinking, with Drizzle seed (which is an amazing package by the way) is it possible to seed things like the week definition, where the week numbering system is ISO 8601, and as such each week starts on a monday? 😅
3 replies
DTDrizzle Team
Created by Jack on 10/3/2024 in #help
Drizzle migration, any way to create an index BEFORE the constraints are added to tables?
I have a multi-tenanted application whereby I store the tenant ID on as many tables as possible. I want to ensure each table has the correct pairing of the userId to the tenantId using a unique index pairing the two columns in the users table, then enforcing that pairing as a foreign key constraint on the tables that reference a userId and tenantId. However, the generated migration file creates the indexes AFTER the constraints are added, causing the migration to fail. I can edit this migration and move the line further up, but for me that defeats the purpose of a lot of the autonomy migrations give me. 😅 Any ideas or help? Thanks a lot
1 replies
DTDrizzle Team
Created by Jack on 6/1/2024 in #help
db.insert(Table).values() gives TypeScript error "Object literal may only specify known properties"
Before I begin, let me clarify I am suuuper new to Drizzle! Loving it so far! Not sure if I should provide repro just yet (happy to later), but I am getting an issue where my table which currently is:
export const PostsTable = pgTable("posts", {
id,
...timestamps,
title: varchar("title", { length: 255 }).notNull(),
description: varchar("description", { length: 5_000 }).notNull(),
authorId: uuid("authorId")
.references(() => UsersTable.id)
.notNull()
});
export const PostsTable = pgTable("posts", {
id,
...timestamps,
title: varchar("title", { length: 255 }).notNull(),
description: varchar("description", { length: 5_000 }).notNull(),
authorId: uuid("authorId")
.references(() => UsersTable.id)
.notNull()
});
Is giving me this a long typescript error for the values method that basically boils down to this: Object literal may only specify known properties, and authorId does not exist in type ... When I run:
await db.insert(PostsTable).values({
authorId: req.user.userId,
description: formData.description,
fileId: dbFile!.fileId,
title: formData.title
});
await db.insert(PostsTable).values({
authorId: req.user.userId,
description: formData.description,
fileId: dbFile!.fileId,
title: formData.title
});
I feel like I am missing something basic, but I am scratching my head a bit! 😅 I have been able to successfully use the values method with no problems with very similar other tables. Thanks so much
2 replies
TtRPC
Created by Jack on 3/9/2024 in #❓-help
Type error when creating a server-side context 🤔
No description
17 replies