state_flow.install in State Machine 7
Same filename and directory in other branches
Install file for the State Flow module.
File
modules/state_flow/state_flow.installView 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(
'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',
),
),
'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.');
}
Functions
Name | Description |
---|---|
state_flow_install | Implements hook_install(). |
state_flow_schema | Implements hook_schema(). |
state_flow_update_7001 | Implements hook_update_N(). |