-
Notifications
You must be signed in to change notification settings - Fork 0
/
uc_alternative_price.install
106 lines (100 loc) · 2.64 KB
/
uc_alternative_price.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
// $Id$
/**
* Implementation of hook_schema().
*/
function uc_alternative_price_schema() {
$schema['uc_alternative_prices'] = array(
'description' => t('alternative price table for Ubercart'),
'fields' => array(
'pfid' => array(
'description' => t('price id'),
'type' => 'int',
'size' => 'medium',
'not null' => TRUE,
),
'alternative_price' => array(
'description' => t('alternative price'),
'type' => 'numeric',
'precision' => 10,
'scale' => 2,
'not null' => TRUE,
'default' => 0.00,
),
'price_low' => array(
'description' => t('low price'),
'type' => 'numeric',
'precision' => 10,
'scale' => 2,
'not null' => FALSE,
),
'price_high' => array(
'description' => t('high price'),
'type' => 'numeric',
'precision' => 10,
'scale' => 2,
'not null' => FALSE,
),
'discount' => array(
'description' => t('the discount'),
'type' => 'numeric',
'precision' => 10,
'scale' => 2,
'not null' => FALSE,
),
'alternative_description' => array(
'description' => t('alternative description'),
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'standard_description' => array(
'description' => t('normal or standard description'),
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'indexes' => array(
'pfid' => array('pfid'),
),
);
return $schema;
}
/**
* Implementation of hook_schema_alter().
*/
function uc_alternative_price_schema_alter(&$schema) {
$schema['uc_products']['fields']['unique'] = array(
'description' => t('makes product unique'),
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
}
/**
* Implementation of hook_install().
*/
function uc_alternative_price_install() {
drupal_install_schema('uc_alternative_price');
$ret = array();
$schema['uc_products'] = array();
uc_alternative_price_schema_alter($schema);
foreach ($schema['uc_products']['fields'] as $name => $spec) {
db_add_field($ret, 'uc_products', $name, $spec);
}
}
/**
* Implementation of hook_uninstall().
*/
function uc_alternative_price_uninstall() {
drupal_uninstall_schema('uc_alternative_price');
$ret = array();
$schema['uc_products'] = array();
uc_alternative_price_schema_alter($schema);
foreach ($schema['uc_products']['fields'] as $name => $spec) {
db_drop_field($ret, 'uc_products', $name, $spec);
}
}