You are here

radioactivity.install in Radioactivity 7

File

radioactivity.install
View source
<?php

/**
 * Implement hook_field_schema().
 */
function radioactivity_field_schema($field) {
  $columns = array();

  // @FIXME: precision should be checked... float might just not do it for big sites
  if ($field['type'] == RADIOACTIVITY_FIELD_TYPE) {
    $columns = array(
      RADIOACTIVITY_FIELD_ENERGY => array(
        'type' => 'float',
        'not null' => FALSE,
      ),
      RADIOACTIVITY_FIELD_TIMESTAMP => array(
        'type' => 'int',
        'not null' => FALSE,
      ),
    );
  }
  return array(
    'columns' => $columns,
  );
}

/**
 * Implementation of hook_schema
 */
function radioactivity_schema() {
  $schema = array();
  $schema['radioactivity_deferred_storage'] = array(
    'description' => 'Deferred storage table for radioactivity',
    'fields' => array(
      'entity_type' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'description' => 'Type of the entity',
      ),
      'entity_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Entity identifier',
      ),
      'field_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Field identifier',
      ),
      'energy' => array(
        'type' => 'float',
        'size' => 'big',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Amount of energy this action produced',
      ),
      'emission_time' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Time of the emission',
      ),
    ),
    //'primary key' => array('entity_type', 'entity_id', 'field_id'),
    'indexes' => array(
      'main' => array(
        'entity_type',
        'entity_id',
        'field_id',
      ),
    ),
  );
  return $schema;

  /*
  $schema['radioactivity_deferred_store'] =
    array('description' => 'The table where DbStore puts deferred entries',
          'fields' =>
          array('entry_id' => array('type' => 'serial',
                                    'size' => 'big',
                                    'not null' => TRUE,
                                    'description' => 'Entry identifier'),
                'entry_type' => array('type' => 'varchar',
                                      'length' => 10,
                                      'not null' => TRUE,
                                      'description' => 'Entry type, e.g., add-energy'),
                'id' => array('type' => 'int',
                              'unsigned'=> TRUE,
                              'not null' => TRUE,
                              'description' => 'The object identifier. Nid for nodes, cid for comments, uid for users, etc'),
                'class' => array('type' => 'varchar',
                                 'length' => 7,
                                 'not null' => TRUE,
                                 'description' => 'The object class. node, comment, user, etc'),
                'source' => array('type' => 'varchar',
                                  'length' => 16,
                                  'not null' => TRUE,
                                  'description' => 'The energy source, e.g., node_view'),
                'multiplier' => array('type' => 'float',
                                      'size' => 'big',
                                      'not null' => TRUE,
                                      'description' => 'Energy multiplier'),
          ),
          'primary key' => array('entry_id')
    );

  return $schema;
  */
}

Functions

Namesort descending Description
radioactivity_field_schema Implement hook_field_schema().
radioactivity_schema Implementation of hook_schema