-- =====================================================
-- Comprehensive E-commerce Tech Stacks Migration
-- Add comprehensive e-commerce stacks for ALL budget ranges $1-$1000
-- =====================================================

-- Add comprehensive e-commerce 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 E-commerce Stacks ($1-$5/month)
('Ultra Micro E-commerce Stack', 1, 2.00, 80.00,
 'HTML/CSS + JavaScript', 'None', 'None', 'GitHub Pages', 'None', 'None', 'Git', 'None',
 '1', 1, 'Very Low', 'Static Only',
 ARRAY['E-commerce', 'Online stores', 'Product catalogs', 'Simple marketplaces'],
 85, 80, 'Ultra-minimal e-commerce with static site and external payment processing',
 ARRAY['Completely free hosting', 'Zero maintenance', 'Perfect for simple stores', 'Instant deployment'],
 ARRAY['No dynamic features', 'No database', 'Manual order processing', 'Limited functionality']),

('Micro E-commerce Blog Stack', 1, 4.00, 120.00,
 'Jekyll + Liquid', 'None', 'None', 'Netlify', 'None', 'None', 'Git', 'None',
 '1-2', 1, 'Very Low', 'Static Only',
 ARRAY['E-commerce', 'Online stores', 'Product catalogs', 'Content sites'],
 88, 82, 'Static e-commerce blog with product showcase and external payments',
 ARRAY['Free hosting', 'Easy content updates', 'SEO friendly', 'Fast loading'],
 ARRAY['No dynamic features', 'No user accounts', 'Manual order processing', 'Static only']),

('Micro E-commerce API Stack', 1, 6.00, 150.00,
 'None', 'Node.js', 'SQLite', 'Railway', 'None', 'None', 'Git', 'None',
 '1-2', 2, 'Low', 'Small Scale',
 ARRAY['E-commerce', 'API development', 'Backend services', 'Product management'],
 82, 78, 'Simple e-commerce 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 E-commerce Stacks ($5-$25/month)
('Micro E-commerce Full Stack', 1, 8.00, 200.00,
 'React', 'Express.js', 'SQLite', 'Vercel', 'Jest', 'None', 'GitHub Actions', 'None',
 '1-3', 2, 'Low', 'Small Scale',
 ARRAY['E-commerce', 'Online stores', 'Product catalogs', 'Simple marketplaces'],
 85, 82, 'Complete e-commerce solution for small stores',
 ARRAY['Full-stack capabilities', 'Modern tech stack', 'Easy deployment', 'Good for learning'],
 ARRAY['Limited scalability', 'Basic payment options', 'No mobile app', 'Single database']),

('Micro E-commerce Vue Stack', 1, 10.00, 250.00,
 'Vue.js', 'Node.js', 'PostgreSQL', 'DigitalOcean', 'Jest', 'None', 'Docker', 'None',
 '2-4', 3, 'Medium', 'Small Scale',
 ARRAY['E-commerce', 'Online stores', 'Product catalogs', 'Small marketplaces'],
 87, 84, 'Vue.js 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 E-commerce React Stack', 1, 12.00, 300.00,
 'React', 'Django', 'PostgreSQL', 'Railway', 'Cypress', 'None', 'GitHub Actions', 'None',
 '2-4', 3, 'Medium', 'Small Scale',
 ARRAY['E-commerce', 'Online stores', 'Product catalogs', 'Simple marketplaces'],
 88, 85, 'React e-commerce platform for small businesses',
 ARRAY['User management', 'Payment processing', 'API ready', 'Scalable foundation'],
 ARRAY['Limited AI features', 'Basic analytics', 'Manual scaling', 'Limited integrations']),

('Micro E-commerce Mobile Stack', 1, 15.00, 350.00,
 'React', 'Express.js', 'MongoDB', 'Vercel', 'Jest', 'React Native', 'GitHub Actions', 'None',
 '2-5', 4, 'Medium', 'Small Scale',
 ARRAY['E-commerce', 'Mobile apps', 'Cross-platform apps', 'Online stores'],
 86, 83, 'Cross-platform e-commerce 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 E-commerce AI Stack', 1, 18.00, 400.00,
 'React', 'FastAPI', 'PostgreSQL', 'Railway', 'Jest', 'None', 'Docker', 'Hugging Face',
 '2-5', 4, 'Medium', 'Small Scale',
 ARRAY['E-commerce', 'AI applications', 'Machine learning', 'Intelligent stores'],
 84, 81, 'AI-powered e-commerce 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 E-commerce Stacks ($25-$100/month) - Enhanced versions
('Startup E-commerce Pro', 2, 25.00, 600.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 E-commerce SaaS', 2, 35.00, 800.00,
 'React', 'Django', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Terraform', 'Scikit-learn',
 '3-6', 5, 'Medium', 'Medium Scale',
 ARRAY['E-commerce', 'SaaS platforms', 'Web applications', 'Business tools'],
 88, 86, 'Professional e-commerce 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 E-commerce AI', 2, 45.00, 1000.00,
 'Next.js', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Docker', 'Hugging Face',
 '4-8', 6, 'High', 'Medium Scale',
 ARRAY['E-commerce', 'AI platforms', 'Machine learning', 'Intelligent applications'],
 87, 85, 'AI-powered e-commerce 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 E-commerce 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 E-commerce SaaS', 3, 150.00, 2500.00,
 'React', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Terraform', 'Hugging Face',
 '5-12', 7, 'High', 'Large Scale',
 ARRAY['E-commerce', 'SaaS platforms', 'Enterprise applications', 'Business automation'],
 90, 88, 'Enterprise e-commerce 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 E-commerce 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 E-commerce AI', 4, 450.00, 6000.00,
 'React', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Kubernetes', 'TensorFlow',
 '10-20', 9, 'Very High', 'Enterprise Scale',
 ARRAY['E-commerce', 'AI platforms', 'Machine learning', 'Data analytics'],
 92, 90, 'Enterprise AI e-commerce 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 E-commerce 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 E-commerce AI Enterprise', 5, 900.00, 12000.00,
 'React', 'FastAPI', 'PostgreSQL', 'AWS', 'Cypress', 'React Native', 'Kubernetes', 'TensorFlow',
 '20-40', 12, 'Extremely High', 'Global Scale',
 ARRAY['E-commerce', 'AI platforms', 'Machine learning', 'Data analytics'],
 94, 92, 'Global enterprise AI e-commerce 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 e-commerce distribution
SELECT 
    'E-commerce Budget Range' as range_type,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE 'E-commerce' = ANY(recommended_domains) OR 'ecommerce' = ANY(recommended_domains) OR 'Online stores' = ANY(recommended_domains)
AND (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 50

UNION ALL

SELECT 
    'E-commerce Budget Range' as range_type,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE 'E-commerce' = ANY(recommended_domains) OR 'ecommerce' = ANY(recommended_domains) OR 'Online stores' = ANY(recommended_domains)
AND (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 100

UNION ALL

SELECT 
    'E-commerce Budget Range' as range_type,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE 'E-commerce' = ANY(recommended_domains) OR 'ecommerce' = ANY(recommended_domains) OR 'Online stores' = ANY(recommended_domains)
AND (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 200

UNION ALL

SELECT 
    'E-commerce Budget Range' as range_type,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE 'E-commerce' = ANY(recommended_domains) OR 'ecommerce' = ANY(recommended_domains) OR 'Online stores' = ANY(recommended_domains)
AND (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 500

UNION ALL

SELECT 
    'E-commerce Budget Range' as range_type,
    COUNT(*) as stacks_available
FROM price_based_stacks 
WHERE 'E-commerce' = ANY(recommended_domains) OR 'ecommerce' = ANY(recommended_domains) OR 'Online stores' = ANY(recommended_domains)
AND (total_monthly_cost_usd * 12 + total_setup_cost_usd) <= 1000;

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

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