You are here

brilliant_gallery.install in Brilliant Gallery 6.4

File

brilliant_gallery.install
View source
<?php

// Helpful guide: http://drupal.org/node/150215

/**
 * Implementation of hook_schema().
 */
function brilliant_gallery_schema() {
  $schema['brilliant_gallery_checklist'] = array(
    'description' => t('Table tracing which Brilliant Gallery images are hidden or visible.'),
    'fields' => array(
      'nid' => array(
        'description' => t('Unused now.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'user' => array(
        'description' => t('User ID.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'qid' => array(
        'description' => t('Image.'),
        'type' => 'text',
        'not null' => TRUE,
      ),
      'state' => array(
        'description' => t('Visible or invisible.'),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    //'primary key' => array('nid', 'user', 'Array'),
    'primary key' => array(
      'nid',
      'user',
      array(
        'qid',
        255,
      ),
    ),
  );

  /*
   $schema['brilliant_gallery_checklist'] = array(
   'description' => t('Table tracing which Brilliant Gallery images are hidden or visible.'),
   'fields' => array(
   'nid' => array(
   'description' => t('Unused now.'),
   'type' => 'int',
   'unsigned' => TRUE,
   'not null' => TRUE,
   'size' => 'normal',
   'default' => 0,
   ),
   'user' => array(
   'description' => t('User ID.'),
   'type' => 'int',
   'unsigned' => TRUE,
   'not null' => TRUE,
   'size' => 'normal',
   'default' => 0,
   ),
   'qid' => array(
   'description' => t('Image.'),
   'type' => 'text',
   #'unsigned' => FALSE,
   'not null' => TRUE,
   'size' => 'normal',
   #'default' => '',    # brilliant_gallery_checklist.qid is type text and may not have a default value
   ),
   'state' => array(
   'description' => t('Visible or invisible.'),
   'type' => 'int',
   'unsigned' => TRUE,
   'not null' => TRUE,
   'size' => 'normal',
   'default' => 0,
   ),
   ),
   'primary key' => array('nid','user',array('qid',255)),
   );
  */
  $schema['brilliant_gallery_image_arrays'] = array(
    'description' => t('Binds image property array with its hash that is present in the cached file name and in the URL.'),
    'fields' => array(
      'hash' => array(
        'description' => t('Hash of the serialized array.'),
        'type' => 'varchar',
        'length' => '32',
        'not null' => TRUE,
      ),
      'array' => array(
        'description' => t('Array of image parametres.'),
        'type' => 'text',
        'not null' => TRUE,
      ),
      'datetime' => array(
        'description' => t('Date and time of last value refresh.'),
        'type' => 'datetime',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'hash',
    ),
    'indexes' => array(
      'datetime' => array(
        'datetime',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function brilliant_gallery_install() {

  // Create tables.
  drupal_install_schema('brilliant_gallery');
}

/**
 * Implementation of hook_uninstall().
 */
function brilliant_gallery_uninstall() {

  // Remove tables.
  drupal_uninstall_schema('brilliant_gallery');
}

/**
 * Implementation(s) of hook_update_N().
 */
function brilliant_gallery_update_6001() {
  $ret = array();
  $schema['brilliant_gallery_checklist'] = array(
    'description' => t('Table tracing which Brilliant Gallery images are hidden or visible.'),
    'fields' => array(
      'nid' => array(
        'description' => t('Unused now.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'size' => 'normal',
        'default' => 0,
      ),
      'user' => array(
        'description' => t('User ID.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'size' => 'normal',
        'default' => 0,
      ),
      'qid' => array(
        'description' => t('Image.'),
        'type' => 'text',
        #'unsigned' => FALSE,
        'not null' => TRUE,
        'size' => 'normal',
      ),
      'state' => array(
        'description' => t('Visible or invisible.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'size' => 'normal',
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
      'user',
      array(
        'qid',
        255,
      ),
    ),
  );
  db_create_table($ret, 'brilliant_gallery_checklist', $schema['brilliant_gallery_checklist']);
  return $ret;
}
function brilliant_gallery_update_6003() {
  $ret = array();
  $schema['brilliant_gallery_image_arrays'] = array(
    'description' => t('Binds image property array with its hash that is present in the cached file name and in the URL.'),
    'fields' => array(
      'hash' => array(
        'description' => t('Hash of the serialized array.'),
        'type' => 'varchar',
        'length' => '32',
        'not null' => TRUE,
      ),
      'array' => array(
        'description' => t('Array of image parametres.'),
        'type' => 'text',
        'not null' => TRUE,
      ),
      'datetime' => array(
        'description' => t('Date and time of last value refresh.'),
        'type' => 'datetime',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'hash',
    ),
    'indexes' => array(
      'datetime' => array(
        'datetime',
      ),
    ),
  );
  db_create_table($ret, 'brilliant_gallery_image_arrays', $schema['brilliant_gallery_image_arrays']);
  return $ret;
}