mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
parent
d260d2dac0
commit
a741e26ccb
33 changed files with 370 additions and 104 deletions
|
@ -1,44 +1,5 @@
|
|||
const POSITION_GAP = 65535;
|
||||
const { addPosition, removePosition } = require('../../utils/migrations');
|
||||
|
||||
module.exports.up = async (knex) => {
|
||||
await knex.schema.table('task', (table) => {
|
||||
/* Columns */
|
||||
module.exports.up = (knex) => addPosition(knex, 'task', 'card_id');
|
||||
|
||||
table.specificType('position', 'double precision');
|
||||
|
||||
/* Indexes */
|
||||
|
||||
table.index('position');
|
||||
});
|
||||
|
||||
const tasks = await knex('task').orderBy(['card_id', 'id']);
|
||||
|
||||
let prevCardId;
|
||||
let position;
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (task of tasks) {
|
||||
if (task.card_id === prevCardId) {
|
||||
position += POSITION_GAP;
|
||||
} else {
|
||||
prevCardId = task.card_id;
|
||||
position = POSITION_GAP;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await knex('task')
|
||||
.update({
|
||||
position,
|
||||
})
|
||||
.where('id', task.id);
|
||||
}
|
||||
|
||||
return knex.schema.table('task', (table) => {
|
||||
table.dropNullable('position');
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.down = async (knex) =>
|
||||
knex.schema.table('task', (table) => {
|
||||
table.dropColumn('position');
|
||||
});
|
||||
module.exports.down = (knex) => removePosition(knex, 'task');
|
||||
|
|
5
server/db/migrations/20230108213138_labels_reordering.js
Normal file
5
server/db/migrations/20230108213138_labels_reordering.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const { addPosition, removePosition } = require('../../utils/migrations');
|
||||
|
||||
module.exports.up = (knex) => addPosition(knex, 'label', 'board_id');
|
||||
|
||||
module.exports.down = (knex) => removePosition(knex, 'label');
|
Loading…
Add table
Add a link
Reference in a new issue