Core Concepts
July 19, 2025

Setup and Configuration

Learn how to setup and configure your NuxtFast application

Author

Lorenzo

Author

Database Setup

Create a new Supabase project

First of all, you need to create a new Supabase project.

Once created, you need to add the following environment variables to the .env file:

SUPABASE_URL=https://your-project-id.supabase.co
SUPABASE_ANON_KEY=your-anon-key

Subscriptions Table

The subscriptions table manages user subscription data for Stripe integration. It has Row Level Security (RLS) enabled. Here we are going to keep track of the user's subscription data, like their stripe customer id, their subscription status, their plan, etc.

If you don't want to offer subscriptions just now, there is also the option of recording a lifetime subscription, which is a one-time payment for unlimited access to the app.

Table Creation SQL

To create the table, just copy the content of the setup_subscriptions_table.sql file and run it in the Supabase SQL Editor of your project.

Column Details

ColumnTypeDefaultNullableDescription
idbigintALWAYSNOPrimary key, auto-incrementing (GENERATED ALWAYS)
created_attimestamptznow()YESRecord creation timestamp
user_iduuid-YESForeign key to auth.users(id)
emailtext-YESUser email address (duplicated for admin convenience)
stripe_idtext-YESStripe customer/subscription ID
stripe_statustext-YESStripe subscription status
stripe_price_idtext-YESStripe price ID for the plan
trial_ends_attimestamptz-YESTrial period end date
ends_attimestamptz-YESSubscription end date
start_datetimestamptz-YESSubscription start date
last_event_datetimestamptz-YESLast Stripe webhook event date
plantext-YESPlan name/identifier
lifetime_purchasebooleanfalseNOWhether this is a lifetime purchase vs subscription

These policies ensure users can only read their own subscription data. This is very important as we don't want users to be able to modify their own subscription data.

Migration Notes

  1. Auth Schema: Ensure the auth.users table exists before creating the foreign key constraint
  2. Extensions: The table uses uuid type, ensure the uuid-ossp extension is enabled if needed
  3. RLS: The policies assume Supabase's auth.uid() function is available
  4. Performance: Multiple indexes optimize common query patterns (user_id, stripe_status, lifetime_purchase)
  5. Data Types: All timestamp columns use timestamp with time zone for proper timezone handling
  6. Security: Comprehensive CRUD policies restrict access to authenticated users and their own data only
  7. Email Field: The email field is intentionally duplicated for admin convenience - ensure it's populated when creating subscriptions