Database Schema
Ready-to-deploy database model with table definitions, relationships, and indexes.
WaitlistSignUps
Stores waitlist registrations with built-in referral tracking and lifecycle management.
Field | Description |
---|---|
id | Unique identifier for each signup, auto-generated using CUID. |
email | User's email address, must be unique across all signups. |
referralCode | Unique code generated for this user to share with others. |
referredById | Optional ID linking to the user who referred this signup. |
referredBy | Relation to the user who made the referral. |
referrals | List of all users this person has referred. |
offboardedAt | Timestamp when user was removed from waitlist (e.g., got access). |
discardedAt | Timestamp when user was marked as invalid or removed. |
updatedAt | Timestamp of last record update, auto-set to current time. |
createdAt | Timestamp when user signed up, auto-set to current time. |
Key Design Decisions
- Uses a self-referential relation for tracking referrals, allowing multi-level referral tracking.
- Separates
offboardedAt
anddiscardedAt
to distinguish between successful conversions and removed entries. - Email uniqueness prevents duplicate signups.
- Includes database indexes on
referralCode
andemail
for faster lookups. - Uses cascade deletion, meaning if a referrer is deleted, all their referral connections are cleaned up.
- Uses CUID instead of UUID for IDs, which is better for database performance and URL-friendly.
- Keeps track of both creation and update times for audit purposes.
- Makes referral tracking optional by having
referredById
as nullable.
Apply Changes
Remember to apply these changes to your development database and regenerate Prisma client.
Or if you are not using migrations: