You are here

themekey_ui.install in ThemeKey 6.2

Database schema of @author Markus Kalkbrenner | Cocomore AG

File

themekey_ui.install
View source
<?php

/**
 * @file
 * Database schema of @see themekey_ui.module
 *
 * @author Markus Kalkbrenner | Cocomore AG
 *   @see http://drupal.org/user/124705
 */

/**
 * Implements hook_schema().
 */
function themekey_ui_schema() {
  $schema = array();
  $schema['themekey_ui_node_theme'] = array(
    'fields' => array(
      'nid' => array(
        'description' => 'The {node} this version belongs to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'description' => 'The primary identifier for this version.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'theme' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );
  $schema['themekey_ui_author_theme'] = array(
    'fields' => array(
      'uid' => array(
        'description' => 'The user id.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'theme' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'uid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function themekey_ui_install() {
  drupal_install_schema('themekey_ui');
}

/**
 * Implements hook_uninstall().
 */
function themekey_ui_uninstall() {

  // Drop tables
  drupal_uninstall_schema('themekey_ui');

  // Remove variables
  db_query("DELETE FROM {variable} WHERE name LIKE 'themekey_ui%%'");
  cache_clear_all('variables', 'cache');
}

/**
 * Implements hook_update_N().
 */
function themekey_ui_update_6100() {

  // moved to themekey_update_6105() to not break upgrades from ThemeKey 6.x-1.1 to 6.x-2.0
  return array();
}

/**
 * Implements hook_update_N().
 */
function themekey_ui_update_6200() {
  $schema['themekey_ui_author_theme'] = array(
    'fields' => array(
      'uid' => array(
        'description' => 'The user id.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'theme' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'uid',
    ),
  );
  $ret = array();
  db_create_table($ret, 'themekey_ui_author_theme', $schema['themekey_ui_author_theme']);
  return $ret;
}