]> Git — Sourcephile - gargantext.git/blob - devops/postgres/tools/removeUnusedDocuments.sql
Merge remote-tracking branch 'origin/213-dev-implement-json-errors' into dev
[gargantext.git] / devops / postgres / tools / removeUnusedDocuments.sql
1
2 WITH repeated AS
3 (
4 select nn.context_id AS id, count(*) AS c
5 FROM nodes_contexts nn
6 GROUP BY nn.context_id
7 )
8
9 DELETE FROM contexts c
10 USING repeated r
11 WHERE
12 c.id = r.id
13 AND r.c = 1
14 AND c.typename = 4
15 ;
16