Changed to upsert in permissions storage