The waitlist/leads database schema was already implemented and migrated in 0002_chemical_shocker.sql. Created plan document at plans/FRE-645-waitlist-schema.md with schema documentation and usage examples. Co-Authored-By: Paperclip <noreply@paperclip.ing>
78 lines
1.9 KiB
Markdown
78 lines
1.9 KiB
Markdown
# FRE-645: Waitlist/Leads Database Schema
|
|
|
|
## Status: COMPLETE
|
|
|
|
The waitlist/leads database schema was already implemented and migrated in migration `0002_chemical_shocker.sql`.
|
|
|
|
## Current Schema
|
|
|
|
### waitlist_signups Table
|
|
|
|
Stores lead/waitlist signup records:
|
|
|
|
```typescript
|
|
- id: integer (PK, auto-increment)
|
|
- email: text (NOT NULL, UNIQUE)
|
|
- name: text (nullable)
|
|
- source: text (NOT NULL, default: "organic")
|
|
- status: text (NOT NULL, default: "waitlist")
|
|
- metadata: text (nullable, JSON)
|
|
- createdAt: timestamp
|
|
- updatedAt: timestamp
|
|
```
|
|
|
|
### waitlist_events Table
|
|
|
|
Tracks engagement events for each signup:
|
|
|
|
```typescript
|
|
- id: integer (PK, auto-increment)
|
|
- signupId: integer (FK → waitlist_signups.id)
|
|
- eventType: text (NOT NULL)
|
|
- eventData: text (nullable, JSON)
|
|
- createdAt: timestamp
|
|
```
|
|
|
|
## Schema Location
|
|
|
|
- Schema definition: `/src/db/schema/waitlist.ts`
|
|
- Exported in: `/src/db/schema/index.ts`
|
|
- Migration: `/src/db/migrations/0002_chemical_shocker.sql`
|
|
|
|
## Usage Examples
|
|
|
|
### Insert a new signup
|
|
|
|
```typescript
|
|
import { db } from "./config/migrations";
|
|
import { waitlistSignups } from "./schema";
|
|
|
|
await db.insert(waitlistSignups).values({
|
|
email: "user@example.com",
|
|
name: "John Doe",
|
|
source: "product-hunt",
|
|
status: "waitlist",
|
|
}).returning();
|
|
```
|
|
|
|
### Track an event
|
|
|
|
```typescript
|
|
import { waitlistEvents } from "./schema";
|
|
|
|
await db.insert(waitlistEvents).values({
|
|
signupId: 1,
|
|
eventType: "email_opened",
|
|
eventData: JSON.stringify({ campaign: "welcome" }),
|
|
});
|
|
```
|
|
|
|
## Next Steps
|
|
|
|
The schema is ready for use. No additional work needed unless new requirements emerge:
|
|
|
|
1. **API endpoints** - Create REST/tRPC endpoints for signup submission
|
|
2. **Admin dashboard** - Build UI for managing waitlist/leads
|
|
3. **Email integration** - Connect to email service provider for nurturing
|
|
4. **Analytics** - Track conversion metrics from waitlist to active users
|