You are here

function og_schema_7001_info in Organic groups 7.2

Return the schema for upgrade 7001.

1 call to og_schema_7001_info()
og_update_7001 in ./og.install
Add group membership entities instead of field data.

File

./og.install, line 650
Install, update, and uninstall functions for the Organic groups module.

Code

function og_schema_7001_info() {
  $schema = array();
  $schema['og_membership_type'] = array(
    'description' => 'The group membership type.',
    'fields' => array(
      // Although the "name" should be enough as the primary key, the numeric ID
      // is required for the internal use of entity API.
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Numeric group membership type ID.',
      ),
      'name' => array(
        'description' => 'The unified identifier for a group membership type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'Description for this group membership type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // This is equivilent to ENTITY_CUSTOM.
        'default' => 0x1,
        'size' => 'tiny',
        'description' => 'The exportable status of the entity.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
  );
  $schema['og_membership'] = array(
    'description' => 'The group membership table.',
    'fields' => array(
      'id' => array(
        'description' => "The group membership's unique ID.",
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'Reference to a group membership type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'etid' => array(
        'description' => "The entity ID.",
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'entity_type' => array(
        'description' => "The entity type (e.g. node, comment, etc').",
        'type' => 'varchar',
        'length' => '32',
        'not null' => TRUE,
        'default' => '',
      ),
      'gid' => array(
        'description' => "The group's unique ID.",
        'type' => 'int',
        'size' => 'normal',
        'not null' => TRUE,
      ),
      'state' => array(
        'description' => 'The state of the group content.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the group content was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      // Entity index; When searching for an entity, we use both the id and type.
      'entity' => array(
        'etid',
        'entity_type',
      ),
      'gid' => array(
        'gid',
      ),
    ),
    'foreign keys' => array(
      'og_membership_type' => array(
        'table' => 'og_membership_type',
        'columns' => array(
          'name' => 'name',
        ),
      ),
      'group' => array(
        'table' => 'og',
        'columns' => array(
          'gid' => 'gid',
        ),
      ),
    ),
  );
  return $schema;
}