You are here

function workbench_scheduler_schema in Workbench Scheduler 7.2

Same name and namespace in other branches
  1. 7 workbench_scheduler.install \workbench_scheduler_schema()

Implements hook_schema().

1 call to workbench_scheduler_schema()
workbench_scheduler_update_7200 in ./workbench_scheduler.install
Update from 7.x-1.x version to 7.x-2.0 version.

File

./workbench_scheduler.install, line 10
Contains install and update functions for workbench_scheduler.

Code

function workbench_scheduler_schema() {
  $schema = array();

  // Schedules table.
  $schema['workbench_scheduler_schedules'] = array(
    'description' => 'Saves data for workbench schedules that can be run on the system',
    'fields' => array(
      'sid' => array(
        'description' => 'The unique id for a schedule',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'A unique machine name to identify the schedule',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'A label for the schedule',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'transition' => array(
        'description' => 'The id of the transition',
        'type' => 'int',
        'not null' => FALSE,
        'unsigned' => TRUE,
      ),
    ),
    'primary key' => array(
      'sid',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
  );

  // Schedule content types table.
  $schema['workbench_scheduler_types'] = array(
    'description' => 'Saves the associations between schedules and content types',
    'fields' => array(
      'name' => array(
        'description' => 'The machine name of a schedule',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The machine name of a content type',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
    ),
    'unique keys' => array(
      'name_type' => array(
        'name',
        'type',
      ),
    ),
  );

  // Schedule nodes table.
  $schema['workbench_scheduler_nodes'] = array(
    'description' => 'Saves the schedule information for nodes',
    'fields' => array(
      'nid' => array(
        'description' => 'The node id',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'vid' => array(
        'description' => 'The revision id of the node',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'sid' => array(
        'description' => 'The id of the schedule',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'date' => array(
        'description' => 'the date when the new state should be applied',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
      ),
      'completed' => array(
        'description' => 'mark if the schedule has been completed for this node',
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => FALSE,
      ),
    ),
    'unique keys' => array(
      'vid' => array(
        'vid',
        'sid',
      ),
    ),
    'foreign_keys' => array(
      'nid' => array(
        'node' => 'nid',
      ),
      'vid' => array(
        'node_revision' => 'vid',
      ),
      'sid' => array(
        'workbench_scheduler_schedules' => 'sid',
      ),
    ),
  );
  return $schema;
}