Restored showcased function with indexes.
This commit is contained in:
parent
97d9f5e373
commit
abfbb0f279
|
@ -431,22 +431,10 @@ const releasesFragment = `
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
or: [
|
isShowcased: {
|
||||||
{
|
|
||||||
entity: {
|
|
||||||
showcased: {
|
|
||||||
equalTo: true
|
equalTo: true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
studio: {
|
|
||||||
showcased: {
|
|
||||||
equalTo: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
first: $limit,
|
first: $limit,
|
||||||
offset: $offset,
|
offset: $offset,
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
/*
|
exports.up = async (knex) => Promise.resolve()
|
||||||
exports.up = async (knex) => knex.raw(`
|
.then(() => knex.raw(`
|
||||||
CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
|
CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
|
||||||
SELECT COALESCE(entities.showcased, false) OR COALESCE(studios.showcased, false) FROM releases
|
SELECT COALESCE(entities.showcased, false) OR COALESCE(studios.showcased, false) FROM releases
|
||||||
LEFT JOIN entities ON entities.id = releases.entity_id
|
LEFT JOIN entities ON entities.id = releases.entity_id
|
||||||
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
|
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
|
||||||
WHERE releases.id = release.id
|
WHERE releases.id = release.id
|
||||||
$$ LANGUAGE SQL STABLE;
|
$$ LANGUAGE SQL STABLE;
|
||||||
`);
|
`)).then(() => knex.schema.alterTable('releases', (table) => {
|
||||||
|
|
||||||
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('entity_id');
|
||||||
table.index('studio_id');
|
table.index('studio_id');
|
||||||
});
|
}));
|
||||||
|
|
||||||
exports.down = async (knex) => knex.schema.alterTable('releases', (table) => {
|
exports.down = async (knex) => Promise.resolve()
|
||||||
|
.then(() => knex.schema.alterTable('releases', (table) => {
|
||||||
table.dropIndex('entity_id');
|
table.dropIndex('entity_id');
|
||||||
table.dropIndex('studio_id');
|
table.dropIndex('studio_id');
|
||||||
});
|
})).then(() => knex.raw(`
|
||||||
|
DROP FUNCTION IF EXISTS releases_is_showcased;
|
||||||
|
`));
|
||||||
|
|
Loading…
Reference in New Issue