Files
ai-wave-02/apps/api/src/db/schema/orders.ts
T
2026-09-24 18:09:20 +09:00

24 lines
959 B
TypeScript

import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { addresses } from "./addresses";
import { products } from "./products";
import { users } from "./users";
export const orders = sqliteTable("orders", {
id: text("id").primaryKey(),
orderNumber: text("order_number").notNull().unique(),
customerId: text("customer_id").notNull().references(() => users.id),
shippingAddressId: text("shipping_address_id").notNull().references(() => addresses.id),
status: text("status").notNull(),
notes: text("notes"),
createdAt: text("created_at").notNull(),
updatedAt: text("updated_at").notNull()
});
export const orderItems = sqliteTable("order_items", {
id: text("id").primaryKey(),
orderId: text("order_id").notNull().references(() => orders.id),
productId: text("product_id").notNull().references(() => products.id),
quantity: integer("quantity").notNull(),
unitPriceCents: integer("unit_price_cents").notNull()
});