You are here

job_scheduler.install in Job Scheduler 8.2

Schema definitions install/update/uninstall hooks.

File

job_scheduler.install
View source
<?php

/**
 * @file
 * Schema definitions install/update/uninstall hooks.
 */

/**
 * Implements hook_schema().
 */
function job_scheduler_schema() {
  $schema = [];
  $schema['job_schedule'] = [
    'description' => 'Schedule of jobs to be executed.',
    'fields' => [
      'item_id' => [
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Primary Key: Unique item ID.',
      ],
      'name' => [
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Name of the schedule.',
      ],
      'type' => [
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Type identifier of the job.',
      ],
      'id' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'unsigned' => TRUE,
        'description' => 'Numeric identifier of the job.',
      ],
      'period' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
        'description' => 'Time period after which job is to be executed.',
      ],
      'crontab' => [
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Crontab line in *NIX format.',
      ],
      'data' => [
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'The arbitrary data for the item.',
      ],
      'expire' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Timestamp when job expires.',
      ],
      'last' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
        'description' => 'Timestamp when a job was last executed.',
      ],
      'periodic' => [
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
        'description' => 'If true job will be automatically rescheduled.',
      ],
      'next' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
        'description' => 'Timestamp when a job is to be executed (next = last + period), used for fast ordering.',
      ],
      'scheduled' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
        'not null' => TRUE,
        'description' => 'Timestamp when a job was scheduled. 0 if a job is currently not scheduled.',
      ],
    ],
    'primary key' => [
      'item_id',
    ],
    'indexes' => [
      'name_type_id' => [
        'name',
        'type',
        'id',
      ],
      'name_type' => [
        'name',
        'type',
      ],
      'next' => [
        'next',
      ],
      'scheduled' => [
        'scheduled',
      ],
    ],
  ];
  return $schema;
}

/**
 * Rebuild cache.
 */
function job_scheduler_update_8001() {

  // Empty update to cause a cache rebuild.
}

Functions

Namesort descending Description
job_scheduler_schema Implements hook_schema().
job_scheduler_update_8001 Rebuild cache.