function commerce_invoice_schema in Commerce Invoice 7.2
Same name and namespace in other branches
- 7 commerce_invoice.install \commerce_invoice_schema()
Implements hook_schema().
File
- ./
commerce_invoice.install, line 10 - Install and uninstall functions for the Commerce Invoice module.
Code
function commerce_invoice_schema() {
$schema = array();
$schema['commerce_invoice'] = array(
'description' => 'The base table for invoices.',
'fields' => array(
'invoice_id' => array(
'description' => 'The primary identifier for an invoice.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'number_sequence' => array(
'description' => 'The sequential invoice number.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'number_pattern' => array(
'description' => 'The name of the pattern used to calculate the invoice number.',
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
),
'number_key' => array(
'description' => 'The key created from the pattern which differentiates sequential invoice numbers.',
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
),
'invoice_date' => array(
'description' => 'The Unix timestamp for the invoice date.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'invoice_due' => array(
'description' => 'The Unix timestamp for the invoice due date.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'invoice_status' => array(
'description' => 'The invoice status.',
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
),
'revision_id' => array(
'description' => 'The revision ID for this invoice.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The type of this invoice.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'description' => 'The {users}.uid that owns this invoice.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'order_id' => array(
'description' => 'The order ID.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'order_revision_id' => array(
'description' => 'The order revision ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'created' => array(
'description' => 'The Unix timestamp when the invoice was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the invoice was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'invoice_id',
),
'unique keys' => array(
'invoice_number' => array(
'number_pattern',
'number_key',
'number_sequence',
),
),
'indexes' => array(
'uid' => array(
'uid',
),
'order_revision' => array(
'order_id',
'order_revision_id',
),
),
'foreign keys' => array(
'order' => array(
'table' => 'commerce_order',
'columns' => array(
'order_id' => 'order_id',
),
),
'order_revision' => array(
'table' => 'commerce_order_revision',
'columns' => array(
'order_id' => 'order_id',
'order_revision_id' => 'revision_id',
),
),
'owner' => array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
),
),
);
$schema['commerce_invoice_revision'] = array(
'description' => 'Stores information about each saved revision of an invoice.',
'fields' => array(
'invoice_id' => array(
'description' => 'The {commerce_invoice}.invoice_id of the invoice this revision belongs to.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'revision_id' => array(
'description' => 'The primary identifier for this revision.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'invoice_date' => array(
'description' => 'The invoice date for this revision.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'invoice_status' => array(
'description' => 'The invoice status for this revision.',
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The invoice owner for this revision.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'revision_created' => array(
'description' => 'The Unix timestamp when the revision was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'revision_uid' => array(
'description' => 'The {users}.uid of the user who created the revision.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'log' => array(
'description' => 'A log message for the revision.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'primary key' => array(
'revision_id',
),
'indexes' => array(
'invoice_id' => array(
'invoice_id',
),
),
'foreign keys' => array(
'invoice' => array(
'table' => 'commerce_invoice',
'columns' => array(
'invoice_id' => 'invoice_id',
),
),
),
);
$schema['commerce_invoice_number_pattern'] = array(
'description' => 'Stores configurable invoice number patterns.',
'fields' => array(
'name' => array(
'description' => 'The pattern machine name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'label' => array(
'description' => 'A human-readable label for the pattern.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'skip_sequence' => array(
'description' => 'Boolean indicating whether to skip the sequence number or not.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'pattern' => array(
'description' => 'The invoice number pattern.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
// Set the default to ENTITY_CUSTOM without using the constant as it is
// not safe to use it at this point.
'default' => 0x1,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'primary key' => array(
'name',
),
);
return $schema;
}