You are here

commerce_cop.install in Commerce Custom Offline Payments 7

Install functions.

File

commerce_cop.install
View source
<?php

/**
 * @file
 * Install functions.
 */

/**
 * Implements hook_schema().
 */
function commerce_cop_schema() {
  $schema['commerce_custom_offline_payment'] = array(
    'description' => 'Custom offline payments methods for Drupal Commerce',
    'fields' => array(
      'id' => array(
        'description' => 'Machine name of payment',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'description' => 'Payment title',
        'not null' => TRUE,
        'default' => '',
        'translatable' => TRUE,
      ),
      'description' => array(
        'type' => 'text',
        'size' => 'normal',
        'description' => 'Description for the payment method.',
        'translatable' => TRUE,
      ),
      'information' => array(
        'type' => 'text',
        'size' => 'big',
        'description' => 'Default information for the payment method.',
        'translatable' => TRUE,
      ),
      'format' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => 'The {filter_format}.format of the payment information.',
      ),
      'status' => array(
        'description' => '',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'checkout' => array(
        'description' => '',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
      ),
      'terminal' => array(
        'description' => '',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
      ),
      'fieldable' => array(
        'description' => '',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'machine_name' => array(
        'id',
      ),
    ),
    'indexes' => array(
      'permission' => array(
        'id',
      ),
    ),
  );
  return $schema;
}

/**
 * Add 'checkout' and 'terminal' columns to the 'commerce_custom_offline_payment' table
 * to extend the payments definitions/settings.
*/
function commerce_cop_update_7000() {

  // 'checkout' table field.
  $field = array(
    'description' => '',
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 1,
  );
  db_add_field('commerce_custom_offline_payment', 'checkout', $field);

  // 'terminal' table field.
  $field = array(
    'description' => '',
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 1,
  );
  db_add_field('commerce_custom_offline_payment', 'terminal', $field);
}

/**
 * Add 'fieldable' columns to the 'commerce_custom_offline_payment' table
 * for for Drupal Commerce Payment Transaction Fields.
 * @see https://drupal.org/project/commerce_payment_fields
*/
function commerce_cop_update_7001() {

  // 'fieldable' table field.
  $field = array(
    'description' => '',
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  );
  db_add_field('commerce_custom_offline_payment', 'fieldable', $field);
}

/**
 * Drop and recreate 'machine name' unique key replacing space with underscore
 * Required for SQL Server compatibility
 */
function commerce_cop_update_7002() {
  db_drop_unique_key('commerce_custom_offline_payment', 'machine name');
  db_add_unique_key('commerce_custom_offline_payment', 'machine_name', array(
    'id',
  ));
}

Functions

Namesort descending Description
commerce_cop_schema Implements hook_schema().
commerce_cop_update_7000 Add 'checkout' and 'terminal' columns to the 'commerce_custom_offline_payment' table to extend the payments definitions/settings.
commerce_cop_update_7001 Add 'fieldable' columns to the 'commerce_custom_offline_payment' table for for Drupal Commerce Payment Transaction Fields.
commerce_cop_update_7002 Drop and recreate 'machine name' unique key replacing space with underscore Required for SQL Server compatibility