c434015829
Deploy to route.crispygoat.com / deploy (push) Failing after 17s
- Add MinIO/S3-compatible storage client (src/lib/storage.ts) with uploadObject, deleteObject, presigned URL helpers, and BUCKETS constant - Wire product images, brand logos, and water log photos to MinIO via the new storage client - Migrate forgot-password to Neon Auth (remove Supabase /auth/v1/recover call) - Migrate send-scheduled cron to direct Postgres + Resend (remove Supabase Edge Function proxy) - Add logoUrl to email types (OrderReceipt, Welcome, PasswordReset) and pass brand_settings.logo_url from all call sites - Update email templates to use dynamic logoUrl instead of hardcoded Supabase bucket URLs - Remove hardcoded Supabase URLs from TuxedoVideoHero, TuxedoAboutPage, TimeTrackingFieldClient; use brand_settings props + local public/ fallback - Download brand logos (3) and tuxedo-hero.mp4 (36MB) from Supabase bucket to public/ for local development - Add MinIO env vars to .env.example (endpoint, access key, secret, buckets) - Fix TimeTrackingFieldClient to destructure logoUrl and brandAccent props - Fix admin/users.ts logoUrl type (null → undefined for optional string) - Remove stale sb- cookie from wholesale-auth - Migrate tuxedo/about page to remove supabase import and use pool query for wholesale_settings lookup
86 lines
2.6 KiB
TypeScript
86 lines
2.6 KiB
TypeScript
/**
|
|
* Orders + order_items. Source: `db/migrations/0001_init.sql`.
|
|
*/
|
|
import {
|
|
pgTable,
|
|
uuid,
|
|
text,
|
|
integer,
|
|
timestamp,
|
|
index,
|
|
} from "drizzle-orm/pg-core";
|
|
import { brands } from "./brands";
|
|
import { customers } from "./customers";
|
|
import { stops } from "./stops";
|
|
import { products } from "./products";
|
|
|
|
export const orders = pgTable(
|
|
"orders",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
brandId: uuid("brand_id")
|
|
.notNull()
|
|
.references(() => brands.id, { onDelete: "cascade" }),
|
|
customerId: uuid("customer_id").references(() => customers.id, {
|
|
onDelete: "set null",
|
|
}),
|
|
stopId: uuid("stop_id").references(() => stops.id, {
|
|
onDelete: "set null",
|
|
}),
|
|
totalCents: integer("total_cents").notNull().default(0),
|
|
status: text("status", {
|
|
enum: ["pending", "confirmed", "fulfilled", "canceled"],
|
|
}).notNull().default("pending"),
|
|
fulfillment: text("fulfillment", {
|
|
enum: ["pickup", "ship", "mixed"],
|
|
}).notNull(),
|
|
customerAddress: text("customer_address"),
|
|
customerCity: text("customer_city"),
|
|
customerState: text("customer_state"),
|
|
customerZip: text("customer_zip"),
|
|
idempotencyKey: text("idempotency_key"),
|
|
notes: text("notes"),
|
|
placedAt: timestamp("placed_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
},
|
|
(t) => ({
|
|
brandIdx: index("orders_brand_idx").on(t.brandId),
|
|
statusIdx: index("orders_status_idx").on(t.brandId, t.status),
|
|
stopIdx: index("orders_stop_idx").on(t.stopId),
|
|
customerIdx: index("orders_customer_idx").on(t.customerId),
|
|
}),
|
|
);
|
|
|
|
export const orderItems = pgTable(
|
|
"order_items",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
orderId: uuid("order_id")
|
|
.notNull()
|
|
.references(() => orders.id, { onDelete: "cascade" }),
|
|
productId: uuid("product_id").references(() => products.id, {
|
|
onDelete: "set null",
|
|
}),
|
|
quantity: integer("quantity").notNull(),
|
|
priceCents: integer("price_cents").notNull(),
|
|
fulfillment: text("fulfillment", {
|
|
enum: ["pickup", "ship"],
|
|
}).notNull(),
|
|
createdAt: timestamp("created_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
},
|
|
(t) => ({
|
|
orderIdx: index("order_items_order_idx").on(t.orderId),
|
|
}),
|
|
);
|
|
|
|
export type Order = typeof orders.$inferSelect;
|
|
export type NewOrder = typeof orders.$inferInsert;
|
|
export type OrderItem = typeof orderItems.$inferSelect;
|
|
export type NewOrderItem = typeof orderItems.$inferInsert;
|