array( 'message_id' => array( 'type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'description' => 'ID of chat message.', ), 'uid1' => array( 'description' => 'Uid of the sender.', 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, ), 'uid2' => array( 'description' => 'Uid of the receiver.', 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, ), 'message' => array( 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'description' => 'Chat message.', ), 'timestamp' => array( 'description' => 'The Unix timestamp when the XMPP account was created.', 'type' => 'int', 'not null' => TRUE, 'unsigned' => TRUE, ), ), 'indexes' => array( 'uid1' => array('uid1'), 'uid2' => array('uid2'), ), ); $schema['drupalchat_users'] = array( 'fields' => array( 'uid' => array( 'description' => 'The user uid.', 'type' => 'int', 'not null' => TRUE, 'unsigned' => TRUE, ), 'session' => array( 'description' => 'Current session id.', 'type' => 'varchar', 'length' => 60, 'not null' => TRUE, ), 'name' => array( 'description' => 'Name of the user.', 'type' => 'varchar', 'length' => 60, 'not null' => TRUE, ), 'status' => array( 'description' => 'Unix timestamp of last activity.', 'type' => 'int', 'not null' => TRUE, 'unsigned' => TRUE, 'default' => 0, 'size' => 'tiny', ), 'timestamp' => array( 'description' => 'Unix timestamp of last activity.', 'type' => 'int', 'not null' => TRUE, 'unsigned' => TRUE, ), ), 'primary key' => array('uid', 'session'), 'indexes' => array( 'uid' => array('uid'), 'session' => array('session'), 'timestamp' => array('timestamp'), ), ); return $schema; } function drupalchat_update_7000() { db_drop_index('drupalchat_msg','uid1'); db_drop_index('drupalchat_msg','uid2'); db_drop_primary_key('drupalchat_users'); db_change_field('drupalchat_msg', 'uid1', 'uid1', array( 'description' => 'Uid of the sender.', 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, )); db_change_field('drupalchat_msg', 'uid2', 'uid2', array( 'description' => 'Uid of the receiver.', 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, )); if (!db_index_exists('drupalchat_msg','uid1')) { db_add_index('drupalchat_msg','uid1',array('uid1')); } if (!db_index_exists('drupalchat_msg','uid2')) { db_add_index('drupalchat_msg','uid2',array('uid2')); } if (!db_index_exists('drupalchat_users','uid')) { db_add_index('drupalchat_users','uid',array('uid')); } if (!db_index_exists('drupalchat_users','session')) { db_add_index('drupalchat_users','session',array('session')); } } function drupalchat_update_7001() { if(!db_field_exists('drupalchat_msg', 'message_id')) { db_add_field('drupalchat_msg', 'message_id', array( 'type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'description' => 'ID of chat message.', )); } }