Newer
Older
<?php
/**
* Implements hook_schema().
*/
function commerce_coupon_schema() {
$schema = array();
$schema['commerce_coupon'] = array(
'description' => 'The base table for coupons.',
'fields' => array(
'coupon_id' => array(
'description' => 'The primary identifier for the coupon.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The {commerce_coupon_type}.type of this coupon.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
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
'code' => array(
'description' => 'The code provided to the customer.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'amount' => array(
'description' => 'The coupon amount.',
'type' => 'float',
'not null' => TRUE,
'default' => 0,
),
'is_percentage' => array(
'description' => 'Indicates if this coupon is a percentage or an fixed amount.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'is_active' => array(
'description' => 'Indicates if this coupon is active or not.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => 'The Unix timestamp when the coupon was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the coupon was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'data' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
'description' => 'Everything else, serialized.',
),
),
'primary key' => array('coupon_id'),
'code' => array('code'),
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
107
108
109
110
111
112
113
114
115
116
117
);
$schema['commerce_coupon_type'] = array(
'description' => 'Stores information about all defined coupon types.',
'fields' => array(
'type_id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique coupon type ID.',
),
'type' => array(
'description' => 'The machine-readable name of this coupon type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this coupon type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this coupon type in relation to others.',
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of additional data related to this coupon type.',
),
) + entity_exportable_schema_fields(),
'primary key' => array('type_id'),
'unique keys' => array(
'type' => array('type'),
),
$schema['commerce_coupon_log'] = array(
'description' => 'Stores the usage of coupons.',
'fields' => array(
'log_id' => array(
'description' => 'The primary identifier for the log entry.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'coupon_id' => array(
'description' => 'The referenced coupon.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'The referenced user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'order_id' => array(
'description' => 'The referenced order id.',
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
'unsigned' => TRUE,
'not null' => TRUE,
),
'is_accepted' => array(
'description' => 'Indicates if this coupon is accepted.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'is_processed' => array(
'description' => 'Indicates if this coupon is processed. This is set to true, when the order is completed.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => 'The Unix timestamp when the log was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the log was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('log_id'),
'foreign keys' => array(
'coupon' => array(
'table' => 'commerce_coupon',
'columns' => array('coupon_id' => 'coupon_id'),
),
'order' => array(
'table' => 'commerce_order',
'columns' => array('order_id' => 'order_id'),
),
'user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);