You are here

currency_api.install in Currency 6

This module provides an API for currency conversion.

File

currency_api/currency_api.install
View source
<?php

/**
 * @file
 *   This module provides an API for currency conversion.
 */

/**
 * Implementation of hook_install().
 *
 * This will automatically install the database tables for CurrencyAPI.
 */
function currency_api_install() {
  drupal_install_schema('currency_api');
}

/**
 * Implementation of hook_schema().
 *
 * Define schema for currencyapi database
 */
function currency_api_schema() {
  $schema['currencyapi'] = array(
    'description' => 'Table to cache currency rates that have been looked up by the Currency API module.',
    'fields' => array(
      'currency_from' => array(
        'description' => 'ISO 4217 3-character currency code for destination currency, as a character string.',
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => '',
      ),
      'currency_to' => array(
        'description' => 'ISO 4217 3-character currency code for destination currency, as a character string.',
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => '',
      ),
      'rate' => array(
        'description' => 'Conversion rate, currency_to per currency_from, as a floating point number.',
        'type' => 'float',
        'size' => 'normal',
        'not null' => TRUE,
        'default' => 0,
      ),
      'timestamp' => array(
        'description' => 'The time that the conversion rate was created, or last edited by its author, as a Unix timestamp.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'currency_from',
      'currency_to',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_uninstall().
 *
 * This will automatically remove the database tables and varibles
 * defined by CurrencyAPI.
 */
function currency_api_uninstall() {
  drupal_uninstall_schema('currency_api');
  db_query("DELETE FROM {variable} WHERE name LIKE 'currency_api%'");
}
function currency_api_update_1() {
  $ret = array();
  db_change_field($ret, 'currencyapi', 'timestamp', 'timestamp', array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  return $ret;
}

Functions

Namesort descending Description
currency_api_install Implementation of hook_install().
currency_api_schema Implementation of hook_schema().
currency_api_uninstall Implementation of hook_uninstall().
currency_api_update_1