-- Issue 1: sbc_submissions was created (0001_initial.sql) without a club_id column,
-- but the MY CLUB milestone query (routes/club.rs get_milestones) counts
--   SELECT COUNT(*) FROM sbc_submissions WHERE club_id = ? AND passed = 1
-- so SQLite errored on the unknown column and the error was swallowed by
-- `.unwrap_or(0)` -> the `sbcs_completed` milestone always read 0. Add the column
-- and backfill it from the profile's club so historical submissions count.
ALTER TABLE sbc_submissions ADD COLUMN club_id TEXT;

UPDATE sbc_submissions
SET club_id = (SELECT c.id FROM clubs c WHERE c.profile_id = sbc_submissions.profile_id)
WHERE club_id IS NULL;
