Required Supabase Tables
-- Run in Supabase SQL editor:
create table athletes (
id uuid primary key default gen_random_uuid(),
name text not null,
current_week integer default 1,
program_template text default 'level4',
pin text default null,
created_at timestamptz default now()
);
create table workout_logs (
id uuid primary key default gen_random_uuid(),
athlete_id uuid references athletes(id) on delete cascade,
week integer not null,
day integer not null,
exercise_index integer not null,
completed boolean default false,
weights jsonb default '[]',
notes text default '',
updated_at timestamptz default now()
);
create table program_overrides (
id uuid primary key default gen_random_uuid(),
week integer not null,
day integer not null,
exercises jsonb not null,
updated_at timestamptz default now(),
unique(week, day)
);
create table athlete_overrides (
id uuid primary key default gen_random_uuid(),
athlete_id uuid references athletes(id) on delete cascade,
template text not null default 'level4',
week integer not null,
day integer not null,
scope text default 'week',
exercises jsonb not null,
updated_at timestamptz default now(),
unique(athlete_id, template, week, day, scope)
);
-- SECURITY: Row Level Security must be ENABLED with policies.
-- Run security-migration.sql (shipped with this app) in the SQL editor.
-- Do NOT disable RLS — that exposes all data to anyone with the anon key.