64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
const { Sequelize } = require("sequelize");
|
|
|
|
module.exports = {
|
|
async up(queryInterface) {
|
|
await queryInterface.createTable("multiple_choices", {
|
|
ID_MULTIPLE_CHOICES: {
|
|
type: Sequelize.UUID,
|
|
primaryKey: true,
|
|
defaultValue: Sequelize.UUIDV4,
|
|
allowNull: false,
|
|
},
|
|
ID_ADMIN_EXERCISE: {
|
|
type: Sequelize.UUID,
|
|
allowNull: false,
|
|
},
|
|
OPTION_A: {
|
|
type: Sequelize.STRING(256),
|
|
allowNull: true,
|
|
},
|
|
OPTION_B: {
|
|
type: Sequelize.STRING(256),
|
|
allowNull: true,
|
|
},
|
|
OPTION_C: {
|
|
type: Sequelize.STRING(256),
|
|
allowNull: true,
|
|
},
|
|
OPTION_D: {
|
|
type: Sequelize.STRING(256),
|
|
allowNull: true,
|
|
},
|
|
OPTION_E: {
|
|
type: Sequelize.STRING(256),
|
|
allowNull: true,
|
|
},
|
|
ANSWER_KEY: {
|
|
type: Sequelize.STRING(100),
|
|
allowNull: false,
|
|
},
|
|
TIME_MULTIPLE_CHOICES: {
|
|
type: Sequelize.DATE,
|
|
allowNull: true,
|
|
defaultValue: Sequelize.NOW,
|
|
},
|
|
});
|
|
|
|
await queryInterface.addConstraint("multiple_choices", {
|
|
fields: ["ID_ADMIN_EXERCISE"],
|
|
type: "foreign key",
|
|
name: "FK_MC_TERDAPAT",
|
|
references: {
|
|
table: "admin_exercise",
|
|
field: "ID_ADMIN_EXERCISE",
|
|
},
|
|
onUpdate: "CASCADE",
|
|
onDelete: "CASCADE",
|
|
});
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
await queryInterface.dropTable("multiple_choices");
|
|
},
|
|
};
|