You are here

function _profile2_revision_table in Profile 2 7.2

Define the {profile_revision} table.

Put it in a separate function in order to guarantee that we use the same definition in hook_schema() and hook_update_N().

2 calls to _profile2_revision_table()
profile2_schema in ./profile2.install
Implements hook_schema().
profile2_update_7105 in ./profile2.install
Add revisioning support.

File

./profile2.install, line 201
Install, update and uninstall functions for the profile module.

Code

function _profile2_revision_table() {
  $profile_revision = array(
    'description' => 'Stores information about each saved version of a {profile}.',
    'fields' => array(
      'pid' => array(
        'description' => 'The {profile} this version belongs to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'vid' => array(
        'description' => 'Primary Key: Unique identifier of this version.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'authorid' => array(
        'description' => 'The {users}.uid that created this version.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'label' => array(
        'description' => 'A human-readable label for this profile.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'log' => array(
        'description' => 'The log entry explaining the changes in this version.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
      'timestamp' => array(
        'description' => 'A Unix timestamp indicating when this version was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'pid' => array(
        'pid',
      ),
      'authorid' => array(
        'authorid',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'foreign keys' => array(
      'versioned_profile' => array(
        'table' => 'profile',
        'columns' => array(
          'pid' => 'pid',
        ),
      ),
      'version_uid' => array(
        'table' => 'users',
        'columns' => array(
          'authorid' => 'uid',
        ),
      ),
    ),
  );
  return $profile_revision;
}