1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00

feat: Display comments total on front of cards (#1146)

Closes #1136
This commit is contained in:
Hannes 2025-05-23 17:31:28 +02:00 committed by GitHub
parent f9d3e73651
commit 4049b4c396
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 165 additions and 13 deletions

View file

@ -0,0 +1,32 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
exports.up = async (knex) => {
await knex.schema.alterTable('card', (table) => {
/* Columns */
table.integer('comments_total').notNullable().defaultTo(0);
});
await knex.raw(`
UPDATE card
SET comments_total = comments_total_by_card_id.comments_total
FROM (
SELECT card_id, COUNT(*) as comments_total
FROM comment
GROUP BY card_id
) AS comments_total_by_card_id
WHERE card.id = comments_total_by_card_id.card_id
`);
return knex.schema.alterTable('card', (table) => {
table.integer('comments_total').notNullable().alter();
});
};
exports.down = (knex) =>
knex.schema.table('card', (table) => {
table.dropColumn('comments_total');
});