From 199ee02ba970a95c3ee444ccf556c60ca09225b8 Mon Sep 17 00:00:00 2001 From: Alejandro Montes Date: Wed, 5 Aug 2026 10:09:00 +0200 Subject: [PATCH] fix(database): add missing task media columns Keep task schema aligned with Sequelize hasOne associations. Refs #1138 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...104500-feature-task-media-associations.cjs | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 code/migrations/20260805104500-feature-task-media-associations.cjs diff --git a/code/migrations/20260805104500-feature-task-media-associations.cjs b/code/migrations/20260805104500-feature-task-media-associations.cjs new file mode 100644 index 00000000..0a98f2fa --- /dev/null +++ b/code/migrations/20260805104500-feature-task-media-associations.cjs @@ -0,0 +1,70 @@ +'use strict'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + const transaction = await queryInterface.sequelize.transaction(); + + try { + const task = await queryInterface.describeTable('weavejs_task'); + + if (!task.ImageModelRoomId) { + await queryInterface.addColumn( + 'weavejs_task', + 'ImageModelRoomId', + { + type: Sequelize.STRING, + allowNull: true, + }, + { transaction }, + ); + } + + if (!task.VideoModelRoomId) { + await queryInterface.addColumn( + 'weavejs_task', + 'VideoModelRoomId', + { + type: Sequelize.STRING, + allowNull: true, + }, + { transaction }, + ); + } + + await transaction.commit(); + } catch (error) { + await transaction.rollback(); + throw error; + } + }, + + async down(queryInterface) { + const transaction = await queryInterface.sequelize.transaction(); + + try { + const task = await queryInterface.describeTable('weavejs_task'); + + if (task.ImageModelRoomId) { + await queryInterface.removeColumn( + 'weavejs_task', + 'ImageModelRoomId', + { transaction }, + ); + } + + if (task.VideoModelRoomId) { + await queryInterface.removeColumn( + 'weavejs_task', + 'VideoModelRoomId', + { transaction }, + ); + } + + await transaction.commit(); + } catch (error) { + await transaction.rollback(); + throw error; + } + }, +};