You are here

forena.install in Forena Reports 6.2

Installation api for module

File

forena.install
View source
<?php

/**
 * @file
 * Installation api for module
 */

/**
 * Implementation of hook_schema
 *
 * @return unknown
 */

/**
 * Implementation of hook_schema
 *
 * @return unknown
 */
function forena_schema() {

  /*
   * Table to store Reports
   */
  $schema['forena_reports'] = array(
    'fields' => array(
      'report_name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 30,
        'not null' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 63,
        'not null' => TRUE,
      ),
      'descriptor' => array(
        'type' => 'text',
      ),
      'category' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'hidden' => array(
        'type' => 'int',
        'not null' => FALSE,
      ),
      'cache' => array(
        'type' => 'text',
      ),
      'src' => array(
        'type' => 'text',
      ),
      'modified' => array(
        'type' => 'int',
      ),
      'altered' => array(
        'type' => 'int',
      ),
    ),
    'primary key' => array(
      'report_name',
      'language',
    ),
    'indexes' => array(
      'category' => array(
        'category',
      ),
    ),
  );
  $schema['forena_repositories'] = array(
    'fields' => array(
      'repository' => array(
        'type' => 'varchar',
        'length' => '63',
        'not null' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => '63',
      ),
      'enabled' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'config' => array(
        'type' => 'text',
      ),
    ),
    'primary_key' => array(
      'repository',
    ),
  );
  $schema['forena_data_blocks'] = array(
    'fields' => array(
      'repository' => array(
        'type' => 'varchar',
        'length' => '63',
        'not null' => TRUE,
      ),
      'block_name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 63,
        'not null' => FALSE,
      ),
      'descriptor' => array(
        'type' => 'varchar',
        'length' => '255',
      ),
      'category' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'modified' => array(
        'type' => 'int',
      ),
      'src' => array(
        'type' => 'text',
      ),
      'locked' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'block_name',
    ),
    'indexes' => array(
      'category' => array(
        'category',
      ),
      'repository' => array(
        'repository',
      ),
    ),
  );
  return $schema;
}
function forena_update_6001() {
  $ret = array();
  db_add_field($ret, 'forena_reports', 'modified', array(
    'type' => 'int',
  ));
  return $ret;
}
function forena_update_6002() {
  $ret = array();
  db_drop_field($ret, 'forena_reports', 'file_name');
  return $ret;
}

/**
 * Updating database schema
 */
function forena_update_6201() {
  $ret = array();
  $schema = array();
  $schema['forena_repositories'] = array(
    'fields' => array(
      'repository' => array(
        'type' => 'varchar',
        'length' => 63,
        'not null' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 63,
      ),
      'enabled' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'config' => array(
        'type' => 'text',
      ),
    ),
    'primary_key' => array(
      'repository',
    ),
  );
  $schema['forena_data_blocks'] = array(
    'fields' => array(
      'repository' => array(
        'type' => 'varchar',
        'length' => '63',
        'not null' => TRUE,
      ),
      'block_name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 63,
        'not null' => FALSE,
      ),
      'descriptor' => array(
        'type' => 'varchar',
        'length' => '255',
      ),
      'category' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'modified' => array(
        'type' => 'int',
      ),
      'src' => array(
        'type' => 'text',
      ),
      'locked' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'block_name',
    ),
    'indexes' => array(
      'category' => array(
        'category',
      ),
      'repository' => array(
        'repository',
      ),
    ),
  );
  db_add_field($ret, 'forena_reports', 'descriptor', array(
    'type' => 'text',
  ));
  db_add_field($ret, 'forena_reports', 'src', array(
    'type' => 'text',
  ));
  db_add_field($ret, 'forena_reports', 'altered', array(
    'type' => 'int',
  ));
  db_create_table($ret, 'forena_repositories', $schema['forena_repositories']);
  db_create_table($ret, 'forena_data_blocks', $schema['forena_data_blocks']);
  return $ret;
}

/**
 * Add language column
 */
function forena_update_6202() {
  $ret = array();
  db_add_field($ret, 'forena_reports', 'language', array(
    'type' => 'varchar',
    'length' => 30,
    'not null' => TRUE,
    'default' => 'en',
  ));
  db_query("update {forena_reports} set language='en'");
  db_drop_primary_key($ret, 'forena_reports');
  db_add_primary_key($ret, 'forena_reports', array(
    'report_name',
    'language',
  ));
  return $ret;
}

/**
 * Basic install and uninstall hooks.
 *
 */
function forena_install() {
  drupal_install_schema('forena');
}
function forena_uninstall() {
  drupal_uninstall_schema('forena');
}

Functions

Namesort descending Description
forena_install Basic install and uninstall hooks.
forena_schema Implementation of hook_schema
forena_uninstall
forena_update_6001
forena_update_6002
forena_update_6201 Updating database schema
forena_update_6202 Add language column