From 07e8ebd552802831ae1bbf3dee68d14becda4822 Mon Sep 17 00:00:00 2001 From: Rikard Bartholf Date: Tue, 15 Oct 2024 14:52:50 +0200 Subject: [PATCH] Create v_funnel_collections (#423) * Add query * Substitute sub-query with JOIN * Fix typo in view * Fix typo in view * :art: Cleanup * Remove redundant GRANT * Fix revision for 504 --- migrations/000.504.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 migrations/000.504.sql diff --git a/migrations/000.504.sql b/migrations/000.504.sql new file mode 100644 index 0000000..8348b88 --- /dev/null +++ b/migrations/000.504.sql @@ -0,0 +1,15 @@ +-- View: public.v_funnel_collections + +DROP VIEW public.v_funnel_collections; + +CREATE VIEW public.v_funnel_collections + AS + SELECT c.id AS collection_id, + c.name AS collection_name, + c.inserted AS date_added, + cp.product_id, + cp.inserted AS product_date_added + FROM collections c + JOIN collections_products cp ON c.id = cp.collection_id; + +GRANT SELECT ON TABLE public.v_funnel_collections TO funnel;