module.exports = {
    /**
     * @param {QueryInterface} queryInterface
     * @param {Sequelize} Sequelize
     * @returns {Promise<void>}
     */
    async up(queryInterface, Sequelize) {
        /**
         * @type {Transaction}
         */
        const transaction = await queryInterface.sequelize.transaction();
        try {
            
                
                    await queryInterface.createTable('users', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('roles', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('permissions', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('accounts', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('patients', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('patient_access_grants', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('medications', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('medication_schedules', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('calendar_events', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('reminders', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('cognitive_programs', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('cognitive_exercises', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('cognitive_sessions', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('cognitive_attempts', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('stage_assessments', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('voice_assistant_sessions', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('iot_devices', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('iot_telemetry_events', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('geofences', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('alerts', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('alert_notifications', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('shared_dashboard_posts', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('scientific_articles', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('article_recommendations', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('clinical_reports', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    await queryInterface.createTable('admin_metrics_snapshots', {
                        id: {
                            type: Sequelize.DataTypes.UUID,
                            defaultValue: Sequelize.DataTypes.UUIDV4,
                            primaryKey: true,
                        },
                        createdById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        updatedById: {
                            type: Sequelize.DataTypes.UUID,
                            references: {
                                key: 'id',
                                model: 'users',
                            },
                        },
                        createdAt: { type: Sequelize.DataTypes.DATE },
                        updatedAt: { type: Sequelize.DataTypes.DATE },
                        deletedAt: { type: Sequelize.DataTypes.DATE },
                        importHash: {
                            type: Sequelize.DataTypes.STRING(255),
                            allowNull: true,
                          unique: true, 
                        },
                    }, { transaction });
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'firstName',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'lastName',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'phoneNumber',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'email',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'disabled',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'password',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'emailVerified',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'emailVerificationToken',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'emailVerificationTokenExpiresAt',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'passwordResetToken',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'passwordResetTokenExpiresAt',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'provider',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'app_roleId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'roles',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'users',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'roles',
                      'name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'roles',
                      'role_customization',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'roles',
                      'globalAccess',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'permissions',
                      'name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'accounts',
                      'name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'patient_code',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'first_name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'last_name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'date_of_birth',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'sex',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['female','male','other','unknown'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'disease_stage',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['mild','moderate','severe','unknown'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'diagnosis_date',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'medical_notes',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'accountId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patients',
                      'primary_physicianId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'access_level',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['view','edit','clinician','owner'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'can_view_iot_location',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'can_manage_medications',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'can_manage_calendar',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'can_view_health_data',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'granted_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'revoked_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'patient_access_grants',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'medication_name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'dosage',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'route',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'instructions',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'start_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'end_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'is_active',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'prescribed_byId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medications',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'medicationId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'medications',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'frequency_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['daily','weekly','custom'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'time_of_day',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'days_of_week',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'effective_from',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'effective_until',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'requires_confirmation',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'medication_schedules',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'created_by_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'event_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['medication','appointment','cognitive_session','care_task','family_note','other'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'title_text',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'description',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'start_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'end_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'location_text',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'status',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['scheduled','completed','cancelled'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'has_reminder',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'reminder_minutes_before',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'linked_medicationId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'medications',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'calendar_events',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'eventId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'calendar_events',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'channel',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['push','sms','email','voice'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'scheduled_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'state',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['pending','sent','failed','cancelled'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'message',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'recipient_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'reminders',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_programs',
                      'program_name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_programs',
                      'description',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_programs',
                      'target_stage',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['mild','moderate','severe','all'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_programs',
                      'status',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['draft','published','archived'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_programs',
                      'estimated_minutes',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_programs',
                      'created_by_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_programs',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'programId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'cognitive_programs',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'exercise_name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'exercise_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['memory','attention','language','orientation','executive_function'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'instructions',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'difficulty_level',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['easy','medium','hard','adaptive'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'max_score',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'is_active',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_exercises',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'programId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'cognitive_programs',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'started_by_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'started_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'ended_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'completion_status',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['in_progress','completed','abandoned'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'total_score',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'session_notes',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_sessions',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'sessionId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'cognitive_sessions',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'exerciseId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'cognitive_exercises',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'attempted_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'score',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'accuracy',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'duration_seconds',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'result',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['success','partial','failed'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'raw_response',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'cognitive_attempts',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'assessed_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'predicted_stage',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['mild','moderate','severe','unknown'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'confidence_score',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'method',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['questionnaire','cognitive_model','clinician','hybrid'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'model_version',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'explanation',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'reviewed_by_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'stage_assessments',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'initiated_by_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'started_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'ended_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'channel',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['mobile','web','smart_speaker'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'transcript',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'assistant_summary',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'outcome',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['info','reminder_created','alert_created','handoff_to_caregiver','other'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'voice_assistant_sessions',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'device_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['gps_bracelet','phone','beacon','other'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'device_label',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'serial_number',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'status',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['active','inactive','lost','maintenance'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'paired_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'last_seen_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'battery_level',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'firmware_version',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_devices',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'deviceId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'iot_devices',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'recorded_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'latitude',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'longitude',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'speed',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'accuracy_meters',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'battery_level',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'event_kind',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['location_update','geofence_enter','geofence_exit','panic','fall_suspected','device_offline'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'iot_telemetry_events',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'geofence_name',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'shape_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['circle','polygon'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'center_latitude',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'center_longitude',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'radius_meters',
                      {
                          type: Sequelize.DataTypes.DECIMAL,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'polygon_points',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'is_active',
                      {
                          type: Sequelize.DataTypes.BOOLEAN,
                          
                            defaultValue: false,
                            allowNull: false,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'alert_on',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['enter','exit','enter_or_exit'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'geofences',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'deviceId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'iot_devices',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'trigger_eventId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'iot_telemetry_events',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'alert_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['wandering','geofence_breach','panic','fall_suspected','missed_medication','device_offline','other'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'severity',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['low','medium','high','critical'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'title_text',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'details',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'triggered_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'status',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['open','acknowledged','resolved','dismissed'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'acknowledged_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'resolved_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'assigned_to_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alerts',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alert_notifications',
                      'alertId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'alerts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alert_notifications',
                      'recipient_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alert_notifications',
                      'channel',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['push','sms','email','voice'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alert_notifications',
                      'sent_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alert_notifications',
                      'delivery_status',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['pending','sent','delivered','failed'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alert_notifications',
                      'provider_message_id',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'alert_notifications',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'author_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'post_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['update','question','note','photo','document'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'title_text',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'content',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'posted_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'visibility',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['family_only','care_team','all_authorized'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'shared_dashboard_posts',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'title_text',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'abstract_text',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'journal',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'published_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'doi',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'url',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'keywords',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'validation_status',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['pending','validated','rejected'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'validated_by_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'validation_notes',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'scientific_articles',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'article_recommendations',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'article_recommendations',
                      'articleId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'scientific_articles',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'article_recommendations',
                      'recommended_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'article_recommendations',
                      'reason_type',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['stage_based','symptom_based','caregiver_interest','clinician_selected','trending'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'article_recommendations',
                      'reason_text',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'article_recommendations',
                      'state',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['new','viewed','saved','dismissed'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'article_recommendations',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'patientId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'patients',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'generated_by_userId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'users',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'period_start_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'period_end_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'report_title',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'summary',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'share_scope',
                      {
                          type: Sequelize.DataTypes.ENUM,
                          
                          
                            values: ['family','clinicians','admin'],
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'clinical_reports',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'snapshot_at',
                      {
                          type: Sequelize.DataTypes.DATE,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'total_accounts',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'total_users',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'total_patients',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'active_devices',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'alerts_last_24h',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'cognitive_sessions_last_7d',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'reminders_sent_last_24h',
                      {
                          type: Sequelize.DataTypes.INTEGER,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'notes',
                      {
                          type: Sequelize.DataTypes.TEXT,
                          
                          
                          
                      },
                      { transaction }
                    );
                
            
                
                    
                    await queryInterface.addColumn(
                      'admin_metrics_snapshots',
                      'accountsId',
                      {
                          type: Sequelize.DataTypes.UUID,
                          
                          
                          
                            references: {
                                model: 'accounts',
                                key: 'id',
                            },
                          
                      },
                      { transaction }
                    );
                
            
            
            
            await transaction.commit();
        } catch (err) {
            await transaction.rollback();
            throw err;
        }
    },
    /**
     * @param {QueryInterface} queryInterface
     * @param {Sequelize} Sequelize
     * @returns {Promise<void>}
     */
    async down(queryInterface, Sequelize) {
        /**
         * @type {Transaction}
         */
        const transaction = await queryInterface.sequelize.transaction();
        try {
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'notes',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'reminders_sent_last_24h',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'cognitive_sessions_last_7d',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'alerts_last_24h',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'active_devices',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'total_patients',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'total_users',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'total_accounts',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'admin_metrics_snapshots',
                        'snapshot_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'share_scope',
                        { transaction }
                    );
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'summary',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'report_title',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'period_end_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'period_start_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'generated_by_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'clinical_reports',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'article_recommendations',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'article_recommendations',
                        'state',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'article_recommendations',
                        'reason_text',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'article_recommendations',
                        'reason_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'article_recommendations',
                        'recommended_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'article_recommendations',
                        'articleId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'article_recommendations',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'accountsId',
                        { transaction }
                    );
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'validation_notes',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'validated_by_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'validation_status',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'keywords',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'url',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'doi',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'published_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'journal',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'abstract_text',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'scientific_articles',
                        'title_text',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'visibility',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'posted_at',
                        { transaction }
                    );
                
            
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'content',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'title_text',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'post_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'author_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'shared_dashboard_posts',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alert_notifications',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alert_notifications',
                        'provider_message_id',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alert_notifications',
                        'delivery_status',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alert_notifications',
                        'sent_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alert_notifications',
                        'channel',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alert_notifications',
                        'recipient_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alert_notifications',
                        'alertId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'assigned_to_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'resolved_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'acknowledged_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'status',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'triggered_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'details',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'title_text',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'severity',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'alert_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'trigger_eventId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'deviceId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'alerts',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'alert_on',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'is_active',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'polygon_points',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'radius_meters',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'center_longitude',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'center_latitude',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'shape_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'geofence_name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'geofences',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'event_kind',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'battery_level',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'accuracy_meters',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'speed',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'longitude',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'latitude',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'recorded_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_telemetry_events',
                        'deviceId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'firmware_version',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'battery_level',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'last_seen_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'paired_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'status',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'serial_number',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'device_label',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'device_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'iot_devices',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'outcome',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'assistant_summary',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'transcript',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'channel',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'ended_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'started_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'initiated_by_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'voice_assistant_sessions',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'reviewed_by_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'explanation',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'model_version',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'method',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'confidence_score',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'predicted_stage',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'assessed_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'stage_assessments',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'raw_response',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'result',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'duration_seconds',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'accuracy',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'score',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'attempted_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'exerciseId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_attempts',
                        'sessionId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'session_notes',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'total_score',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'completion_status',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'ended_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'started_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'started_by_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'programId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_sessions',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'is_active',
                        { transaction }
                    );
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'max_score',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'difficulty_level',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'instructions',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'exercise_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'exercise_name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_exercises',
                        'programId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_programs',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_programs',
                        'created_by_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_programs',
                        'estimated_minutes',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_programs',
                        'status',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_programs',
                        'target_stage',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_programs',
                        'description',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'cognitive_programs',
                        'program_name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'recipient_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'message',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'state',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'scheduled_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'channel',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'eventId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'reminders',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'linked_medicationId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'reminder_minutes_before',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'has_reminder',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'status',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'location_text',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'end_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'start_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'description',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'title_text',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'event_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'created_by_userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'calendar_events',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'requires_confirmation',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'effective_until',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'effective_from',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'days_of_week',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'time_of_day',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'frequency_type',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medication_schedules',
                        'medicationId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'prescribed_byId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'is_active',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'end_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'start_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'instructions',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'route',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'dosage',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'medication_name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'medications',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'accountsId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'revoked_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'granted_at',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'can_view_health_data',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'can_manage_calendar',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'can_manage_medications',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'can_view_iot_location',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'access_level',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'userId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patient_access_grants',
                        'patientId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'primary_physicianId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'accountId',
                        { transaction }
                    );
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'medical_notes',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'diagnosis_date',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'disease_stage',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'sex',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'date_of_birth',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'last_name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'first_name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'patients',
                        'patient_code',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'accounts',
                        'name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'permissions',
                        'name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'roles',
                        'globalAccess',
                        { transaction }
                    );
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'roles',
                        'role_customization',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'roles',
                        'name',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'accountsId',
                        { transaction }
                    );
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'app_roleId',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'provider',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'passwordResetTokenExpiresAt',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'passwordResetToken',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'emailVerificationTokenExpiresAt',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'emailVerificationToken',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'emailVerified',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'password',
                        { transaction }
                    );
                
            
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'disabled',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'email',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'phoneNumber',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'lastName',
                        { transaction }
                    );
                
            
                
                    await queryInterface.removeColumn(
                        'users',
                        'firstName',
                        { transaction }
                    );
                
            
                
                    await queryInterface.dropTable('admin_metrics_snapshots', { transaction });
                
            
                
                    await queryInterface.dropTable('clinical_reports', { transaction });
                
            
                
                    await queryInterface.dropTable('article_recommendations', { transaction });
                
            
                
                    await queryInterface.dropTable('scientific_articles', { transaction });
                
            
                
                    await queryInterface.dropTable('shared_dashboard_posts', { transaction });
                
            
                
                    await queryInterface.dropTable('alert_notifications', { transaction });
                
            
                
                    await queryInterface.dropTable('alerts', { transaction });
                
            
                
                    await queryInterface.dropTable('geofences', { transaction });
                
            
                
                    await queryInterface.dropTable('iot_telemetry_events', { transaction });
                
            
                
                    await queryInterface.dropTable('iot_devices', { transaction });
                
            
                
                    await queryInterface.dropTable('voice_assistant_sessions', { transaction });
                
            
                
                    await queryInterface.dropTable('stage_assessments', { transaction });
                
            
                
                    await queryInterface.dropTable('cognitive_attempts', { transaction });
                
            
                
                    await queryInterface.dropTable('cognitive_sessions', { transaction });
                
            
                
                    await queryInterface.dropTable('cognitive_exercises', { transaction });
                
            
                
                    await queryInterface.dropTable('cognitive_programs', { transaction });
                
            
                
                    await queryInterface.dropTable('reminders', { transaction });
                
            
                
                    await queryInterface.dropTable('calendar_events', { transaction });
                
            
                
                    await queryInterface.dropTable('medication_schedules', { transaction });
                
            
                
                    await queryInterface.dropTable('medications', { transaction });
                
            
                
                    await queryInterface.dropTable('patient_access_grants', { transaction });
                
            
                
                    await queryInterface.dropTable('patients', { transaction });
                
            
                
                    await queryInterface.dropTable('accounts', { transaction });
                
            
                
                    await queryInterface.dropTable('permissions', { transaction });
                
            
                
                    await queryInterface.dropTable('roles', { transaction });
                
            
                
                    await queryInterface.dropTable('users', { transaction });
                
            
            await transaction.commit();
        } catch (err) {
            await transaction.rollback();
            throw err;
        }
    }
};
