create table if not exists tournaments(
  id serial primary key,
  name text not null,
  location text,
  start_date date,
  end_date date,
  created_at timestamp default now()
);
create table if not exists participants(
  id serial primary key,
  tournament_id int not null references tournaments(id) on delete cascade,
  full_name text not null,
  created_at timestamp default now()
);
create index if not exists idx_participants_t on participants(tournament_id);
create table if not exists matches(
  id serial primary key,
  tournament_id int not null references tournaments(id) on delete cascade,
  court text,
  starts_at timestamp,
  team_a text,
  team_b text,
  score_a int default 0,
  score_b int default 0,
  done boolean default false,
  created_at timestamp default now()
);
create index if not exists idx_matches_t on matches(tournament_id);
