rogueturnip
rogueturnip
Explore posts from servers
DTDrizzle Team
Created by rogueturnip on 11/14/2024 in #help
sqlitetable circular reference
I'm trying to create a self referencing table using sqlite, here is what I'm doing
export const forms = sqliteTable("forms", {
id: int("id").primaryKey(),
name: text("name").notNull(),
description: text("description"),
categoryId: int("category_id").references(() => categories.id),
slug: text("slug").notNull(),
version: text("version").notNull().default("1.0"),
active: integer("active", { mode: "boolean" }).notNull().default(true),
parentFormId: int("parent_form_id").references(() => forms.id),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
});
export const forms = sqliteTable("forms", {
id: int("id").primaryKey(),
name: text("name").notNull(),
description: text("description"),
categoryId: int("category_id").references(() => categories.id),
slug: text("slug").notNull(),
version: text("version").notNull().default("1.0"),
active: integer("active", { mode: "boolean" }).notNull().default(true),
parentFormId: int("parent_form_id").references(() => forms.id),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
});
but I'm getting this type error Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.ts(7024) Is there any way to structure this to to remove the TS warning?
2 replies
DTDrizzle Team
Created by rogueturnip on 10/11/2023 in #help
branches with neon
I was wondering if anyone is using Neon with drizzle in a production setup. I've got things setup nicely for development using a branch called "dev". What I'm wondering is what is the procedure now that I want to start getting my "main" branch ready. How do I do my migration into this branch given I have a number of migration files that have come along with my development process. I've been looking for some good documentation of going from development to production but I haven't found anything.
I am using Next 13 and deploy to vercel. Thanks!
1 replies
DTDrizzle Team
Created by rogueturnip on 10/3/2023 in #help
one-to-many
I might be asking something simple or have to change my model but I thought I'd ask cause I've been stuck for a while. I have an images table
export const images = pgTable('images', {
id: text('id')
.$defaultFn(() => `image_${nanoid()}`)
.primaryKey(),
label: text('label'),
url: text('url'),
resourceId: text('resource_id'),
resourceType: text('resource_type'),
createdAt: timestamp('created_at').defaultNow().notNull(),
});
export const images = pgTable('images', {
id: text('id')
.$defaultFn(() => `image_${nanoid()}`)
.primaryKey(),
label: text('label'),
url: text('url'),
resourceId: text('resource_id'),
resourceType: text('resource_type'),
createdAt: timestamp('created_at').defaultNow().notNull(),
});
you can see I have a resourceId and a resourceType because I have different things that can have relations to images. I know I could create a table inbetween but I thought I'd try there, where I'm stuck is on setting up the relation. All the documentation shows
many(images)
many(images)
But when I run it I get an error on the resource I'm doing the with as "There is not enough information to infer the relation" Any suggestions?
6 replies