You are here

function fb_schema in Drupal for Facebook 7.4

1 call to fb_schema()
fb_update_7402 in ./fb.install
Facebook application namespace is optional. Allow null in fb_application.namespace database schema.

File

./fb.install, line 12

Code

function fb_schema() {

  // TODO: add expires to fb_token, and keep track of it.
  $schema['fb_token'] = array(
    'description' => 'Access Tokens used for facebook integration.',
    'fields' => array(
      'fba' => array(
        'type' => 'int',
        'size' => 'big',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Facebook\'s application ID',
      ),
      'fbu' => array(
        'type' => 'int',
        'size' => 'big',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Facebook\'s user ID',
      ),
      'access_token' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'The token itself.',
      ),
      'status' => array(
        'description' => 'Bit flags indicate properties of this token.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the token was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        // TODO: change to sdata like fb_application table
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
        'default' => NULL,
        'serialize' => TRUE,
        'description' => 'Additional properties as serialized data.',
      ),
    ),
    'primary key' => array(
      'fba',
      'fbu',
    ),
    'unique keys' => array(
      'access_token' => array(
        'access_token',
      ),
    ),
    'indexes' => array(
      'fba_status' => array(
        'fba',
        'status',
      ),
    ),
  );
  $schema['fb_application'] = array(
    'description' => 'Facebook applications.',
    'fields' => array(
      'fba' => array(
        'type' => 'int',
        'size' => 'big',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Facebook\'s application ID',
      ),
      'secret' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => 'Copied and pasted from facebook admin pages.  Only for locally hosted applications.',
      ),
      'status' => array(
        'description' => 'Bit flags indicate properties of this app.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'namespace' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
        'description' => 'We learn this from facebook app properties',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'We learn this from facebook app properties',
      ),
      'sdata' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
        'default' => NULL,
        'serialize' => TRUE,
        'description' => 'Additional properties as serialized data.',
      ),
    ),
    'unique keys' => array(
      'namespace' => array(
        'namespace',
      ),
    ),
    'primary key' => array(
      'fba',
    ),
  );

  // Cache for data learned from facebook graph api.
  $schema['cache_fb'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_fb']['description'] = 'Cache of data learned from facebook\'s graph API.';
  return $schema;
}