-- =====================================================
-- Comprehensive Tech Stacks Migration
-- Add more comprehensive stacks to cover $1-$1000 budget range
-- =====================================================

-- Add comprehensive stacks for Micro Budget ($5-$25/month)
INSERT INTO price_based_stacks (
    stack_name, price_tier_id, total_monthly_cost_usd, total_setup_cost_usd,
    frontend_tech, backend_tech, database_tech, cloud_tech, testing_tech, mobile_tech, devops_tech, ai_ml_tech,
    team_size_range, development_time_months, maintenance_complexity, scalability_ceiling,
    recommended_domains, success_rate_percentage, user_satisfaction_score, description, pros, cons
) VALUES

-- Ultra Micro Budget Stacks ($1-$5/month)
('Ultra Micro Static Stack', 1, 1.00, 50.00,
 'HTML/CSS', 'None', 'None', 'GitHub Pages', 'None', 'None', 'Git', 'None',
 '1', 1, 'Very Low', 'Static Only',
 ARRAY['Personal websites', 'Portfolio', 'Documentation', 'Simple landing pages'],
 95, 90, 'Ultra-minimal static site with zero backend costs',
 ARRAY['Completely free hosting', 'Zero maintenance', 'Perfect for portfolios', 'Instant deployment'],
 ARRAY['No dynamic features', 'No database', 'No user accounts', 'Limited functionality']),

('Micro Blog Stack', 1, 3.00, 100.00,
 'Jekyll', 'None', 'None', 'Netlify', 'None', 'None', 'Git', 'None',
 '1-2', 1, 'Very Low', 'Static Only',
 ARRAY['Blogs', 'Documentation sites', 'Personal websites', 'Content sites'],
 90, 85, 'Static blog with content management',
 ARRAY['Free hosting', 'Easy content updates', 'SEO friendly', 'Fast loading'],
 ARRAY['No dynamic features', 'No user comments', 'Limited interactivity', 'Static only']),

('Micro API Stack', 1, 5.00, 150.00,
 'None', 'Node.js', 'SQLite', 'Railway', 'None', 'None', 'Git', 'None',
 '1-2', 2, 'Low', 'Small Scale',
 ARRAY['API development', 'Microservices', 'Backend services', 'Data processing'],
 85, 80, 'Simple API backend with database',
 ARRAY['Low cost', 'Easy deployment', 'Good for learning', 'Simple setup'],
 ARRAY['Limited scalability', 'Basic features', 'No frontend', 'Single database']),

-- Micro Budget Stacks ($5-$25/month)
('Micro Full Stack', 1, 8.00, 200.00,
 'React', 'Express.js', 'SQLite', 'Vercel', 'Jest', 'None', 'GitHub Actions', 'None',
 '1-3', 2, 'Low', 'Small Scale',
 ARRAY['Small web apps', 'Personal projects', 'Learning projects', 'Simple business sites'],
 88, 85, 'Complete full-stack solution for small projects',
 ARRAY['Full-stack capabilities', 'Modern tech stack', 'Easy deployment', 'Good for learning'],
 ARRAY['Limited scalability', 'Basic features', 'No mobile app', 'Single database']),

('Micro E-commerce Stack', 1, 12.00, 300.00,
 'Vue.js', 'Node.js', 'PostgreSQL', 'DigitalOcean', 'Jest', 'None', 'Docker', 'None',
 '2-4', 3, 'Medium', 'Small Scale',
 ARRAY['Small e-commerce', 'Online stores', 'Product catalogs', 'Simple marketplaces'],
 85, 82, 'E-commerce solution for small businesses',
 ARRAY['E-commerce ready', 'Payment integration', 'Product management', 'Order processing'],
 ARRAY['Limited features', 'Basic payment options', 'Manual scaling', 'Limited analytics']),

('Micro SaaS Stack', 1, 15.00, 400.00,
 'React', 'Django', 'PostgreSQL', 'Railway', 'Cypress', 'None', 'GitHub Actions', 'None',
 '2-4', 3, 'Medium', 'Small Scale',
 ARRAY['SaaS applications', 'Web apps', 'Business tools', 'Data management'],
 87, 84, 'SaaS platform for small businesses',
 ARRAY['User management', 'Subscription billing', 'API ready', 'Scalable foundation'],
 ARRAY['Limited AI features', 'Basic analytics', 'Manual scaling', 'Limited integrations']),

('Micro Mobile Stack', 1, 18.00, 500.00,
 'React', 'Express.js', 'MongoDB', 'Vercel', 'Jest', 'React Native', 'GitHub Actions', 'None',
 '2-5', 4, 'Medium', 'Small Scale',
 ARRAY['Mobile apps', 'Cross-platform apps', 'Startup MVPs', 'Simple business apps'],
 86, 83, 'Cross-platform mobile app solution',
 ARRAY['Mobile app included', 'Cross-platform', 'Modern stack', 'Easy deployment'],
 ARRAY['Limited native features', 'Basic performance', 'Manual scaling', 'Limited offline support']),

('Micro AI Stack', 1, 20.00, 600.00,
 'React', 'FastAPI', 'PostgreSQL', 'Railway', 'Jest', 'None', 'Docker', 'Hugging Face',
 '2-5', 4, 'Medium', 'Small Scale',
 ARRAY['AI applications', 'Machine learning', 'Data analysis', 'Intelligent apps'],
 84, 81, 'AI-powered application stack',
 ARRAY['AI capabilities', 'ML integration', 'Data processing', 'Modern APIs'],
 ARRAY['Limited AI models', 'Basic ML features', 'Manual scaling', 'Limited training capabilities']),

-- Startup Budget Stacks ($25-$100/month) - Enhanced versions
('Startup E-commerce Pro', 2, 35.00, 800.00,
 'Next.js', 'Express.js', 'PostgreSQL', 'DigitalOcean', 'Cypress', 'Ionic', 'Docker', 'None',
 '3-6', 4, 'Medium', 'Medium Scale',
 ARRAY['E-commerce', 'Online stores', 'Marketplaces', 'Retail platforms'],
 89, 87, 'Professional e-commerce solution with mobile app',
 ARRAY['Full e-commerce features', 'Mobile app included', 'Payment processing', 'Inventory management'],
 ARRAY['Higher cost', 'Complex setup', 'Requires expertise', 'Limited AI features']),

('Startup SaaS Pro', 2, 45.00, 1000.00,
 'React', 'Django', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Terraform', 'Scikit-learn',
 '3-6', 5, 'Medium', 'Medium Scale',
 ARRAY['SaaS platforms', 'Web applications', 'Business tools', 'Data-driven apps'],
 88, 86, 'Professional SaaS platform with AI features',
 ARRAY['Full SaaS features', 'AI integration', 'Mobile app', 'Scalable architecture'],
 ARRAY['Complex setup', 'Higher costs', 'Requires expertise', 'AWS complexity']),

('Startup AI Platform', 2, 55.00, 1200.00,
 'Next.js', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Docker', 'Hugging Face',
 '4-8', 6, 'High', 'Medium Scale',
 ARRAY['AI platforms', 'Machine learning', 'Data analytics', 'Intelligent applications'],
 87, 85, 'AI-powered platform with advanced ML capabilities',
 ARRAY['Advanced AI features', 'ML model deployment', 'Data processing', 'Scalable AI'],
 ARRAY['High complexity', 'Expensive setup', 'Requires AI expertise', 'AWS costs']),

-- Small Business Stacks ($100-$300/month)
('Small Business E-commerce', 3, 120.00, 2000.00,
 'Angular', 'Django', 'PostgreSQL', 'AWS', 'Playwright', 'Flutter', 'Jenkins', 'Scikit-learn',
 '5-10', 6, 'High', 'Large Scale',
 ARRAY['E-commerce', 'Online stores', 'Marketplaces', 'Enterprise retail'],
 91, 89, 'Enterprise-grade e-commerce solution',
 ARRAY['Enterprise features', 'Advanced analytics', 'Multi-channel', 'High performance'],
 ARRAY['High cost', 'Complex setup', 'Requires large team', 'Long development time']),

('Small Business SaaS', 3, 150.00, 2500.00,
 'React', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Terraform', 'Hugging Face',
 '5-12', 7, 'High', 'Large Scale',
 ARRAY['SaaS platforms', 'Enterprise applications', 'Business automation', 'Data platforms'],
 90, 88, 'Enterprise SaaS platform with AI capabilities',
 ARRAY['Enterprise features', 'AI integration', 'Advanced analytics', 'High scalability'],
 ARRAY['Very high cost', 'Complex architecture', 'Requires expert team', 'Long development']),

-- Growth Stage Stacks ($300-$600/month)
('Growth E-commerce Platform', 4, 350.00, 5000.00,
 'Angular', 'Django', 'PostgreSQL', 'AWS', 'Playwright', 'Flutter', 'Kubernetes', 'TensorFlow',
 '8-15', 8, 'Very High', 'Enterprise Scale',
 ARRAY['E-commerce', 'Marketplaces', 'Enterprise retail', 'Multi-tenant platforms'],
 93, 91, 'Enterprise e-commerce platform with AI and ML',
 ARRAY['Enterprise features', 'AI/ML integration', 'Multi-tenant', 'Global scalability'],
 ARRAY['Very expensive', 'Complex architecture', 'Requires large expert team', 'Long development']),

('Growth AI Platform', 4, 450.00, 6000.00,
 'React', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Kubernetes', 'TensorFlow',
 '10-20', 9, 'Very High', 'Enterprise Scale',
 ARRAY['AI platforms', 'Machine learning', 'Data analytics', 'Intelligent applications'],
 92, 90, 'Enterprise AI platform with advanced ML capabilities',
 ARRAY['Advanced AI/ML', 'Enterprise features', 'High scalability', 'Global deployment'],
 ARRAY['Extremely expensive', 'Very complex', 'Requires AI experts', 'Long development']),

-- Scale-Up Stacks ($600-$1000/month)
('Scale-Up E-commerce Enterprise', 5, 750.00, 10000.00,
 'Angular', 'Django', 'PostgreSQL', 'AWS', 'Playwright', 'Flutter', 'Kubernetes', 'TensorFlow',
 '15-30', 10, 'Extremely High', 'Global Scale',
 ARRAY['E-commerce', 'Global marketplaces', 'Enterprise retail', 'Multi-tenant platforms'],
 95, 93, 'Global enterprise e-commerce platform with AI/ML',
 ARRAY['Global features', 'Advanced AI/ML', 'Multi-tenant', 'Enterprise security'],
 ARRAY['Extremely expensive', 'Very complex', 'Requires large expert team', 'Very long development']),

('Scale-Up AI Enterprise', 5, 900.00, 12000.00,
 'React', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Kubernetes', 'TensorFlow',
 '20-40', 12, 'Extremely High', 'Global Scale',
 ARRAY['AI platforms', 'Machine learning', 'Data analytics', 'Global AI applications'],
 94, 92, 'Global enterprise AI platform with advanced capabilities',
 ARRAY['Global AI/ML', 'Enterprise features', 'Maximum scalability', 'Global deployment'],
 ARRAY['Extremely expensive', 'Extremely complex', 'Requires AI experts', 'Very long development']);

-- =====================================================
-- VERIFICATION QUERIES
-- =====================================================

-- Check the new distribution
SELECT 
    pt.tier_name,
    COUNT(pbs.id) as stack_count,
    MIN(pbs.total_monthly_cost_usd) as min_monthly,
    MAX(pbs.total_monthly_cost_usd) as max_monthly,
    MIN(pbs.total_monthly_cost_usd * 12 + pbs.total_setup_cost_usd) as min_first_year,
    MAX(pbs.total_monthly_cost_usd * 12 + pbs.total_setup_cost_usd) as max_first_year
FROM price_based_stacks pbs
JOIN price_tiers pt ON pbs.price_tier_id = pt.id
GROUP BY pt.id, pt.tier_name
ORDER BY pt.min_price_usd;

-- Check stacks that fit in different budget ranges
SELECT 
    'Budget $100' as budget_range,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 100

UNION ALL

SELECT 
    'Budget $500' as budget_range,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 500

UNION ALL

SELECT 
    'Budget $1000' as budget_range,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 1000;

-- =====================================================
-- MIGRATION COMPLETED
-- =====================================================

-- Display completion message
DO $$
BEGIN
    RAISE NOTICE 'Comprehensive stacks migration completed successfully!';
    RAISE NOTICE 'Added comprehensive tech stacks covering $1-$1000 budget range';
    RAISE NOTICE 'All stacks now have complete technology specifications';
    RAISE NOTICE 'Ready for seamless tech stack selection across all budget ranges';
END $$;
