You are here

function drupalchat_schema in DrupalChat 7.2

Same name and namespace in other branches
  1. 8 drupalchat.install \drupalchat_schema()
  2. 6.2 drupalchat.install \drupalchat_schema()
  3. 6 drupalchat.install \drupalchat_schema()
  4. 7 drupalchat.install \drupalchat_schema()

Implements hook_schema().

File

./drupalchat.install, line 42
Installation file for the DrupalChat module.

Code

function drupalchat_schema() {
  $schema = array();
  $schema['drupalchat_msg'] = array(
    'fields' => 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;
}