41 lines
941 B
JavaScript
41 lines
941 B
JavaScript
import { sequelize } from './../loaders/index.js';
|
|
import { DataTypes } from 'sequelize';
|
|
|
|
const assessmentQuestion = sequelize.define('assessmentQuestion', {
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
},
|
|
orderId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
|
|
},
|
|
question: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
},
|
|
options: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
}
|
|
}, {
|
|
tableName: 'assessment_questions', // Define the name of the table
|
|
});
|
|
|
|
// Sync the model with the database
|
|
const syncDb = async () => {
|
|
try {
|
|
await sequelize.sync({ alter: false });
|
|
console.log('assessmentQuestion table created (or already exists)');
|
|
} catch (err) {
|
|
console.error('Error syncing the database:', err);
|
|
}
|
|
};
|
|
|
|
// Call the sync function
|
|
syncDb();
|
|
|
|
export { assessmentQuestion };
|