Improved 'is new' postgres function to deal with skipped batch IDs.

This commit is contained in:
2020-06-30 02:08:48 +02:00
parent ff384fb734
commit 3fba2d8a77
2 changed files with 2 additions and 6 deletions

View File

@@ -803,7 +803,7 @@ exports.up = knex => Promise.resolve()
$$ LANGUAGE SQL STABLE;
CREATE FUNCTION releases_is_new(release releases) RETURNS boolean AS $$
SELECT NOT EXISTS(SELECT true FROM batches WHERE batches.id = release.created_batch_id + 1 LIMIT 1);
SELECT EXISTS(SELECT true WHERE (SELECT id FROM batches ORDER BY created_at DESC LIMIT 1) = release.created_batch_id);
$$ LANGUAGE sql STABLE;
CREATE VIEW movie_actors AS