diff options
| author | faried nawaz <faried@gmail.com> | 2021-04-21 02:38:59 +0500 | 
|---|---|---|
| committer | faried nawaz <faried@gmail.com> | 2021-05-08 02:00:42 +0500 | 
| commit | a0c9a2b4cc8c22d6238b0f31239c1e655f47730f (patch) | |
| tree | aeb2c8d59d6b3fbc79a5112d2a5dcb3646ae1369 /lib | |
| parent | 22b2451edd9e42ba96bf7f815383b2eaad9a5e56 (diff) | |
| download | pleroma-a0c9a2b4cc8c22d6238b0f31239c1e655f47730f.tar.gz pleroma-a0c9a2b4cc8c22d6238b0f31239c1e655f47730f.zip | |
mix prune_objects: remove unused hashtags after pruning remote objects
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/mix/tasks/pleroma/database.ex | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex index e7f4b67a4..53ad58b64 100644 --- a/lib/mix/tasks/pleroma/database.ex +++ b/lib/mix/tasks/pleroma/database.ex @@ -96,6 +96,17 @@ defmodule Mix.Tasks.Pleroma.Database do      )      |> Repo.delete_all(timeout: :infinity) +    prune_hashtags_query = """ +    delete from hashtags +    where id in ( +      select id from hashtags as ht +      left join hashtags_objects as hto +      on hto.hashtag_id = ht.id +      where hto.hashtag_id is null) +    """ + +    Repo.query(prune_hashtags_query) +      if Keyword.get(options, :vacuum) do        Maintenance.vacuum("full")      end | 
