tududi/backend/migrations/20250623000001-add-uuid-to-tasks.js
Chris 03f38f05dc
Setup intelligence (#84)
* Add next suggestions and remove console logs

* Add pomodoro timer

* Add pomodoro switch in settings

* Fix pomodoro setting

* Add timezones to settings

* Fix an issue with password reset

* Cleanup

* Sort tags alphabetically

* Clean up today's view

* Add an indicator for repeatedly added to today

* Refactor tags

* Add due date today item

* Move recurrence to the subtitle area

* Fix today layout

* Add a badge to Inbox items

* Move inbox badge to sidebar

* Add quotes and progress bar

* Add translations for quotes

* Fix test issues

* Add helper script for docker local

* Set up overdue tasks

* Add  linux/arm/v7 build to deploy script

* Add  linux/arm/v7 build to deploy script pt2

* Fix an issue with helmet and SSL

* Add volume db persistence

* Fix cog icon issues
2025-06-27 14:02:18 +03:00

41 lines
No EOL
1.1 KiB
JavaScript

'use strict';
const { v4: uuidv4 } = require('uuid');
module.exports = {
async up(queryInterface, Sequelize) {
// Add UUID column to tasks table (without unique constraint initially)
await queryInterface.addColumn('tasks', 'uuid', {
type: Sequelize.UUID,
allowNull: true
});
// Backfill existing tasks with UUIDs
const tasks = await queryInterface.sequelize.query(
'SELECT id FROM tasks WHERE uuid IS NULL',
{ type: Sequelize.QueryTypes.SELECT }
);
for (const task of tasks) {
const uuid = uuidv4();
await queryInterface.sequelize.query(
'UPDATE tasks SET uuid = ? WHERE id = ?',
{ replacements: [uuid, task.id] }
);
}
// Add unique index for UUID
await queryInterface.addIndex('tasks', ['uuid'], {
unique: true,
name: 'tasks_uuid_unique'
});
},
async down(queryInterface, Sequelize) {
// Remove index first
await queryInterface.removeIndex('tasks', 'tasks_uuid_unique');
// Remove UUID column
await queryInterface.removeColumn('tasks', 'uuid');
}
};