-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- migrate:up | ||
DROP VIEW flat_logger_files; | ||
|
||
CREATE VIEW flat_logger_files AS ( | ||
WITH has_logger_type AS ( | ||
SELECT | ||
r.id, | ||
array_agg(DISTINCT l."type") AS types, | ||
li.deployment | ||
FROM | ||
ring AS r | ||
JOIN logger_instrumentation AS li ON li.ring = r.id | ||
JOIN logger AS l ON li.logger = l.id | ||
GROUP BY | ||
r.id, | ||
li.deployment | ||
) | ||
SELECT | ||
li.id, | ||
li.logger, | ||
h.types AS related_logger_types, | ||
li.ring, | ||
li.status, | ||
li.sampling_freq_s, | ||
li.mass_g, | ||
li.attachment_method, | ||
li.mount_method, | ||
li.startup, | ||
li.deployment, | ||
li.retrieval, | ||
li.filename, | ||
li.data_stored_externally, | ||
li.comment, | ||
l.type, | ||
l.model | ||
FROM | ||
logger_instrumentation li | ||
JOIN has_logger_type h ON h.id = li.ring | ||
AND h.deployment = li.deployment | ||
JOIN logger l ON li.logger = l.id | ||
); | ||
|
||
GRANT SELECT ON public.flat_logger_files TO readonly; | ||
|
||
-- migrate:down |