How to design two tables: A hasMany B, and one B per A has state 'active'?
You can use a partial unique index on the branches table: 

create table branches
(
  id integer primary key, 
  env_id integer not null references environments,
  active boolean not null,
  ... other columns ...
);

create unique index on branches (env_id) 
where active;


Now for each env_id, there can be many different rows with active = false, but only one with active = true.