You are here

brightcove_field.install in Brightcove Video Connect 7.2

File

brightcove_field/brightcove_field.install
View source
<?php

/**
 * Implements hook_field_schema().
 */
function brightcove_field_field_schema() {
  return array(
    'columns' => array(
      'video_id' => array(
        'type' => 'varchar',
        'length' => 15,
        'not null' => FALSE,
      ),
      'player' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'indexes' => array(
      'video_id' => array(
        'video_id',
      ),
    ),
  );
}

/**
 * Updates the schema of the brightcove field if possible.
 */
function brightcove_field_update_7201() {
  if (module_exists('field_sql_storage')) {
    $coldef = array(
      'type' => 'varchar',
      'length' => 255,
      'not null' => FALSE,
    );
    foreach (field_info_fields() as $name => $def) {
      if ($def['type'] == 'brightcove_video' && $def['storage']['type'] == 'field_sql_storage') {
        $tablename = _field_sql_storage_tablename($def);
        $revtablename = _field_sql_storage_revision_tablename($def);
        $playercol = _field_sql_storage_columnname($name, 'player');
        db_add_field($tablename, $playercol, $coldef);
        db_add_field($revtablename, $playercol, $coldef);
      }
    }
    db_delete('cache_field')
      ->execute();
  }
}

Functions

Namesort descending Description
brightcove_field_field_schema Implements hook_field_schema().
brightcove_field_update_7201 Updates the schema of the brightcove field if possible.