<?php

/**
 * @file
 * Install and update hooks for commerce_autosku
 */

function commerce_autosku_schema() {
  $schema['commerce_autosku_patterns'] = array(
  'description' => 'TODO: please describe this table!',
  'fields' => array(
    'product_type' => array(
      'description' => 'Product type identifier.',
      'type' => 'varchar',
      'length' => 32,
      'not null' => TRUE,
    ),
    'pattern' => array(
      'description' => 'Token replacement pattern.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => TRUE,
    ),
    'advanced' => array(
      'description' => 'Serialized array of additional settings.',
      'type' => 'blob',
      'not null' => FALSE,
      'size' => 'big',
      'serialize' => TRUE,
    )
  ),
  'primary key' => array('product_type'),
);
  return $schema;
}

/**
 * Change pattern field from 128 to 255 characters in commerce_autosku_patterns.
 */
function commerce_autosku_update_7101(&$sandbox) {
  $spec = array(
    'description' => 'Token replacement pattern.',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
  );
  db_change_field('commerce_autosku_patterns', 'pattern', 'pattern', $spec);
}

/**
 * Change product_type field from 55 to 32 characters in commerce_autosku_patterns.
 */
function commerce_autosku_update_7102(&$sandbox) {
  $spec = array(
    'description' => 'Product type identifier.',
    'type' => 'varchar',
    'length' => 32,
    'not null' => TRUE,
  );
  db_change_field('commerce_autosku_patterns', 'product_type', 'product_type', $spec);
}
