You are here

function userpoints_update_7200 in User Points 7.2

Add userpoints transaction type table, and default bundle.

File

./userpoints.install, line 411
Install time hook userpoints module.

Code

function userpoints_update_7200() {

  // Add transaction type table from schema.
  $txn_type_schema = array(
    'description' => 'Userpoints transaction type',
    'fields' => array(
      'id' => array(
        'description' => 'Transaction type id',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'Machine name',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'Human-readable name',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'status' => array(
        'description' => 'Type status used by Entity API',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0x1,
      ),
      'module' => array(
        'description' => 'Module owner of type used by Entity API',
        'type' => 'varchar',
        'length' => 100,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
  );
  db_create_table('userpoints_txn_type', $txn_type_schema);

  // Create the default userpoints bundle.
  $insert = db_insert('userpoints_txn_type')
    ->fields(array(
    'name' => 'userpoints',
    'label' => st('Default'),
    'status' => 0x1,
    'module' => 'userpoints',
  ));
  $insert
    ->execute();
  variable_set('userpoints_default_bundle', 'userpoints');

  // Add bundle column to transaction table.
  $type_field = array(
    'description' => 'Bundle',
    'type' => 'varchar',
    'length' => 100,
    'not null' => TRUE,
    'initial' => 'userpoints',
  );
  db_add_field('userpoints_txn', 'type', $type_field);
}