You are here

function emapi_update_6302 in Embedded Media Field 6.3

Build a table to store media.

File

emapi/emapi.install, line 123
This is Embedded Media API's installation, configuration, and removal file.

Code

function emapi_update_6302() {
  $schema = array();
  $schema['emapi_media'] = array(
    'description' => 'Stores Embedded Media info.',
    'fields' => array(
      'emid' => array(
        'description' => 'The unique ID of the media.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uri' => array(
        'description' => 'Unique URI for the media.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The {users}.uid of the user who is associated with the media.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'A bitmapped field indicating the status of the media. The least significant bit indicates temporary (0) or permanent (1). Temporary media older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'timestamp' => array(
        'description' => 'UNIX timestamp for when the media was added.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
      'status' => array(
        'status',
      ),
      'timestamp' => array(
        'timestamp',
      ),
    ),
    'unique keys' => array(
      'uri' => array(
        'uri',
      ),
    ),
    'primary key' => array(
      'emid',
    ),
    'foreign keys' => array(
      'uid' => array(
        'users' => 'uid',
      ),
    ),
  );
  $ret = array();
  if (!db_table_exists('emapi_media')) {
    db_create_table($ret, 'emapi_media', $schema['emapi_media']);
  }
  return $ret;
}