-- Seed demo credits for existing users who don't yet have a credits row.
-- Run after migrations. Safe to re-run (INSERT IGNORE).
INSERT IGNORE INTO `user_credits` (`user_id`, `balance`, `total_used`)
SELECT `id`, 10, 0
FROM `users`
WHERE `id` NOT IN (SELECT `user_id` FROM `user_credits`);

-- Seed a welcome notification for users who have none.
INSERT IGNORE INTO `notifications` (`user_id`, `type`, `title`, `body`)
SELECT `id`, 'info', 'Welcome to Syntro Build AI',
       'You have been granted 10 free credits to get started. Use them to generate your first website!'
FROM `users`
WHERE `id` NOT IN (SELECT DISTINCT `user_id` FROM `notifications`);
