uc_order.install in Ubercart 8.4
Same filename and directory in other branches
Install, update and uninstall functions for the uc_order module.
File
uc_order/uc_order.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the uc_order module.
*/
use Drupal\uc_order\Entity\OrderStatus;
/**
* Implements hook_schema().
*/
function uc_order_schema() {
$schema = [];
$schema['uc_order_admin_comments'] = [
'description' => 'Comments on orders that only administrators can see.',
'fields' => [
'comment_id' => [
'description' => 'Primary key: the comment ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'order_id' => [
'description' => 'The {uc_orders}.order_id of the order.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'uid' => [
'description' => 'The {user}.uid of the author of the comment.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'message' => [
'description' => 'The comment body.',
'type' => 'text',
],
'created' => [
'description' => 'The Unix timestamp indicating when the comment was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
],
'indexes' => [
'order_id' => [
'order_id',
],
],
'primary key' => [
'comment_id',
],
'foreign keys' => [
'uc_orders' => [
'table' => 'uc_orders',
'columns' => [
'order_id' => 'order_id',
],
],
'users' => [
'table' => 'users',
'columns' => [
'uid' => 'uid',
],
],
],
];
$schema['uc_order_comments'] = [
'description' => 'Comments on the order that the customer can see.',
'fields' => [
'comment_id' => [
'description' => 'Primary key: the comment ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'order_id' => [
'description' => 'The {uc_orders}.order_id of the order.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'uid' => [
'description' => 'The {users}.uid of the user who made the comment.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'order_status' => [
'description' => 'The status the order had when the comment was made.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
],
'notified' => [
'description' => 'A flag indicating whether the comment was emailed to the customer. 1 => Yes. 0 => No.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
],
'message' => [
'description' => 'The comment body.',
'type' => 'text',
],
'created' => [
'description' => 'The Unix timestamp indicating when the comment was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
],
'indexes' => [
'order_id' => [
'order_id',
],
],
'primary key' => [
'comment_id',
],
'foreign keys' => [
'uc_orders' => [
'table' => 'uc_orders',
'columns' => [
'order_id' => 'order_id',
],
],
'users' => [
'table' => 'users',
'columns' => [
'uid' => 'uid',
],
],
],
];
$schema['uc_order_line_items'] = [
'description' => 'Order line items other than products.',
'fields' => [
'line_item_id' => [
'description' => 'Primary key: the line item ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'order_id' => [
'description' => 'The {uc_orders}.order_id.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'type' => [
'description' => 'The line item type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
],
'title' => [
'description' => 'The label of the line item.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'amount' => [
'description' => "The amount of the line item in the store's currency.",
'type' => 'numeric',
'precision' => 16,
'scale' => 5,
'not null' => TRUE,
'default' => 0.0,
],
'weight' => [
'description' => 'The sort criteria of line items.',
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
],
'data' => [
'description' => 'A serialized array of extra data.',
'type' => 'text',
'serialize' => TRUE,
],
],
'indexes' => [
'order_id' => [
'order_id',
],
],
'primary key' => [
'line_item_id',
],
'foreign keys' => [
'uc_orders' => [
'table' => 'uc_orders',
'columns' => [
'order_id' => 'order_id',
],
],
],
];
$schema['uc_order_log'] = [
'description' => 'Record of changes made to an order.',
'fields' => [
'order_log_id' => [
'description' => 'Primary key: the log entry ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'order_id' => [
'description' => 'The {uc_orders}.order_id.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'uid' => [
'description' => 'The {users}.uid of the user who made the changes.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'changes' => [
'description' => 'The description of what was changed.',
'type' => 'text',
],
'created' => [
'description' => 'The Unix timestamp indicating when the change was made.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
],
'indexes' => [
'order_id' => [
'order_id',
],
],
'primary key' => [
'order_log_id',
],
'foreign keys' => [
'uc_orders' => [
'table' => 'uc_orders',
'columns' => [
'order_id' => 'order_id',
],
],
'users' => [
'table' => 'users',
'columns' => [
'uid' => 'uid',
],
],
],
];
return $schema;
}
/**
* Implements hook_uninstall().
*/
function uc_order_uninstall() {
$statuses = OrderStatus::loadMultiple(NULL);
if (!empty($statuses)) {
foreach ($statuses as $status) {
// Unlock OrderStatus configuration entity so it can be deleted.
$status
->setLocked(FALSE)
->save();
}
}
}
Functions
Name | Description |
---|---|
uc_order_schema | Implements hook_schema(). |
uc_order_uninstall | Implements hook_uninstall(). |