You are here

mailchimp_ecommerce.install in Mailchimp E-Commerce 7

Same filename and directory in other branches
  1. 8 mailchimp_ecommerce.install

Mailchimp eCommerce install and update hooks.

File

mailchimp_ecommerce.install
View source
<?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');
  }
}

Functions

Namesort descending Description
mailchimp_ecommerce_schema Implements hook_schema().
mailchimp_ecommerce_uninstall Implements hook_uninstall().
mailchimp_ecommerce_update_7002 Install the 'mailchimp_ecommerce_customer' table schema.
mailchimp_ecommerce_update_7003 Rename 'mailchimp_ecommerce' table to 'mailchimp_ecommerce_customer'.