You are here

function styles_update_7212 in Styles 7.2

Create the styles_presets and styles_preset_instances tables.

File

./styles.install, line 235
Install, update and uninstall functions for the Styles module.

Code

function styles_update_7212() {
  $schema = array();
  $schema['styles_presets'] = array(
    'description' => 'Stores configuration options for styles presets.',
    'fields' => array(
      'pid' => array(
        'description' => 'The primary identifier for a style preset.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'field_type' => array(
        'description' => 'The field type.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'container_name' => array(
        'description' => 'The container name',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The preset name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'description' => array(
        'description' => 'The preset description.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
    ),
    'primary key' => array(
      'pid',
    ),
    'indexes' => array(
      'field_type' => array(
        'field_type',
      ),
      'container_name' => array(
        'container_name',
      ),
      'name' => array(
        'name',
      ),
    ),
  );
  $schema['styles_preset_instances'] = array(
    'description' => 'Stores the settings for each container/style preset.',
    'fields' => array(
      'sid' => array(
        'description' => 'The primary identifier for a style.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'pid' => array(
        'description' => 'The primary identifier for a style preset.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'foreign keys' => array(
      'sid' => array(
        'table' => 'styles',
        'columns' => array(
          'sid' => 'sid',
        ),
      ),
      'pid' => array(
        'table' => 'styles_presets',
        'columns' => array(
          'pid' => 'pid',
        ),
      ),
    ),
    'indexes' => array(
      'sid' => array(
        'sid',
      ),
      'pid' => array(
        'pid',
      ),
    ),
  );
  if (!db_table_exists('styles_presets')) {
    db_create_table('styles_presets', $schema['styles_presets']);
  }
  if (!db_table_exists('styles_preset_instances')) {
    db_create_table('styles_preset_instances', $schema['styles_preset_instances']);
  }
}