You are here

function metatag_update_7003 in Metatag 7

Add the {metatag}.language field.

File

./metatag.install, line 906
Install, update, and uninstall functions for the metatag module.

Code

function metatag_update_7003() {

  // Set the target table and field name.
  $table_name = 'metatag';
  $field_name = 'language';

  // Don't add the new field if it already exists.
  if (!db_field_exists($table_name, $field_name)) {

    // Describe the new field.
    $field_spec = array(
      'type' => 'varchar',
      'length' => 32,
      'not null' => TRUE,
      'default' => '',
      'description' => 'The language of the tag',
    );

    // Add it and update the primary key.
    db_add_field($table_name, $field_name, $field_spec);
    db_drop_primary_key($table_name);
    db_add_primary_key($table_name, array(
      'entity_type',
      'entity_id',
      'language',
    ));
  }
}