initial commit
[squeep-indie-auther] / src / db / postgres / sql / scope-in-use.sql
1 -- return whether a scope is currently in use, either a profile setting or on a token
2 SELECT EXISTS (
3 SELECT 1 FROM scope s
4 INNER JOIN profile_scope ps USING (scope_id)
5 WHERE s.scope = $(scope)
6 UNION All
7 SELECT 1 FROM scope s
8 INNER JOIN token_scope ts USING (scope_id)
9 WHERE s.scope = $(scope)
10 UNION All
11 SELECT 1 FROM scope s
12 WHERE s.scope = $(scope) AND s.is_permanent
13 ) AS in_use