export const PriceTable = pgTable(
"price",
{
id: text("id").primaryKey(),
productId: text("product_id")
.notNull()
.references(() => ProductTable.id),
active: boolean("active").notNull(),
currency: text("currency").notNull(),
unitAmount: integer("unit_amount"),
createdAt: timestamp("created_at").defaultNow()
},
(t) => ({
productIdIdx: index("idx_price_productId").on(t.productId),
idIdx: index("idx_price_id").on(t.id)
})
);
export const priceRelations = relations(PriceTable, ({ one }) => ({
product: one(ProductTable, {
fields: [PriceTable.productId],
references: [ProductTable.id]
})
}));
export const PriceTable = pgTable(
"price",
{
id: text("id").primaryKey(),
productId: text("product_id")
.notNull()
.references(() => ProductTable.id),
active: boolean("active").notNull(),
currency: text("currency").notNull(),
unitAmount: integer("unit_amount"),
createdAt: timestamp("created_at").defaultNow()
},
(t) => ({
productIdIdx: index("idx_price_productId").on(t.productId),
idIdx: index("idx_price_id").on(t.id)
})
);
export const priceRelations = relations(PriceTable, ({ one }) => ({
product: one(ProductTable, {
fields: [PriceTable.productId],
references: [ProductTable.id]
})
}));