-- CreateFreeSubscriptions
INSERT INTO "subscriptions" (
  id,
  user_id,
  plan_type,
  optimizations_used,
  optimizations_limit,
  subscription_status,
  current_period_start,
  current_period_end,
  created_at,
  updated_at
)
SELECT
  gen_random_uuid(),
  user_id,
  'free',
  0,
  100,
  'active',
  CURRENT_TIMESTAMP,
  CURRENT_TIMESTAMP + INTERVAL '1 month',
  CURRENT_TIMESTAMP,
  CURRENT_TIMESTAMP
FROM users
WHERE user_id NOT IN (
  SELECT user_id FROM subscriptions
);