]> pd.if.org Git - zpackage/commitdiff
add views useful for installs and uninstalls
authorNathan Wagner <nw@hydaspes.if.org>
Tue, 21 Aug 2018 17:33:16 +0000 (17:33 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Tue, 21 Aug 2018 17:33:16 +0000 (17:33 +0000)
db.sql

diff --git a/db.sql b/db.sql
index d134208b4ea2f0ccccae3ef79a33c4eaf6d2e7be..5f227c87ee3fe99b752f2a7751b94c146a5d2b46 100644 (file)
--- a/db.sql
+++ b/db.sql
@@ -101,6 +101,23 @@ create table packagefiles (
 without rowid
 ;
 
+create view installedfiles as
+select PF.package, PF.version, PF.release,
+printf('%s-%s-%s', PF.package, PF.version, PF.release) as pkgid,
+PF.path, PF.hash, PF.filetype
+from packagefiles PF
+left join packages P
+on P.package = PF.package and P.version = PF.version and P.release = PF.release
+where
+P.status = 'installed'
+;
+
+create view installed_ref_count as
+select I.path, count(*) as refcount
+from installedfiles I
+group by I.path
+;
+
 create table pathtags (
        -- package id triple
        package text,