You are here

state_flow.install in State Machine 7.2

Install file for the State Flow module.

File

modules/state_flow/state_flow.install
View source
<?php

/**
 * @file
 * Install file for the State Flow module.
 */

/**
 * Implements hook_install().
 */
function state_flow_install() {
  $result = db_update('system')
    ->fields(array(
    'weight' => 5,
  ))
    ->condition('name', 'state_flow')
    ->execute();
}

/**
 * Implements hook_schema().
 */
function state_flow_schema() {
  $schema['node_revision_states'] = array(
    'description' => 'Saves the current live vid of a node',
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'state' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
      'status' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null',
        TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
  );
  $schema['node_revision_states_history'] = array(
    'description' => 'Saves the state history of a node revision.',
    'fields' => array(
      'nrshid' => array(
        'description' => 'The primary identifier for this record.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'state' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
      'timestamp' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null',
        TRUE,
        'default' => 0,
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'log' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
      ),
    ),
    'primary key' => array(
      'nrshid',
    ),
    'indexes' => array(
      'vid' => array(
        'vid',
      ),
      'nid' => array(
        'nid',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_update_N().
 *
 * Create a new node_revision_states_history table to track state changes. Also,
 * add an index for 'nid' to the node_revision_states table.
 */
function state_flow_update_7001() {
  $new_table = drupal_get_schema_unprocessed('state_flow', 'node_revision_states_history');
  db_create_table('node_revision_states_history', $new_table);
  db_add_index('node_revision_states', 'nid', array(
    'nid',
  ));
  return t('Created a new {node_revision_states_history} table.');
}

/**
 * Add primary index to node_revision_states_history.
 */
function state_flow_update_7002() {
  db_add_field('node_revision_states_history', 'nrshid', array(
    'description' => 'The primary identifier for this record.',
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'nrshid',
    ),
  ));
}

Functions

Namesort descending Description
state_flow_install Implements hook_install().
state_flow_schema Implements hook_schema().
state_flow_update_7001 Implements hook_update_N().
state_flow_update_7002 Add primary index to node_revision_states_history.