diff --git a/migrations/20200806170752-removeDifficultyFromQuestion.js b/migrations/20200806170752-removeDifficultyFromQuestion.js new file mode 100644 index 0000000..8ff4422 --- /dev/null +++ b/migrations/20200806170752-removeDifficultyFromQuestion.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.removeColumn('questions', 'difficulty') + }, + + down: (queryInterface, Sequelize) => { + return queryInterface.addColumn('questions', 'difficulty', { + type: Sequelize.INTEGER(), + allowNull: false, + defaultValue: 0 + }) + } +}; diff --git a/migrations/20200806170817-addDifficultyToQuestion.js b/migrations/20200806170817-addDifficultyToQuestion.js new file mode 100644 index 0000000..fb5d073 --- /dev/null +++ b/migrations/20200806170817-addDifficultyToQuestion.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.addColumn('questions', 'difficulty', { + type: Sequelize.ENUM('EASY', 'MEDIUM', 'HARD'), + allowNull: false, + }) + }, + + down: (queryInterface, Sequelize) => { + return queryInterface.removeColumn('questions', 'difficulty') + } +}; \ No newline at end of file diff --git a/models/questions.js b/models/questions.js index 10011c9..c6df6c1 100644 --- a/models/questions.js +++ b/models/questions.js @@ -14,9 +14,9 @@ module.exports = (sequelize, DataTypes) => { allowNull: true }, difficulty: { - type: DataTypes.INTEGER, + type: DataTypes.ENUM ('EASY', 'MEDIUM', 'HARD'), allowNull: false, - defaultValue: 0 + defaultValue: 'EASY' }, correctAnswers: { type: DataTypes.ARRAY(DataTypes.BIGINT),