You are here

function entity_translation_update_7006 in Entity Translation 7

Add revision schema for entity translation metadata.

File

./entity_translation.install, line 353
Installation functions for Entity Translation module.

Code

function entity_translation_update_7006() {

  // Create revision id column.
  $spec = array(
    'type' => 'int',
    'unsigned' => TRUE,
    // If we have existing data we cannot enforce this to be NOT NULL.
    'not null' => FALSE,
    'description' => 'The entity revision id this translation relates to',
  );

  // Create revision id column if it doesn't exist already.
  if (!db_field_exists('entity_translation', 'revision_id')) {
    db_add_field('entity_translation', 'revision_id', $spec);
  }

  // Create the entity translation revision schema.
  $table = array(
    'description' => 'Table to track entity translation revisions',
    'fields' => array(
      'entity_type' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The entity type this translation revision relates to',
      ),
      'entity_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The entity id this translation revision relates to',
      ),
      'revision_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The entity revision id this translation relates to',
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The target language for this translation revision.',
      ),
      'source' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The source language from which this translation revision was created.',
      ),
      'uid' => array(
        'description' => 'The author of this translation revision.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'Boolean indicating whether the translation revision is published (visible to non-administrators).',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'translate' => array(
        'description' => 'A boolean indicating whether this translation revision needs to be updated.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the translation revision was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the translation revision was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'entity_type',
      'revision_id',
      'language',
    ),
    'indexes' => array(
      'revision_id' => array(
        'revision_id',
      ),
    ),
  );

  // Create entity translation revision table if it doesn't exist already.
  if (!db_table_exists('entity_translation_revision')) {
    db_create_table('entity_translation_revision', $table);
  }
}