916ad39176
Deploy to route.crispygoat.com / deploy (push) Failing after 3m1s
- 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
72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
/**
|
|
* Marketing: email templates + campaigns.
|
|
* Source of truth: `db/migrations/0001_init.sql`.
|
|
*/
|
|
import {
|
|
pgTable,
|
|
uuid,
|
|
text,
|
|
integer,
|
|
timestamp,
|
|
index,
|
|
} from "drizzle-orm/pg-core";
|
|
import { campaignStatusEnum } from "./enums";
|
|
import { brands } from "./brands";
|
|
|
|
export const emailTemplates = pgTable(
|
|
"email_templates",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
brandId: uuid("brand_id")
|
|
.notNull()
|
|
.references(() => brands.id, { onDelete: "cascade" }),
|
|
name: text("name").notNull(),
|
|
subject: text("subject").notNull(),
|
|
bodyHtml: text("body_html").notNull(),
|
|
createdAt: timestamp("created_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
},
|
|
(t) => ({
|
|
brandIdx: index("email_templates_brand_idx").on(t.brandId),
|
|
}),
|
|
);
|
|
|
|
export const campaigns = pgTable(
|
|
"campaigns",
|
|
{
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
brandId: uuid("brand_id")
|
|
.notNull()
|
|
.references(() => brands.id, { onDelete: "cascade" }),
|
|
templateId: uuid("template_id").references((): any => emailTemplates.id, {
|
|
onDelete: "set null",
|
|
}),
|
|
name: text("name").notNull(),
|
|
status: text("status", { enum: campaignStatusEnum })
|
|
.notNull()
|
|
.default("draft"),
|
|
scheduledFor: timestamp("scheduled_for", { withTimezone: true }),
|
|
sentAt: timestamp("sent_at", { withTimezone: true }),
|
|
recipientCount: integer("recipient_count").notNull().default(0),
|
|
createdAt: timestamp("created_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
},
|
|
(t) => ({
|
|
brandIdx: index("campaigns_brand_idx").on(t.brandId),
|
|
statusIdx: index("campaigns_status_idx").on(t.brandId, t.status),
|
|
}),
|
|
);
|
|
|
|
export type EmailTemplate = typeof emailTemplates.$inferSelect;
|
|
export type NewEmailTemplate = typeof emailTemplates.$inferInsert;
|
|
export type Campaign = typeof campaigns.$inferSelect;
|
|
export type NewCampaign = typeof campaigns.$inferInsert;
|