function uc_discounts_schema in Ubercart Discounts (Alternative) 7.2
Same name and namespace in other branches
- 6.2 uc_discounts/uc_discounts.install \uc_discounts_schema()
Implements hook_schema().
File
- uc_discounts/
uc_discounts.install, line 11 - Install, update, and uninstall functions for uc_discounts module.
Code
function uc_discounts_schema() {
$schema = array();
$schema['uc_discounts'] = array(
'fields' => array(
'discount_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'short_description' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
),
'qualifying_type' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'qualifying_amount' => array(
'type' => 'float',
'not null' => TRUE,
'default' => 0.0,
'description' => 'Minimum quantity or price required to qualify for this discount.',
),
'has_qualifying_amount_max' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether or not this discount has a max qualifying amount.',
),
'qualifying_amount_max' => array(
'type' => 'float',
'not null' => TRUE,
'default' => 0.0,
'description' => 'Maximum quantity or price required to qualify for this discount.',
),
'discount_type' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'discount_amount' => array(
'type' => 'float',
'not null' => TRUE,
'default' => 0.0,
'description' => 'Amount to discount (i.e. 1 free item, 25%, or $2.00)',
),
'requires_code' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'Requires code to activate discount.',
),
'filter_type' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'description' => 'What type of object to filter on.',
),
'has_role_filter' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether or not this discount filters based on role.',
),
'use_only_discounted_products_to_qualify' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Calculate the order subtotal using only discounted products.',
),
'requires_single_product_to_qualify' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'Requires qualifying amount to come from a single product.',
),
'required_product_type' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'max_times_applied' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'description' => 'Number of times this discount can be applied to a single cart (0 for unlimited).',
),
'limit_max_times_applied' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether or not to further limit the maximum times applied to the number of qualifying products.',
),
'can_be_combined_with_other_discounts' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether or not this discount will be applied if other discounts are.',
),
'add_to_cart' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
'default' => 0,
'description' => 'Indicates whether free items are added to cart by the module.',
),
'max_uses' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Number of times this discount can be applied (0 for no limit).',
),
'max_uses_per_user' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'description' => 'Number of times this discount can be applied to a particular user (0 for unlimited).',
),
'max_uses_per_code' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Number of times this discount can be applied for a particular code (0 for unlimited).',
),
'has_activation' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether or not discount has an activation date.',
),
'activates_on' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The activation date and time as a unix timestamp.',
),
'has_expiration' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether or not discount has an expiration.',
),
'expiration' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The exipration date and time as a unix timestamp.',
),
'is_active' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
'default' => 0,
'description' => 'Convenience flag to state whether code is published on site or not.',
),
'weight' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'insert_timestamp' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The insert date and time as a unix timestamp.',
),
),
'primary key' => array(
'discount_id',
),
);
$schema['uc_discounts_codes'] = array(
'fields' => array(
'discount_code_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'code' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'discount_code_id',
),
'indexes' => array(
'discount_id' => array(
'discount_id',
),
),
);
$schema['uc_discounts_products'] = array(
'fields' => array(
'discount_product_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'product_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {uc_products}.nid of the product being discounted.',
),
'grouping' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'The grouping of this entry since required products be used in discount qualification or application.',
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
'primary key' => array(
'discount_product_id',
),
);
$schema['uc_discounts_terms'] = array(
'fields' => array(
'discount_term_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'term_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {term}.tid of the term being discounted.',
),
'grouping' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'The grouping of this entry since required products be used in discount qualification or application.',
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
'primary key' => array(
'discount_term_id',
),
);
$schema['uc_discounts_skus'] = array(
'fields' => array(
'discount_sku_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'sku' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'The {uc_products}.model of the product being discounted.',
),
'grouping' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'The grouping of this entry since required products be used in discount qualification or application.',
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
'primary key' => array(
'discount_sku_id',
),
);
$schema['uc_discounts_classes'] = array(
'fields' => array(
'discount_class_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'class' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => 'The {node_type}.type of the product being discounted.',
),
'grouping' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'The grouping of this entry since required products be used in discount qualification or application.',
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
'primary key' => array(
'discount_class_id',
),
);
$schema['uc_discounts_authors'] = array(
'fields' => array(
'discount_author_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'author_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {users}.uid of the author being discounted.',
),
'grouping' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'The grouping of this entry since required products be used in discount qualification or application.',
),
),
'indexes' => array(
'discount_id_grouping' => array(
'discount_id',
'grouping',
),
),
'primary key' => array(
'discount_author_id',
),
);
$schema['uc_discounts_roles'] = array(
'fields' => array(
'discount_role_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'role_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The {role}.rid of the role required.',
),
),
'primary key' => array(
'discount_role_id',
),
'indexes' => array(
'discount_id' => array(
'discount_id',
),
),
);
$schema['uc_discounts_uses'] = array(
'fields' => array(
'discount_use_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'discount_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {uc_discounts}.discount_id of the discount.',
),
'user_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid of the user who used the discount or (0 if anonymous).',
),
'order_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "The {uc_orders}.order_id of the user's order.",
),
'code' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
'description' => 'Code used for discount.',
),
'times_applied' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'description' => 'Number of times this discount was applied.',
),
'amount' => array(
'type' => 'float',
'not null' => TRUE,
'default' => 0,
'description' => 'Total amount of discount.',
),
'insert_timestamp' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The insert date and time as a unix timestamp.',
),
),
'primary key' => array(
'discount_use_id',
),
'indexes' => array(
'discount_id' => array(
'discount_id',
),
),
);
$schema['uc_discounts_order_codes'] = array(
'fields' => array(
'order_discount_id' => array(
'type' => 'serial',
'not null' => TRUE,
),
'order_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => "The {uc_orders}.order_id of the user's order.",
),
'codes' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Newline delimited codes string for order.',
),
),
'primary key' => array(
'order_discount_id',
),
'indexes' => array(
'order_id' => array(
'order_id',
),
),
);
return $schema;
}