13 lines
345 B
JavaScript
13 lines
345 B
JavaScript
|
exports.up = async (knex) => knex.raw(`
|
||
|
CREATE MATERIALIZED VIEW entities_stats
|
||
|
AS
|
||
|
SELECT entities.id AS entity_id, count(releases.id) AS releases_count
|
||
|
FROM entities
|
||
|
LEFT JOIN releases ON releases.entity_id = entities.id
|
||
|
GROUP BY entities.id;
|
||
|
`);
|
||
|
|
||
|
exports.down = async (knex) => knex.raw(`
|
||
|
DROP MATERIALIZED VIEW entities_stats;
|
||
|
`);
|