Fix migration for duplicate column, fixes #202
This commit is contained in:
parent
b65d6eea5b
commit
549236f2db
1 changed files with 17 additions and 10 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue