You are here

function media_youtube_update_6009 in Media: YouTube 6

Add metadata tables.

File

./media_youtube.install, line 88
This is Media: YouTube's installation, configuration, and removal file.

Code

function media_youtube_update_6009() {
  $ret = array();
  $schema = array();
  $schema['media_youtube_metadata'] = array(
    'description' => 'Media: YouTube table for video metadata.',
    'fields' => array(
      'value' => array(
        'description' => 'The identifier for a YouTube video.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'status' => array(
        'description' => "The availability status of this media.",
        'type' => 'int',
        'unsigned' => 'TRUE',
        'not null' => TRUE,
        'default' => EMFIELD_STATUS_AVAILABLE,
      ),
      'last_touched' => array(
        'description' => "Timestamp when the data was last retrieved from YouTube.",
        'type' => 'int',
        'unsigned' => 'TRUE',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'status' => array(
        'status',
      ),
      'last_touched' => array(
        'last_touched',
      ),
    ),
    'primary key' => array(
      'value',
    ),
  );
  $schema['media_youtube_node_data'] = array(
    'description' => 'Media: YouTube table for video node reference.',
    'fields' => array(
      'value' => array(
        'description' => 'The identifier for a YouTube video.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => 'The {node} nid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'field_name' => array(
        'description' => 'The node field storing this data.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'delta' => array(
        'description' => "The field delta.",
        'type' => 'int',
        'unsigned' => 'TRUE',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'value' => array(
        'value',
      ),
      'nid' => array(
        'nid',
      ),
      'field_name' => array(
        'field_name',
      ),
      'delta' => array(
        'delta',
      ),
    ),
  );
  if (!db_table_exists('media_youtube_metadata')) {
    db_create_table($ret, 'media_youtube_metadata', $schema['media_youtube_metadata']);
  }
  if (!db_table_exists('media_youtube_node_data')) {
    db_create_table($ret, 'media_youtube_node_data', $schema['media_youtube_node_data']);
  }

  // We need to rebuild the metadata, but we'll do that in 6012 now, because
  // our schema will have changed by then.
  return $ret;
}