X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=db.sql;h=94ffce308a19b726172ff4e9e987d9ef24053750;hb=51a6d79f8a532376a9f27dbb5133bf13a5474703;hp=bf6fd22a07c01b886d9d6e26a9dc1557d5132c03;hpb=6adc79aeafb90e90c9923b3eeedab662888927e9;p=zpackage diff --git a/db.sql b/db.sql index bf6fd22..94ffce3 100644 --- a/db.sql +++ b/db.sql @@ -52,6 +52,8 @@ create table packages ( without rowid ; +create index package_status_index on packages (status); + create view packages_pkgid as select printf('%s-%s-%s', package, version, release) as pkgid, * from packages; @@ -153,6 +155,13 @@ from installedfiles I group by I.path ; +create view sync_status_ref_count as +select path, status, count(*) as refcount +from packagefiles_status +where status in ('installed', 'installing', 'removing') +group by path, status +; + create view packagefiles_status as select P.status, PF.* from packagefiles_pkgid PF @@ -197,6 +206,16 @@ left join packagefiles_status PN and PI.pkgid != PN.pkgid where PN.path is null and PI.package in (select package from packages where status = 'installing') + +union all +-- remove files in removing, but not installing +select distinct 'remove' as op, PR.* +from packagefiles_status PR +left join packagefiles_status PN +on PR.path = PN.path +and PR.pkgid != PN.pkgid and PN.status in ('installing', 'installed') +where PN.path is null +and PR.status = 'removing' ; create table pathtags (