mirror of https://github.com/artifacthub/hub.git
Keep views tracked when a pkg or repo is removed (#2572)
Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
This commit is contained in:
parent
a4be2500a9
commit
81a085be12
|
|
@ -62,6 +62,7 @@ returns setof json as $$
|
|||
sum(total) as total
|
||||
from package_views
|
||||
where day = current_date
|
||||
and package_id is not null
|
||||
group by package_id
|
||||
order by total desc
|
||||
limit 10
|
||||
|
|
@ -79,6 +80,7 @@ returns setof json as $$
|
|||
from package_views
|
||||
where date_trunc('year', day) = date_trunc('year', current_date)
|
||||
and date_trunc('month', day) = date_trunc('month', current_date)
|
||||
and package_id is not null
|
||||
group by package_id
|
||||
order by total desc
|
||||
limit 10
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
alter table package_views alter column package_id drop not null;
|
||||
alter table package_views alter column version drop not null;
|
||||
alter table package_views drop constraint package_views_package_id_version_fkey;
|
||||
alter table package_views add constraint package_views_package_id_version_fkey
|
||||
foreign key (package_id, version)
|
||||
references snapshot (package_id, version)
|
||||
on delete set null;
|
||||
|
||||
---- create above / drop below ----
|
||||
|
||||
delete from package_views where package_id is null;
|
||||
alter table package_views alter column package_id set not null;
|
||||
alter table package_views alter column version set not null;
|
||||
alter table package_views drop constraint package_views_package_id_version_fkey;
|
||||
alter table package_views add constraint package_views_package_id_version_fkey
|
||||
foreign key (package_id, version)
|
||||
references snapshot (package_id, version)
|
||||
on delete cascade;
|
||||
Loading…
Reference in New Issue