implications: refactor calculation of implied tags.

Refactor to use a recursive CTE to calculate implied tags in SQL, rather
than storing them in a descendant_names field. This avoids the
complexity of keeping the stored field up to date. It's also more
flexible, since it allows us to find both descendant tags (tags that
imply a given tag) as well as ancestor tags (tags that are implied by a
given tag).
This commit is contained in:
evazion
2020-02-22 22:12:49 -06:00
parent 83a3ed85dd
commit a8e5412d9c
7 changed files with 66 additions and 135 deletions

View File

@@ -2883,7 +2883,6 @@ CREATE TABLE public.tag_implications (
id integer NOT NULL,
antecedent_name character varying NOT NULL,
consequent_name character varying NOT NULL,
descendant_names text[] DEFAULT '{}'::text[] NOT NULL,
creator_id integer NOT NULL,
forum_topic_id integer,
status text DEFAULT 'pending'::text NOT NULL,
@@ -7352,6 +7351,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200119184442'),
('20200119193110'),
('20200123184743'),
('20200217044719');
('20200217044719'),
('20200223042415');