You are here

function workflow_schema in Workflow 7.2

Same name and namespace in other branches
  1. 8 workflow.install \workflow_schema()
  2. 6.2 workflow.install \workflow_schema()
  3. 6 workflow.install \workflow_schema()
  4. 7 workflow.install \workflow_schema()

Implements hook_schema().

2 calls to workflow_schema()
workflow_update_7007 in ./workflow.install
Convert roles to entity-like arrays.
workflow_update_7015 in ./workflow.install
Add database fields. Make Workflow entity-aware, exportable.

File

./workflow.install, line 87
Install, update and uninstall functions for the workflow module.

Code

function workflow_schema() {
  $schema['workflows'] = array(
    'description' => 'Workflows',
    'fields' => array(
      'wid' => array(
        'description' => 'The primary identifier for a workflow.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The machine-readable name of this workflow.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'label' => array(
        'description' => 'The human-readable name of this workflow.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'translatable' => TRUE,
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // Set the default to ENTITY_CUSTOM without using the constant as it is
        // not safe to use it at this point.
        '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,
      ),
      'tab_roles' => array(
        'description' => 'The role IDs that can access the workflow tabs on node pages.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
        'serialize' => TRUE,
      ),
      'options' => array(
        'description' => 'Additional settings for the workflow.',
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'wid',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
  );
  $schema['workflow_type_map'] = array(
    'fields' => array(
      'type' => array(
        'description' => 'The {node_type}.type the workflow is used on.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'wid' => array(
        'description' => 'The {workflows}.wid this record affects.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
    ),
    'indexes' => array(
      'type' => array(
        'type',
        'wid',
      ),
    ),
  );
  $schema['workflow_transitions'] = array(
    'fields' => array(
      'tid' => array(
        'description' => 'The primary identifier for a workflow transition.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The machine-readable name of this transition.',
        'type' => 'varchar',
        'length' => '32',
        // 'not null' => TRUE,
        'default' => '',
      ),
      'label' => array(
        'description' => 'The human-readable name of this transition.',
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'default' => '',
        'translatable' => TRUE,
      ),
      'sid' => array(
        'description' => 'The {workflow_states}.sid start state.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'target_sid' => array(
        'description' => 'The {workflow_states}.sid target state.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'roles' => array(
        'description' => 'The {role}.sid that a user must have to perform transition.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'tid',
    ),
    'indexes' => array(
      'sid' => array(
        'sid',
      ),
      'target_sid' => array(
        'target_sid',
      ),
    ),
  );
  $schema['workflow_states'] = array(
    'fields' => array(
      'sid' => array(
        'description' => 'The primary identifier for a workflow state.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'wid' => array(
        'description' => 'The {workflows}.wid this state is part of.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'name' => array(
        'description' => 'The machine-readable name of this state.',
        'type' => 'varchar',
        'length' => '255',
        // 'not null' => TRUE,
        'default' => '',
      ),
      'state' => array(
        'description' => 'The human-readable name of this state.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
        'translatable' => TRUE,
      ),
      'weight' => array(
        'description' => 'The weight (order) of the state.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '4',
      ),
      'sysid' => array(
        'description' => 'The type of state, usually either WORKFLOW_CREATION or empty.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '4',
      ),
      'status' => array(
        'description' => 'Whether the current state is active still.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
        'disp-width' => '4',
      ),
    ),
    'primary key' => array(
      'sid',
    ),
    'indexes' => array(
      'sysid' => array(
        'sysid',
      ),
      'wid' => array(
        'wid',
      ),
    ),
  );
  $schema['workflow_scheduled_transition'] = array(
    'fields' => array(
      'tid' => array(
        'description' => 'The unique ID for this record.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'entity_type' => array(
        'description' => 'The type of entity this transition belongs to.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'nid' => array(
        'description' => 'The entity ID of the object this transition belongs to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'field_name' => array(
        'description' => 'The name of the field the transition relates to.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'language' => array(
        'description' => 'The {languages}.language of the entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'delta' => array(
        'description' => 'The sequence number for this data item, used for multi-value fields',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'old_sid' => array(
        'description' => 'The {workflow_states}.sid this state starts at.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'sid' => array(
        'description' => 'The {workflow_states}.sid this state transitions to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'uid' => array(
        'description' => 'The user who scheduled this state transition.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'scheduled' => array(
        'description' => 'The date this transition is scheduled for.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'comment' => array(
        'description' => 'The comment explaining this transition.',
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'tid',
    ),
    'indexes' => array(
      'entity_type' => array(
        'entity_type',
      ),
      'entity_id' => array(
        'entity_type',
        'nid',
      ),
    ),
  );
  $schema['workflow_node_history'] = array(
    'fields' => array(
      'hid' => array(
        'description' => 'The unique ID for this record.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'entity_type' => array(
        'description' => 'The type of entity this transition belongs to.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'nid' => array(
        'description' => 'The {node}.nid this record is for.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'revision_id' => array(
        'description' => 'The current version identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'field_name' => array(
        'description' => 'The name of the field the transition relates to.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'language' => array(
        'description' => 'The {languages}.language of the entity.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'delta' => array(
        'description' => 'The sequence number for this data item, used for multi-value fields',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'old_sid' => array(
        'description' => 'The {workflow_states}.sid this transition started as.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'sid' => array(
        'description' => 'The {workflow_states}.sid this transition transitioned to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'uid' => array(
        'description' => 'The {users}.uid who made this transition.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'stamp' => array(
        'description' => 'The unique stamp for this transition.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'comment' => array(
        'description' => 'The comment explaining this transition.',
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'hid',
    ),
    'indexes' => array(
      'sid' => array(
        'entity_type',
        'nid',
        'sid',
      ),
      'nid' => array(
        'nid',
      ),
    ),
  );
  $schema['workflow_node'] = array(
    'fields' => array(
      'nid' => array(
        'description' => 'The {node}.nid this record is for.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'sid' => array(
        'description' => 'The {workflow_states}.sid that this node is currently in.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'uid' => array(
        'description' => 'The {users}.uid who triggered this state.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '10',
      ),
      'stamp' => array(
        'description' => 'The unique stamp for the transition.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '11',
      ),
    ),
    'primary key' => array(
      'nid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
        'sid',
      ),
    ),
  );
  return $schema;
}