You are here

feeds_tamper.install in Feeds Tamper 6

Same filename and directory in other branches
  1. 7 feeds_tamper.install

Schema definitions install/update/uninstall hooks.

File

feeds_tamper.install
View source
<?php

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

/**
 * Implementation of hook_install().
 */
function feeds_tamper_install() {
  drupal_install_schema('feeds_tamper');
}

/**
 * Implementation of hook_schema().
 */
function feeds_tamper_schema() {
  $schema = array();
  $schema['feeds_tamper'] = array(
    'description' => 'Table storing tamper instances.',
    'export' => array(
      'key' => 'id',
      'identifier' => 'feeds_tamper',
      // Exports will be as $tamper_instalce
      'default hook' => 'feeds_tamper_default',
      // Function hook name.
      'api' => array(
        'owner' => 'feeds_tamper',
        'api' => 'feeds_tamper_default',
        // Base name for api include files.
        'minimum_version' => 2,
        'current_version' => 2,
      ),
    ),
    'fields' => array(
      'id' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Id of the feeds tamper instance.',
      ),
      'importer' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Id of the feeds importer.',
      ),
      'source' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The source field of the importer.',
      ),
      'plugin_id' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Id of the tamper plugin.',
      ),
      'settings' => array(
        'type' => 'text',
        'size' => 'big',
        'description' => 'A serialized array of options for a Feeds Tamper plugin.',
        'serialize' => TRUE,
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'The weight of a plugin instance. Plugins are executed in order.',
      ),
      'description' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Description of this plugin.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'importer' => array(
        'importer',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_uninstall().
 */
function feeds_tamper_uninstall() {
  drupal_uninstall_schema('feeds_tamper');
  variable_del('default_feeds_tamper');
}

/**
 * Add weight field to feeds_tamper table.
 */
function feeds_tamper_update_6001(&$sandbox) {
  $ret = array();
  $spec = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'unsigned' => TRUE,
    'description' => 'The weight of a plugin instance. Plugins are executed in order.',
  );
  db_add_field($ret, 'feeds_tamper', 'weight', $spec);
  return $ret;
}

/**
 * Add description field to feeds_tamper table.
 */
function feeds_tamper_update_6002(&$sandbox) {
  $ret = array();
  $spec = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
    'description' => 'Description of this plugin.',
  );
  db_add_field($ret, 'feeds_tamper', 'description', $spec);
  return $ret;
}

/**
 * Add index on importer.
 */
function feeds_tamper_update_6003(&$sandbox) {
  $ret = array();
  $spec = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
    'description' => 'Description of this plugin.',
  );
  db_add_index($ret, 'feeds_tamper', 'importer', array(
    'importer',
  ));
  return $ret;
}

/**
 * Verify that description length is 255.
 *
 * See #1182204.
 */
function feeds_tamper_update_6004(&$sandbox) {
  $spec = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
    'description' => 'Description of this plugin.',
  );
  $ret = array();
  db_change_field($ret, 'feeds_tamper', 'description', 'description', $spec);
  return $ret;
}

Functions

Namesort descending Description
feeds_tamper_install Implementation of hook_install().
feeds_tamper_schema Implementation of hook_schema().
feeds_tamper_uninstall Implementation of hook_uninstall().
feeds_tamper_update_6001 Add weight field to feeds_tamper table.
feeds_tamper_update_6002 Add description field to feeds_tamper table.
feeds_tamper_update_6003 Add index on importer.
feeds_tamper_update_6004 Verify that description length is 255.