commerce_registration.install in Commerce Registration 7.3
Same filename and directory in other branches
Commerce Registration install file.
Modify the registration schema to accommodate a commerce line item ID number.
File
commerce_registration.installView source
<?php
/**
* @file
* Commerce Registration install file.
*
* Modify the registration schema to accommodate a commerce line item ID number.
*/
function commerce_registration_schema() {
$schema = array();
$schema['commerce_registration_settings'] = array(
'description' => 'Entity specific settings for Commerce Registration.',
'fields' => array(
'entity_type' => array(
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
'description' => 'The entity type.',
),
'entity_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The entity\'s unique ID',
),
'entity_bundle' => array(
'type' => 'varchar',
'length' => '100',
'description' => 'The bundle for the entity, or NULL if the settings apply to all bundles of the entity type.',
),
'settings' => array(
'type' => 'text',
'size' => 'big',
'serialize' => TRUE,
),
),
'unique_keys' => array(
'entity' => array(
'entity_type',
'entity_id',
'entity_bundle',
),
),
);
return $schema;
}
/**
* Implements hook_schema_alter().
*/
function commerce_registration_schema_alter(&$schema) {
$schema['registration']['fields']['lineitem_id'] = array(
'description' => 'The line item associated with this registration, if any.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
$schema['commerce_line_item']['fields']['registrations'] = array(
'description' => 'A collection of registrations attached to the line item.',
'type' => 'text',
'size' => 'big',
'serialize' => TRUE,
);
}
/**
* Implements hook_install().
*/
function commerce_registration_install() {
// Add the new commerce line item ID field to registrations.
db_add_field('registration', 'lineitem_id', array(
'description' => 'The line item associated with this registration, if any.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
db_add_field('commerce_line_item', 'registrations', array(
'description' => 'A collection of registrations attached to the line item.',
'type' => 'text',
'size' => 'big',
'serialize' => TRUE,
));
}
/**
* Implements hook_uninstall().
*/
function commerce_registration_uninstall() {
// Drop the lineitem_id field from the registration table.
db_drop_field('registration', 'lineitem_id');
db_drop_field('commerce_line_item', 'registrations');
}
Functions
Name![]() |
Description |
---|---|
commerce_registration_install | Implements hook_install(). |
commerce_registration_schema | @file Commerce Registration install file. |
commerce_registration_schema_alter | Implements hook_schema_alter(). |
commerce_registration_uninstall | Implements hook_uninstall(). |