Added entity scene count function.

This commit is contained in:
DebaucheryLibrarian
2022-01-26 13:52:39 +01:00
parent b62ae00c54
commit 250618df8b
3 changed files with 13 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
exports.up = async (knex) => knex.raw(`
CREATE OR REPLACE FUNCTION entities_scene_total(entity entities) RETURNS integer AS $$
SELECT COUNT(id)
FROM releases
WHERE releases.entity_id = entity.id;
$$ LANGUAGE SQL STABLE;
`);
exports.down = async (knex) => knex.raw(`
DROP FUNCTION IF EXISTS entities_scene_total;
`);