25 lines
818 B
JavaScript
25 lines
818 B
JavaScript
/*
|
|
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
|
|
LEFT JOIN entities ON entities.id = releases.entity_id
|
|
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
|
|
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');
|
|
});
|