-- TODO copyright and license information should probably
-- go here
CREATE TABLE files (
- hash text primary key, -- sha256 of content
+ hash text primary key, -- sha256 of (uncompressed) content
size integer, -- bigint? certainly need > 2GB
compression text, -- always xz?
content blob
create view filerefs as
select F.hash,
-count(PF.hash) + count(S.hash) + count(EL.file) + count(N.file) as refcount
+count(PF.hash) + count(S.hash) + count(EL.file) + count(N.file) + count(EN.file) as refcount,
+count(PF.hash) as pfrefs,
+count(S.hash) as scriptrefs,
+count(EL.file) as librefs,
+count(EN.file) as needrefs,
+count(N.file) as noterefs
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 elfneeded EN on EN.file = F.hash
left join notes N on N.file = F.hash
group by F.hash
;