You are here

function yamlform_update_8052 in YAML Form 8

Issue #2806263: Add property column to submission data table. Update 'yamlform_submission_data' schema.

File

includes/yamlform.update.inc, line 1045
YAML Form module update hooks.

Code

function yamlform_update_8052() {
  $table = 'yamlform_submission_data';

  // Delete primary keys.
  db_drop_primary_key($table);

  // Move delta to property.
  $field = 'delta';
  $new_field = 'property';
  $property_spec = [
    'description' => "The property of the element's value.",
    'type' => 'varchar',
    'length' => 128,
    'not null' => TRUE,
    'default' => '',
  ];
  db_change_field($table, $field, $new_field, $property_spec);

  // Add new delta.
  $delta_spec = [
    'description' => "The delta of the element's value.",
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ];
  db_add_field($table, 'delta', $delta_spec);

  // Add new primary keys.
  db_add_primary_key($table, [
    'sid',
    'name',
    'property',
    'delta',
  ]);

  // Flush all caches to make sure the db schema is up-to-date.
  drupal_flush_all_caches();
}