forked from thinkshout/mailchimp_ecommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailchimp_ecommerce.install
79 lines (73 loc) · 2.08 KB
/
mailchimp_ecommerce.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
<?php
/**
* @file
* MailChimp eCommerce install and update hooks.
*/
/**
* Implements hook_uninstall().
*/
function mailchimp_ecommerce_uninstall() {
variable_del('mailchimp_ecommerce_store_id');
variable_del('mailchimp_ecommerce_currency');
variable_del('mailchimp_ecommerce_list_id');
variable_del('mailchimp_ecommerce_store_name');
variable_del('mailchimp_ecommerce_store_domain');
}
/**
* Implements hook_schema().
*/
function mailchimp_ecommerce_schema() {
$schema['mailchimp_ecommerce_customer'] = [
'description' => 'Maintains a connection between carts, orders and a MailChimp customer.',
'fields' => [
'mailchimp_customer_id' => [
'description' => 'Primary Key (unique ID).',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'mail' => [
'description' => 'The customer email.',
'type' => 'varchar',
'length' => 254,
'not null' => FALSE,
],
'orders_count' => [
'type' => 'int',
'description' => 'Total orders for this customer.',
'unsigned' => TRUE,
'default' => 0,
],
'total_spent' => [
'type' => 'numeric',
'description' => 'Total amount spent by this customer.',
'unsigned' => TRUE,
'precision' => 19,
'scale' => 6,
'default' => 0,
],
],
'primary key' => ['mailchimp_customer_id'],
'indexes' => [
'mail' => ['mail'],
],
];
return $schema;
}
/**
* Install the 'mailchimp_ecommerce_customer' table schema.
*/
function mailchimp_ecommerce_update_7002() {
drupal_install_schema('mailchimp_ecommerce_customer');
}
/**
* Rename 'mailchimp_ecommerce' table to 'mailchimp_ecommerce_customer'.
*/
function mailchimp_ecommerce_update_7003() {
// At one point the schema defined a table named 'mailchimp_ecommerce',
// which should have been named 'mailchimp_ecommerce_customer'.
// The table is renamed here, if it exists.
if (db_table_exists('mailchimp_ecommerce')) {
db_rename_table('mailchimp_ecommerce', 'mailchimp_ecommerce_customer');
}
}