You are here

feed_import_base.install in Feed Import 8

Same filename and directory in other branches
  1. 7.3 feed_import_base/feed_import_base.install

Install/Uninstall code for feed_import

File

feed_import_base/feed_import_base.install
View source
<?php

/**
 * @file
 * Install/Uninstall code for feed_import
 */

/**
 * Implements hook_schema().
 */
function feed_import_base_schema() {
  $schema['feed_import_hashes'] = array(
    'description' => 'Feed import hashes',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Primary key',
      ),
      'feed_machine_name' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => 'Feed machine name',
      ),
      'feed_group' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => 'Feed group',
      ),
      'entity' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => 'Entity name',
      ),
      'entity_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Entity id',
      ),
      'hash' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => 'An uniq hash to identify feed item',
      ),
      'expire' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Timestamp when item expires. 0 = never expires, 1 = item is protected',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'hash_index' => array(
        'feed_group',
        'entity',
        'hash',
      ),
    ),
  );
  $schema['feed_import_settings'] = array(
    'description' => 'Feed import settings',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Primary key',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => 'Feed name',
      ),
      'machine_name' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => 'Unique machine name',
      ),
      'entity' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => 'Entity name',
      ),
      'cron_import' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'If feed is enabled to run at cron',
      ),
      'settings' => array(
        'type' => 'blob',
        'size' => 'big',
        'not null' => TRUE,
        'description' => 'Feed settings',
      ),
      'last_run' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Timestamp of last run',
      ),
      'last_run_duration' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Duration of last run in seconds',
      ),
      'last_run_items' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Last run number of items in feed',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'machine_name' => array(
        'machine_name',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function feed_import_base_uninstall() {
  $vars = array(
    'feed_import_time_between_imports',
    'feed_import_last_executed_import',
    'feed_import_delete_items_per_cron',
    'feed_import_import_running',
    'feed_import_use_cron',
    'feed_import_let_overlap',
    'feed_import_time_settings',
    'feed_import_interval_start',
    'feed_import_interval_stop',
    'feed_import_filters_dir',
    'feed_import_reports',
    'feed_import_invoke_hooks',
  );
  array_map('variable_del', $vars);
  db_drop_table('feed_import_hashes');
  db_drop_table('feed_import_settings');
}

Functions