Fix migration for duplicate column, fixes #202

This commit is contained in:
antanst 2025-07-31 10:21:52 +03:00 committed by Chris
parent b65d6eea5b
commit 549236f2db

View file

@ -1,20 +1,27 @@
'use strict';
const { safeAddColumns, safeAddIndex } = require('../utils/migration-utils');
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('tasks', 'parent_task_id', {
type: Sequelize.INTEGER,
allowNull: true,
references: {
model: 'tasks',
key: 'id',
await safeAddColumns(queryInterface, 'tasks', [
{
name: 'parent_task_id',
definition: {
type: Sequelize.INTEGER,
allowNull: true,
references: {
model: 'tasks',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
});
]);
await queryInterface.addIndex('tasks', ['parent_task_id']);
await safeAddIndex(queryInterface, 'tasks', ['parent_task_id']);
},
async down(queryInterface) {