'use strict'; // Part 1A — completions gain a review workflow (submitted/approved/rejected) // and a response_text field for the new submit_text requirement type. // `status` is added as STRING + an explicit CHECK constraint, matching the // pattern task_progress.type already uses on this CockroachDB instance // (createTable auto-generates `check_type`; addColumn does not, so we add it // ourselves) rather than the ENUM-with-no-constraint gap task_requirements.type // happens to have today. module.exports = { async up(queryInterface, Sequelize) { await queryInterface.addColumn('task_completions', 'response_text', { type: Sequelize.TEXT, allowNull: true, after: 'note', }); await queryInterface.addColumn('task_completions', 'status', { type: Sequelize.STRING, allowNull: false, defaultValue: 'submitted', after: 'response_text', }); await queryInterface.sequelize.query( `ALTER TABLE task_completions ADD CONSTRAINT check_status CHECK (status IN ('submitted', 'approved', 'rejected'))` ); await queryInterface.addColumn('task_completions', 'reviewed_by', { type: Sequelize.BIGINT, allowNull: true, after: 'status', }); await queryInterface.addColumn('task_completions', 'reviewed_at', { type: Sequelize.DATE, allowNull: true, after: 'reviewed_by', }); await queryInterface.addColumn('task_completions', 'review_note', { type: Sequelize.TEXT, allowNull: true, after: 'reviewed_at', }); }, async down(queryInterface) { await queryInterface.removeColumn('task_completions', 'review_note'); await queryInterface.removeColumn('task_completions', 'reviewed_at'); await queryInterface.removeColumn('task_completions', 'reviewed_by'); await queryInterface.sequelize.query( `ALTER TABLE task_completions DROP CONSTRAINT IF EXISTS check_status` ); await queryInterface.removeColumn('task_completions', 'status'); await queryInterface.removeColumn('task_completions', 'response_text'); }, };