From b3cd4c9bbfabfa1b7a7e40cae7bb5a9b12ddd76c Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 1 Oct 2025 00:01:07 +0000 Subject: [PATCH] Create local fallback in createInitialProfile when table missing cgen-236b45a21038444cb9b9ea24baedb328 --- client/lib/aethex-database-adapter.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/client/lib/aethex-database-adapter.ts b/client/lib/aethex-database-adapter.ts index a12595a0..0aeeb4e1 100644 --- a/client/lib/aethex-database-adapter.ts +++ b/client/lib/aethex-database-adapter.ts @@ -297,9 +297,24 @@ export const aethexUserService = { if (error) { if (isTableMissing(error)) { - throw new Error( - 'Supabase table "user_profiles" is missing. Please run the required migrations.', - ); + // Fallback to local profile storage when DB is not migrated + console.warn('user_profiles table missing during createInitialProfile - using local fallback'); + const fallback: AethexUserProfile = { + id: userId, + username: profileData.username || `user_${Date.now()}`, + full_name: profileData.full_name || profileData.username || `user_${Date.now()}`, + user_type: (profileData as any).user_type || "community_member", + experience_level: (profileData as any).experience_level || "beginner", + level: 1, + total_xp: 0, + loyalty_points: 0, + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + } as AethexUserProfile; + try { + localStorage.setItem(`demo_profile_${userId}`, JSON.stringify(fallback)); + } catch {} + return fallback; } throw error; }