-- =====================================================
-- Tools Pricing Migration
-- Add pricing fields and data to tools table
-- =====================================================

-- Add pricing fields to tools table
ALTER TABLE tools ADD COLUMN IF NOT EXISTS price_tier_id INTEGER REFERENCES price_tiers(id);
ALTER TABLE tools ADD COLUMN IF NOT EXISTS monthly_cost_usd DECIMAL(10,2) DEFAULT 0;
ALTER TABLE tools ADD COLUMN IF NOT EXISTS setup_cost_usd DECIMAL(10,2) DEFAULT 0;
ALTER TABLE tools ADD COLUMN IF NOT EXISTS license_cost_usd DECIMAL(10,2) DEFAULT 0;
ALTER TABLE tools ADD COLUMN IF NOT EXISTS training_cost_usd DECIMAL(10,2) DEFAULT 0;
ALTER TABLE tools ADD COLUMN IF NOT EXISTS total_cost_of_ownership_score INTEGER CHECK (total_cost_of_ownership_score >= 1 AND total_cost_of_ownership_score <= 100);
ALTER TABLE tools ADD COLUMN IF NOT EXISTS price_performance_ratio INTEGER CHECK (price_performance_ratio >= 1 AND price_performance_ratio <= 100);

-- Create index for better performance
CREATE INDEX IF NOT EXISTS idx_tools_price_tier ON tools(price_tier_id);
CREATE INDEX IF NOT EXISTS idx_tools_monthly_cost ON tools(monthly_cost_usd);

-- =====================================================
-- UPDATE TOOLS WITH PRICING DATA
-- =====================================================

-- E-commerce Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 29.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 90
WHERE name = 'Shopify';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 100.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 95
WHERE name = 'WooCommerce';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Growth Stage'),
    monthly_cost_usd = 200.00,
    setup_cost_usd = 2000.00,
    license_cost_usd = 0.00,
    training_cost_usd = 500.00,
    total_cost_of_ownership_score = 75,
    price_performance_ratio = 80
WHERE name = 'Magento';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 39.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'BigCommerce';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 18.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Squarespace Commerce';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 300.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 92,
    price_performance_ratio = 90
WHERE name = 'PrestaShop';

-- CRM Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 50.00,
    total_cost_of_ownership_score = 98,
    price_performance_ratio = 95
WHERE name = 'HubSpot CRM';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Scale-Up'),
    monthly_cost_usd = 150.00,
    setup_cost_usd = 1000.00,
    license_cost_usd = 0.00,
    training_cost_usd = 800.00,
    total_cost_of_ownership_score = 80,
    price_performance_ratio = 75
WHERE name = 'Salesforce CRM';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 20.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Zoho CRM';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Pipedrive';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 29.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 82
WHERE name = 'Freshworks CRM';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 25.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 87,
    price_performance_ratio = 85
WHERE name = 'Monday.com CRM';

-- Analytics Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 50.00,
    total_cost_of_ownership_score = 98,
    price_performance_ratio = 95
WHERE name = 'Google Analytics';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 25.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Mixpanel';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 20.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Amplitude';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Hotjar';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Growth Stage'),
    monthly_cost_usd = 70.00,
    setup_cost_usd = 500.00,
    license_cost_usd = 0.00,
    training_cost_usd = 400.00,
    total_cost_of_ownership_score = 80,
    price_performance_ratio = 75
WHERE name = 'Tableau';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 10.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 92,
    price_performance_ratio = 90
WHERE name = 'Power BI';

-- Payment Processing Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 95
WHERE name = 'Stripe';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 50.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 90
WHERE name = 'PayPal';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Razorpay';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Square';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Growth Stage'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 300.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Adyen';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 87,
    price_performance_ratio = 82
WHERE name = 'Braintree';

-- Communication Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 8.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 92,
    price_performance_ratio = 90
WHERE name = 'Slack';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 6.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Microsoft Teams';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 50.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 95
WHERE name = 'Discord';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Zoom';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 25.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 95
WHERE name = 'Telegram';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 10.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'WhatsApp Business';

-- Project Management Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 6.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Trello';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 8.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Jira';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 11.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 87,
    price_performance_ratio = 85
WHERE name = 'Asana';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 10.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Monday.com';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 8.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Notion';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 82
WHERE name = 'Basecamp';

-- Marketing Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 95
WHERE name = 'Mailchimp';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 20.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Klaviyo';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 120.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 300.00,
    total_cost_of_ownership_score = 75,
    price_performance_ratio = 70
WHERE name = 'SEMrush';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 50.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 80,
    price_performance_ratio = 75
WHERE name = 'HubSpot Marketing';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 49.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Hootsuite';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 50.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 95
WHERE name = 'Canva';

-- Design & Content Creation Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 12.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Figma';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 53.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 400.00,
    total_cost_of_ownership_score = 80,
    price_performance_ratio = 75
WHERE name = 'Adobe Creative Suite';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 9.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Sketch';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 8.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 87,
    price_performance_ratio = 82
WHERE name = 'InVision';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 10.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Adobe XD';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 20.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Framer';

-- Development & DevOps Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 50.00,
    total_cost_of_ownership_score = 98,
    price_performance_ratio = 95
WHERE name = 'GitHub';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 90
WHERE name = 'GitLab';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Bitbucket';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 8.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Jira Software';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 6.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Confluence';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 92,
    price_performance_ratio = 90
WHERE name = 'Jenkins';

-- Customer Support Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 19.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Zendesk';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 39.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Intercom';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'Freshdesk';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 20.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Help Scout';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 16.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 87,
    price_performance_ratio = 82
WHERE name = 'LiveChat';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 25.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Crisp';

-- Business Intelligence & Reporting Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 95
WHERE name = 'Google Data Studio';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Growth Stage'),
    monthly_cost_usd = 90.00,
    setup_cost_usd = 500.00,
    license_cost_usd = 0.00,
    training_cost_usd = 400.00,
    total_cost_of_ownership_score = 80,
    price_performance_ratio = 75
WHERE name = 'Looker';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Qlik Sense';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Growth Stage'),
    monthly_cost_usd = 83.00,
    setup_cost_usd = 1000.00,
    license_cost_usd = 0.00,
    training_cost_usd = 500.00,
    total_cost_of_ownership_score = 75,
    price_performance_ratio = 70
WHERE name = 'Sisense';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 25.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Domo';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 95,
    price_performance_ratio = 90
WHERE name = 'Metabase';

-- Accounting & Finance Tools Pricing
UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 200.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'QuickBooks';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 13.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 92,
    price_performance_ratio = 90
WHERE name = 'Xero';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 100.00,
    total_cost_of_ownership_score = 90,
    price_performance_ratio = 88
WHERE name = 'FreshBooks';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Micro Budget'),
    monthly_cost_usd = 0.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 50.00,
    total_cost_of_ownership_score = 98,
    price_performance_ratio = 95
WHERE name = 'Wave';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Small Business'),
    monthly_cost_usd = 25.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 300.00,
    total_cost_of_ownership_score = 85,
    price_performance_ratio = 80
WHERE name = 'Sage';

UPDATE tools SET 
    price_tier_id = (SELECT id FROM price_tiers WHERE tier_name = 'Startup Budget'),
    monthly_cost_usd = 15.00,
    setup_cost_usd = 0.00,
    license_cost_usd = 0.00,
    training_cost_usd = 150.00,
    total_cost_of_ownership_score = 88,
    price_performance_ratio = 85
WHERE name = 'Zoho Books';

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

-- Verify tools pricing data
SELECT 
    t.name,
    t.category,
    pt.tier_name,
    t.monthly_cost_usd,
    t.setup_cost_usd,
    t.total_cost_of_ownership_score,
    t.price_performance_ratio
FROM tools t
LEFT JOIN price_tiers pt ON t.price_tier_id = pt.id
ORDER BY t.monthly_cost_usd DESC, t.name;

-- Summary by price tier
SELECT 
    pt.tier_name,
    COUNT(t.id) as tool_count,
    AVG(t.monthly_cost_usd) as avg_monthly_cost,
    AVG(t.total_cost_of_ownership_score) as avg_tco_score
FROM price_tiers pt
LEFT JOIN tools t ON pt.id = t.price_tier_id
GROUP BY pt.id, pt.tier_name
ORDER BY pt.min_price_usd;

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

-- Migration completed successfully
-- Tools are now connected to price tiers and can be included in budget calculations
