54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { QueryInterface, DataTypes } from 'sequelize';
|
|
|
|
module.exports = {
|
|
async up(queryInterface: QueryInterface): Promise<void> {
|
|
// Add notification preference columns to users table
|
|
await queryInterface.addColumn('users', 'email_notifications_enabled', {
|
|
type: DataTypes.BOOLEAN,
|
|
allowNull: false,
|
|
defaultValue: true,
|
|
comment: 'User preference for receiving email notifications'
|
|
});
|
|
|
|
await queryInterface.addColumn('users', 'push_notifications_enabled', {
|
|
type: DataTypes.BOOLEAN,
|
|
allowNull: false,
|
|
defaultValue: true,
|
|
comment: 'User preference for receiving push notifications'
|
|
});
|
|
|
|
await queryInterface.addColumn('users', 'in_app_notifications_enabled', {
|
|
type: DataTypes.BOOLEAN,
|
|
allowNull: false,
|
|
defaultValue: true,
|
|
comment: 'User preference for receiving in-app notifications'
|
|
});
|
|
|
|
// Add indexes for faster queries
|
|
await queryInterface.addIndex('users', ['email_notifications_enabled'], {
|
|
name: 'idx_users_email_notifications_enabled'
|
|
});
|
|
|
|
await queryInterface.addIndex('users', ['push_notifications_enabled'], {
|
|
name: 'idx_users_push_notifications_enabled'
|
|
});
|
|
|
|
await queryInterface.addIndex('users', ['in_app_notifications_enabled'], {
|
|
name: 'idx_users_in_app_notifications_enabled'
|
|
});
|
|
},
|
|
|
|
async down(queryInterface: QueryInterface): Promise<void> {
|
|
// Remove indexes first
|
|
await queryInterface.removeIndex('users', 'idx_users_in_app_notifications_enabled');
|
|
await queryInterface.removeIndex('users', 'idx_users_push_notifications_enabled');
|
|
await queryInterface.removeIndex('users', 'idx_users_email_notifications_enabled');
|
|
|
|
// Remove columns
|
|
await queryInterface.removeColumn('users', 'in_app_notifications_enabled');
|
|
await queryInterface.removeColumn('users', 'push_notifications_enabled');
|
|
await queryInterface.removeColumn('users', 'email_notifications_enabled');
|
|
}
|
|
};
|
|
|