Files
starr-philproperties/apps/api/database/migrations/20270101000018-create-quiz-options.js
T

22 lines
859 B
JavaScript

'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('quiz_options', {
option_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
question_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'quiz_questions', key: 'question_id' }, onDelete: 'CASCADE' },
text: { type: Sequelize.TEXT, allowNull: false },
is_correct: { type: Sequelize.BOOLEAN, defaultValue: false },
order_index: { type: Sequelize.INTEGER, defaultValue: 0 },
createdAt: { type: Sequelize.DATE, allowNull: false },
updatedAt: { type: Sequelize.DATE, allowNull: false },
});
await queryInterface.addIndex('quiz_options', ['question_id']);
},
async down(queryInterface) {
await queryInterface.dropTable('quiz_options');
},
};