You are here

shrinktheweb.install in ShrinkTheWeb 7

Same filename and directory in other branches
  1. 8 shrinktheweb.install
  2. 6 shrinktheweb.install

File

shrinktheweb.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function shrinktheweb_schema() {
  $schema['shrinktheweb_log'] = array(
    'description' => 'Stores the STW requests',
    'fields' => array(
      'stw_siteid' => array(
        'description' => '',
        'type' => 'serial',
        'unsigned' => TRUE,
        'size' => 'normal',
        'not null' => TRUE,
      ),
      'stw_domain' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      'stw_hash' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '32',
        'not null' => TRUE,
      ),
      'stw_timestamp' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '12',
        'not null' => TRUE,
        'default' => '',
      ),
      'stw_capturedon' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '12',
        'not null' => TRUE,
      ),
      'stw_quality' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 90,
      ),
      'stw_full' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'stw_xmax' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 200,
      ),
      'stw_ymax' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 150,
      ),
      'stw_nrx' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 1024,
      ),
      'stw_nry' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'small',
        'not null' => TRUE,
        'default' => 768,
      ),
      'stw_invalid' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'tiny',
        'not null' => TRUE,
      ),
      'stw_stwerrcode' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '50',
        'not null' => TRUE,
      ),
      'stw_error' => array(
        'description' => '',
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'stw_errcode' => array(
        'description' => '',
        'type' => 'varchar',
        'length' => '50',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'stw_siteid',
    ),
    'unique keys' => array(
      'key' => array(
        'stw_hash',
      ),
    ),
  );
  return $schema;
}

/**
 * This will update the shrinktheweb_log table from Drupal 6.x to its new format for Drupal 7.x
 */
function shrinktheweb_update_7000() {
  $schema = shrinktheweb_schema();
  db_drop_table('shrinktheweb_log');
  db_create_table('shrinktheweb_log', $schema['shrinktheweb_log']);
}

/**
 * This will update the shrinktheweb_log table to its new format
 */
function shrinktheweb_update_7100() {
  $schema = shrinktheweb_schema();
  db_drop_table('shrinktheweb_log');
  db_create_table('shrinktheweb_log', $schema['shrinktheweb_log']);
}

/**
 * This update will add 'stw_' prefix to rows in the shrinktheweb_log table
 * to fix the issue with PostgreSQL (https://www.drupal.org/node/1772534).
 */
function shrinktheweb_update_7101() {
  db_change_field('shrinktheweb_log', 'siteid', 'stw_siteid', array(
    'description' => '',
    'type' => 'serial',
    'unsigned' => TRUE,
    'size' => 'normal',
    'not null' => TRUE,
  ));
  db_change_field('shrinktheweb_log', 'domain', 'stw_domain', array(
    'description' => '',
    'type' => 'varchar',
    'length' => '255',
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field('shrinktheweb_log', 'hash', 'stw_hash', array(
    'description' => '',
    'type' => 'varchar',
    'length' => '32',
    'not null' => TRUE,
  ));
  db_change_field('shrinktheweb_log', 'timestamp', 'stw_timestamp', array(
    'description' => '',
    'type' => 'varchar',
    'length' => '12',
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field('shrinktheweb_log', 'capturedon', 'stw_capturedon', array(
    'description' => '',
    'type' => 'varchar',
    'length' => '12',
    'not null' => TRUE,
  ));
  db_change_field('shrinktheweb_log', 'quality', 'stw_quality', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'small',
    'not null' => TRUE,
    'default' => 90,
  ));
  db_change_field('shrinktheweb_log', 'full', 'stw_full', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field('shrinktheweb_log', 'xmax', 'stw_xmax', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'small',
    'not null' => TRUE,
    'default' => 200,
  ));
  db_change_field('shrinktheweb_log', 'ymax', 'stw_ymax', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'small',
    'not null' => TRUE,
    'default' => 150,
  ));
  db_change_field('shrinktheweb_log', 'nrx', 'stw_nrx', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'small',
    'not null' => TRUE,
    'default' => 1024,
  ));
  db_change_field('shrinktheweb_log', 'nry', 'stw_nry', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'small',
    'not null' => TRUE,
    'default' => 768,
  ));
  db_change_field('shrinktheweb_log', 'invalid', 'stw_invalid', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'tiny',
    'not null' => TRUE,
  ));
  db_change_field('shrinktheweb_log', 'stwerrcode', 'stw_stwerrcode', array(
    'description' => '',
    'type' => 'varchar',
    'length' => '50',
    'not null' => TRUE,
  ));
  db_change_field('shrinktheweb_log', 'error', 'stw_error', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field('shrinktheweb_log', 'errcode', 'stw_errcode', array(
    'description' => '',
    'type' => 'varchar',
    'length' => '50',
    'not null' => TRUE,
  ));
  db_change_field('shrinktheweb_log', 'referrer', 'stw_referrer', array(
    'description' => '',
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'tiny',
    'not null' => TRUE,
  ));
}

/**
 * This update removes unneeded stw_referrer field from log table
 */
function shrinktheweb_update_7102() {
  db_drop_field('shrinktheweb_log', 'stw_referrer');
}

/**
 * Implementation of hook_uninstall().
 */
function shrinktheweb_uninstall() {
  variable_del('shrinktheweb_access_key');
  variable_del('shrinktheweb_secret_key');
  variable_del('shrinktheweb_inside_pages');
  variable_del('shrinktheweb_thumb_size');
  variable_del('shrinktheweb_thumb_size_custom');
  variable_del('shrinktheweb_full_size');
  variable_del('shrinktheweb_max_height');
  variable_del('shrinktheweb_native_res');
  variable_del('shrinktheweb_widescreen_y');
  variable_del('shrinktheweb_delay');
  variable_del('shrinktheweb_quality');
  variable_del('shrinktheweb_cache_days');
  variable_del('shrinktheweb_thumbs_folder');
  variable_del('shrinktheweb_custom_msg_url');
  variable_del('shrinktheweb_debug');
}

Functions

Namesort descending Description
shrinktheweb_schema Implementation of hook_schema().
shrinktheweb_uninstall Implementation of hook_uninstall().
shrinktheweb_update_7000 This will update the shrinktheweb_log table from Drupal 6.x to its new format for Drupal 7.x
shrinktheweb_update_7100 This will update the shrinktheweb_log table to its new format
shrinktheweb_update_7101 This update will add 'stw_' prefix to rows in the shrinktheweb_log table to fix the issue with PostgreSQL (https://www.drupal.org/node/1772534).
shrinktheweb_update_7102 This update removes unneeded stw_referrer field from log table