Plantillas:
customers4 cols
id
uuidemail
varcharfull_name
varcharcreated_at
timestampproducts5 cols
id
uuidsku
varchartitle
varcharprice
decimalstock
intorders5 cols
id
uuidcustomer_id
uuidstatus
varchartotal
decimalcreated_at
timestamporder_items5 cols
id
serialorder_id
uuidproduct_id
uuidquantity
intunit_price
decimalArrastra las tablas para organizar el diagrama · Haz clic en una tabla para editar sus columnas
// Generated by SchemaCost — Drizzle ORM (PostgreSQL)
import { pgTable, uuid, varchar, timestamp, numeric, integer, bigserial } from 'drizzle-orm/pg-core';
export const customers = pgTable('customers', {
id: uuid('id').primaryKey().defaultRandom(),
email: varchar('email', { length: 255 }).notNull().unique(),
fullName: varchar('full_name', { length: 255 }).notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
});
export const products = pgTable('products', {
id: uuid('id').primaryKey().defaultRandom(),
sku: varchar('sku', { length: 255 }).notNull().unique(),
title: varchar('title', { length: 255 }).notNull(),
price: numeric('price', { precision: 12, scale: 2 }).notNull(),
stock: integer('stock').notNull(),
});
export const orders = pgTable('orders', {
id: uuid('id').primaryKey().defaultRandom(),
customerId: uuid('customer_id').notNull().references(() => customers.id, { onDelete: 'restrict' }),
status: varchar('status', { length: 255 }).notNull(),
total: numeric('total', { precision: 12, scale: 2 }).notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
});
export const orderItems = pgTable('order_items', {
id: bigserial('id', { mode: 'number' }).primaryKey(),
orderId: uuid('order_id').notNull().references(() => orders.id, { onDelete: 'cascade' }),
productId: uuid('product_id').notNull().references(() => products.id, { onDelete: 'restrict' }),
quantity: integer('quantity').notNull(),
unitPrice: numeric('unit_price', { precision: 12, scale: 2 }).notNull(),
});