]> pd.if.org Git - zpackage/blobdiff - db.sql
add notes.file to filerefs view
[zpackage] / db.sql
diff --git a/db.sql b/db.sql
index 00c5df0f6f1e316c964dd380fe84570f95cbc169..eb7c461bcc426ec0bee8c4ab96db564cee1c128d 100644 (file)
--- a/db.sql
+++ b/db.sql
@@ -15,6 +15,17 @@ CREATE TABLE files (
 )
 ;
 
+create view filerefs as
+select F.hash,
+count(PF.hash) + count(S.hash) + count(EL.file) + count(N.file) as refcount
+from files F
+left join packagefiles PF on PF.hash = F.hash
+left join scripts S on S.hash = F.hash
+left join elflibraries EL on EL.file = F.hash
+left join notes N on N.file = F.hash
+group by F.hash
+;
+
 -- information about packages
 -- a package is identified by a package,version,release triple
 create table packages (