Added indeces on releases entity_id and studio_id, restored showcase query.

This commit is contained in:
DebaucheryLibrarian
2023-01-07 17:11:25 +01:00
parent 67f5ea9de8
commit f62a64c021
2 changed files with 28 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
/*
exports.up = async (knex) => knex.raw(`
CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
SELECT COALESCE(entities.showcased, false) OR COALESCE(studios.showcased, false) FROM releases
@@ -5,14 +6,19 @@ exports.up = async (knex) => knex.raw(`
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
WHERE releases.id = release.id
$$ LANGUAGE SQL STABLE;
/* CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
SELECT COALESCE((SELECT showcased FROM entities WHERE entities.id = releases.entity_id), false)
OR COALESCE((SELECT showcased FROM entities WHERE entities.id = releases.studio_id), false) FROM releases
WHERE releases.id = release.id
$$ LANGUAGE SQL STABLE; */
`);
exports.down = async (knex) => knex.raw(`
DROP FUNCTION IF EXISTS releases_is_showcased;
`);
*/
exports.up = async (knex) => knex.schema.alterTable('releases', (table) => {
table.index('entity_id');
table.index('studio_id');
});
exports.down = async (knex) => knex.schema.alterTable('releases', (table) => {
table.dropIndex('entity_id');
table.dropIndex('studio_id');
});