Skip to main content
Date: 2026-01-20
Purpose: Understanding and managing users in the database, including test users and Lovable integration

Current User Status

User Statistics

Total Users: 1,223
Test Users: 1,191 (97% of all users)
Recent Users: All 1,223 created in last 7 days

User Breakdown by Type


User Sources

1. E2E Test Users

Pattern: e2e-{test-name}-{timestamp}@test.com Examples:
  • e2e-auth-<timestamp>@test.com
  • e2e-financial-<timestamp>@test.com
  • e2e-leave-<timestamp>@test.com
Source: Automated end-to-end test suites
Location: tests/e2e/ directory
Purpose: Testing complete user flows
Cleanup: These are created during test runs and can be safely cleaned up if not needed.

2. RLS Test Users

Pattern: rls-{scenario}-{test-number}-{timestamp}@example.com Examples:
  • rls-scenario-testN-<timestamp>@example.com
  • rls-close-testN-<timestamp>@example.com
Source: RLS (Row-Level Security) test scenarios
Location: tests/rls/ directory
Purpose: Testing multi-tenant data isolation
Cleanup: These are created during RLS test runs and can be safely cleaned up.

3. Debug/Test Users

Pattern: {role}-{purpose}-{timestamp}@test.com Examples:
  • admin-debug-<timestamp>@test.com
  • regular-debug-<timestamp>@test.com
  • test-user-a-fw-logs-<timestamp>@test.com
Source: Manual testing and debugging
Purpose: Development and troubleshooting
Cleanup: These can be cleaned up if no longer needed for debugging.

4. Seed Data Users

Pattern: {role}@test-org-{name}.example or test.{name}.{num}@org{num}.staging.encoreos.io Examples:
  • admin@test-org-alpha.example
  • manager@test-org-beta.example
  • test.admin.N@orgN.staging.encoreos.io
Source: Seed files in supabase/seeds/
Location: supabase/seeds/base/02_users.sql
Purpose: Staging environment test data
Cleanup: These should remain in staging but should NOT be in production.

5. Lovable Integration

Status: Lovable is connected to the project What Lovable Does:
  • Auto-generates src/integrations/supabase/client.ts
  • Auto-generates src/integrations/supabase/types.ts
  • Manages .env file (when configured)
  • Deploys edge functions automatically
  • Does NOT create users directly
Lovable Users:
  • Lovable does NOT create test users in the database
  • Any users you see are from:
    • Automated test suites (E2E, RLS)
    • Manual testing/debugging
    • Seed data (staging only)
    • Real user signups
Lovable Deployment:
  • Lovable may deploy to .lovable.app domains
  • If you use Lovable deployment URLs, add them to Supabase redirect URLs
  • See docs/development/SUPABASE_VERCEL_SETUP_FIX.md for configuration

User Cleanup Options

⚠️ WARNING: Only run this in production if you’re sure you want to remove test users. ✅ RECOMMENDED: Use the automated cleanup script:
Manual SQL Alternative (if script unavailable):
Before Running:
  1. ✅ Verify you’re in the correct environment (production vs staging)
  2. ✅ Run the SELECT query first to see what will be deleted
  3. ✅ Consider backing up first
  4. ✅ Check if any test users have important data
See: docs/development/TEST_USER_CLEANUP_GUIDE.md for complete cleanup guide.

Option 2: Archive Test Users (Safer)

⚠️ IMPORTANT: You cannot directly modify the auth.users table schema as it’s managed by Supabase. Use one of these safe alternatives:

Alternative A: Use raw_user_meta_data JSONB

Mark users as archived using their existing metadata field:
Create a separate table to track archived user status:

Option 3: Clean Up by Date

Remove users created during a specific time period (e.g., test run):

Preventing Test User Accumulation

1. Use Test Isolation

For E2E Tests:
  • Use unique test user emails with timestamps
  • Clean up test users after test runs
  • Use test database or staging environment
For RLS Tests:
  • Use deterministic test user IDs
  • Clean up after test suite completes
  • Consider using test fixtures that clean up automatically

2. Environment Separation

Production:
  • ✅ No test users should exist
  • ✅ Only real user signups
  • ✅ Regular cleanup of any accidental test users
Staging:
  • ✅ Test users are expected
  • ✅ Seed data users are normal
  • ✅ Can have test users for UAT

3. Automated Cleanup

Consider adding cleanup scripts:

Lovable Integration Notes

Lovable Connection

What Lovable Manages:
  • ✅ Supabase client configuration
  • ✅ TypeScript types generation
  • ✅ Environment variables (when configured)
  • ✅ Edge function deployment
  • Does NOT create users

Lovable Deployment URLs

If you deploy via Lovable to .lovable.app domains:
  1. Add to Supabase Redirect URLs:
  2. Sync Config:

Verification Queries

Check User Distribution

Check Recent User Creation

Find Test Users


Recommendations

For Production

  1. Immediate: Review and clean up test users if they shouldn’t be there
  2. Ongoing: Set up automated cleanup for test users
  3. Monitoring: Add alerts for unexpected user creation spikes
  4. Documentation: Document which users are legitimate

For Staging

  1. Expected: Test users are normal in staging
  2. Seed Data: Keep seed data users for UAT
  3. Cleanup: Periodically clean up old test users (30+ days old)

For Development

  1. Local: Use local Supabase instance for testing
  2. Isolation: Use separate test databases when possible
  3. Cleanup: Clean up test users after development sessions

  • Test User Cleanup Guide: docs/development/TEST_USER_CLEANUP_GUIDE.md - Complete cleanup procedures
  • Setup Fix Guide: docs/development/SUPABASE_VERCEL_SETUP_FIX.md
  • Testing Guide: docs/development/VERIFICATION_TESTING_GUIDE.md
  • Lovable Integration: AGENTS.md
  • Environment Config: ENVIRONMENT_CONFIG.md