<?php

/**
 * @file
 * Install hooks.
 */

/**
 * Implementation of hook_schema().
 */
function feeds_fast_news_schema() {
  // Install data tables.
  include_once('feeds_fast_news.data_default.inc');
  $tables = feeds_fast_news_data_default();
  $schema = array();
  foreach ($tables as $name => $table) {
    $schema[$name] = $table->table_schema;
  }
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function feeds_fast_news_install() {
  // We are replacing feeds_defaults module, taking over its table.
  // Hence we cannot use drupal_install_schema('feeds_fast_news');
  $schema = drupal_get_schema_unprocessed('feeds_fast_news');
  _drupal_initialize_schema('feeds_fast_news', $schema);

  $ret = array();
  foreach ($schema as $name => $table) {
    // Check whether table exists.
    if (!db_table_exists($name)) {
      db_create_table($ret, $name, $table);
    }
  }
}

/**
 * Implementation of hook_uninstall();
 */
function feeds_fast_news_uninstall() {
  drupal_uninstall_schema('feeds_fast_news');
}
