Help with a trigger + function

I'm a noob in this area. Given the following schema...
create table games (
  id uuid primary key DEFAULT gen_random_uuid(),
  name text,
  players_min int default 0,
  players_conf int default 0,
  game_on boolean not null default false
);

I want to change game_on to true when players_conf (confirmed) is equal to or greater than players_min. (Conversely, if players_conf becomes less than players_min, game_on should be changed to
false
.) Basically, on update, I want to run this condition and potential update to run. But... how. Still learning PGSQL.
Was this page helpful?