Spaces:
Running
Running
| -- Create plans table | |
| CREATE TABLE IF NOT EXISTS public.plans ( | |
| id UUID DEFAULT gen_random_uuid() PRIMARY KEY, | |
| name TEXT NOT NULL, | |
| price TEXT NOT NULL, | |
| description TEXT, | |
| features TEXT[] DEFAULT '{}', | |
| cta TEXT DEFAULT 'Get Started', | |
| href TEXT DEFAULT '/auth/signin', | |
| popular BOOLEAN DEFAULT false, | |
| created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL | |
| ); | |
| -- Enable RLS | |
| ALTER TABLE public.plans ENABLE ROW LEVEL SECURITY; | |
| -- Allow public read access to plans | |
| CREATE POLICY "Allow public read access" ON public.plans FOR SELECT USING (true); | |
| -- Seed data | |
| INSERT INTO public.plans (name, price, description, features, cta, href, popular) VALUES | |
| ('Free', '$0', 'Perfect for experimenting and personal projects.', ARRAY['5 video credits per month', '720p video quality', 'Standard generation speed', 'Public community access'], 'Get Started', '/app', false), | |
| ('Pro', '$29', 'For content creators and professionals.', ARRAY['50 video credits per month', '1080p HD video quality', 'Fast generation speed', 'Priority support', 'Commercial usage rights', 'Remove watermarks'], 'Upgrade to Pro', '/auth/signin', true), | |
| ('Enterprise', 'Custom', 'For teams and high-volume needs.', ARRAY['Unlimited video credits', '4K video quality', 'Instant generation', 'Dedicated account manager', 'Custom branding & templates', 'API access'], 'Contact Sales', 'mailto:sales@vidsimplify.com', false); | |
| -- Add plan_id to users table if it doesn't exist | |
| ALTER TABLE public.users ADD COLUMN IF NOT EXISTS plan_id UUID REFERENCES public.plans(id); | |
| -- Update existing users to have the Free plan (assuming 'Free' is the first one inserted or we pick it dynamically) | |
| -- This is a bit tricky in SQL without a function, but for now we can leave it nullable or set a default in the app logic. | |