forked from DebaucheryLibrarian/traxxx
Showing scene and channel count on entity page and tile.
This commit is contained in:
24
migrations/20211030162955_entity_scenes.js
Normal file
24
migrations/20211030162955_entity_scenes.js
Normal file
@@ -0,0 +1,24 @@
|
||||
exports.up = async knex => knex.raw(`
|
||||
CREATE FUNCTION entities_scenes(entity entities) RETURNS SETOF releases AS $$
|
||||
WITH RECURSIVE children AS (
|
||||
SELECT entities.id
|
||||
FROM entities
|
||||
WHERE entities.id = entity.id
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT entities.id
|
||||
FROM entities
|
||||
INNER JOIN children ON children.id = entities.parent_id
|
||||
)
|
||||
|
||||
SELECT releases FROM releases
|
||||
INNER JOIN children ON children.id = releases.entity_id;
|
||||
$$ LANGUAGE SQL STABLE;
|
||||
|
||||
COMMENT ON FUNCTION entities_scenes IS E'@sortable';
|
||||
`);
|
||||
|
||||
exports.down = async knex => knex.raw(`
|
||||
DROP FUNCTION IF EXISTS entities_scenes;
|
||||
`);
|
||||
Reference in New Issue
Block a user