62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
/** @type {import('sequelize-cli').Migration} */
|
|
module.exports = {
|
|
async up (queryInterface, Sequelize) {
|
|
console.log('Creating guest_settings table...');
|
|
|
|
await queryInterface.createTable('guest_settings', {
|
|
id: {
|
|
type: Sequelize.CHAR(36),
|
|
primaryKey: true,
|
|
allowNull: false,
|
|
comment: 'UUID primary key'
|
|
},
|
|
max_quizzes: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 3,
|
|
comment: 'Maximum number of quizzes a guest can take'
|
|
},
|
|
expiry_hours: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 24,
|
|
comment: 'Guest session expiry time in hours'
|
|
},
|
|
public_categories: {
|
|
type: Sequelize.JSON,
|
|
allowNull: false,
|
|
defaultValue: '[]',
|
|
comment: 'Array of category UUIDs accessible to guests'
|
|
},
|
|
feature_restrictions: {
|
|
type: Sequelize.JSON,
|
|
allowNull: false,
|
|
defaultValue: '{"allowBookmarks":false,"allowReview":true,"allowPracticeMode":true,"allowTimedMode":false,"allowExamMode":false}',
|
|
comment: 'Feature restrictions for guest users'
|
|
},
|
|
created_at: {
|
|
type: Sequelize.DATE,
|
|
allowNull: false,
|
|
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
|
|
},
|
|
updated_at: {
|
|
type: Sequelize.DATE,
|
|
allowNull: false,
|
|
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
|
|
}
|
|
}, {
|
|
comment: 'System-wide guest user settings'
|
|
});
|
|
|
|
console.log('✅ guest_settings table created successfully');
|
|
},
|
|
|
|
async down (queryInterface, Sequelize) {
|
|
console.log('Dropping guest_settings table...');
|
|
await queryInterface.dropTable('guest_settings');
|
|
console.log('✅ guest_settings table dropped successfully');
|
|
}
|
|
};
|