Jack
Jack
Explore posts from servers
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