You are here

progress.install in Background Process 8

Installation file for the Progress module.

File

progress/progress.install
View source
<?php

/**
 * @file
 * Installation file for the Progress module.
 */

/**
 * Implemets Progress Schema.
 */
function progress_schema() {
  $schema = [];
  $schema['progress'] = [
    'description' => 'Progress',
    'fields' => [
      'name' => [
        'description' => 'Name of progress',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'progress' => [
        'description' => 'Progress status',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 0,
      ],
      'message' => [
        'description' => 'Message for current progress',
        'type' => 'text',
        'not null' => TRUE,
      ],
      'start_stamp' => [
        'description' => 'Start time in unix timestamp',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0,
      ],
      'end_stamp' => [
        'description' => 'End time in unix timestamp',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0,
      ],
      'current_stamp' => [
        'description' => 'Current time in unix timestamp',
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'name',
    ],
  ];
  return $schema;
}

/**
 * Implemets for Major version upgrade of Drupal.
 */
function progress_update_7000(&$context) {
  $schema_version = db_query("SELECT schema_version FROM {system} WHERE name = 'progress'")
    ->fetchField();
  if ($schema_version > 0 && $schema_version < 7000) {
    $context['sandbox']['major_version_upgrade'] = [
      7101 => TRUE,
    ];
  }
}

/**
 * Implemets to Change schema to SQL 99 compliance.
 */
function progress_update_7101(&$context) {
  if (!empty($context['sandbox']['major_version_upgrade'][7101])) {

    // This udate is already part of latest.
    return;
  }
  db_change_field('progress', 'start', 'start_stamp', [
    'description' => 'Start time in unix timestamp',
    'type' => 'float',
    'size' => 'big',
    'not null' => TRUE,
    'default' => 0,
  ]);
  db_change_field('progress', 'end', 'end_stamp', [
    'description' => 'End time in unix timestamp',
    'type' => 'float',
    'size' => 'big',
    'not null' => TRUE,
    'default' => 0,
  ]);
  db_change_field('progress', 'current', 'current_stamp', [
    'description' => 'Current time in unix timestamp',
    'type' => 'float',
    'size' => 'big',
    'not null' => TRUE,
    'default' => 0,
  ]);
}

Functions

Namesort descending Description
progress_schema Implemets Progress Schema.
progress_update_7000 Implemets for Major version upgrade of Drupal.
progress_update_7101 Implemets to Change schema to SQL 99 compliance.