1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-24 15:49:46 +02:00
planka/server/db/migrations/20250708200908_persist_closed_state_per_card.js

29 lines
686 B
JavaScript
Raw Normal View History

2025-07-09 17:45:47 +02:00
/*!
* 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.boolean('is_closed').notNullable().default(false);
});
await knex.raw(`
UPDATE card
SET is_closed = TRUE
FROM list
WHERE card.list_id = list.id AND list.type = 'closed';
`);
return knex.schema.alterTable('card', (table) => {
table.boolean('is_closed').notNullable().alter();
});
};
exports.down = (knex) =>
knex.schema.table('card', (table) => {
table.dropColumn('is_closed');
});