import { pgPrefixIdKey } from "@/utils/drizzle"
import { relations } from "drizzle-orm"
import { pgTable, text, varchar } from "drizzle-orm/pg-core"
export const option = pgTable("option", {
id: pgPrefixIdKey({ prefix: "option" }).primaryKey(),
name: varchar("name", { length: 64 }).notNull(),
})
export const optionRelations = relations(option, ({ many }) => ({
values: many(optionValue),
}))
export const optionValue = pgTable("option_value", {
id: pgPrefixIdKey({ prefix: "option_value" }).primaryKey(),
value: varchar("value", { length: 64 }).notNull(),
optionId: text("option_id")
.notNull()
.references(() => option.id),
})
export const optionValueRelations = relations(optionValue, ({ one }) => ({
option: one(option, {
fields: [optionValue.optionId],
references: [option.id],
}),
}))
import { pgPrefixIdKey } from "@/utils/drizzle"
import { relations } from "drizzle-orm"
import { pgTable, text, varchar } from "drizzle-orm/pg-core"
export const option = pgTable("option", {
id: pgPrefixIdKey({ prefix: "option" }).primaryKey(),
name: varchar("name", { length: 64 }).notNull(),
})
export const optionRelations = relations(option, ({ many }) => ({
values: many(optionValue),
}))
export const optionValue = pgTable("option_value", {
id: pgPrefixIdKey({ prefix: "option_value" }).primaryKey(),
value: varchar("value", { length: 64 }).notNull(),
optionId: text("option_id")
.notNull()
.references(() => option.id),
})
export const optionValueRelations = relations(optionValue, ({ one }) => ({
option: one(option, {
fields: [optionValue.optionId],
references: [option.id],
}),
}))