import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";

export const waitlistSignups = sqliteTable("waitlist_signups", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  email: text("email").notNull().unique(),
  name: text("name"),
  source: text("source").notNull().default("organic"),
  status: text("status").notNull().default("waitlist"),
  metadata: text("metadata"),
  createdAt: integer("created_at", { mode: "timestamp" }).notNull().default(new Date()),
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull().default(new Date()),
});

export const waitlistEvents = sqliteTable("waitlist_events", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  signupId: integer("signup_id").notNull().references(() => waitlistSignups.id),
  eventType: text("event_type").notNull(),
  eventData: text("event_data"),
  createdAt: integer("created_at", { mode: "timestamp" }).notNull().default(new Date()),
});

export type WaitlistSignup = typeof waitlistSignups.$inferSelect;
export type NewWaitlistSignup = typeof waitlistSignups.$inferInsert;
export type WaitlistEvent = typeof waitlistEvents.$inferSelect;
export type NewWaitlistEvent = typeof waitlistEvents.$inferInsert;
