You are here

function tablefield_repair_schema in TableField 7.2

Same name and namespace in other branches
  1. 7.3 tablefield.install \tablefield_repair_schema()
  2. 7 tablefield.install \tablefield_repair_schema()

Helper function for updating/repairing the database schema.

2 calls to tablefield_repair_schema()
tablefield_update_7000 in ./tablefield.install
Update schema to handle machine names of input filter formats.
tablefield_update_7001 in ./tablefield.install
Fix columns created by versions prior to beta1.

File

./tablefield.install, line 50
Installation options for TableField.

Code

function tablefield_repair_schema() {
  $spec = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => FALSE,
  );
  $fields = _update_7000_field_read_fields(array(
    'module' => 'tablefield',
    'storage_type' => 'field_sql_storage',
  ));
  foreach ($fields as $field_name => $field) {
    if ($field['deleted']) {
      $table = "field_deleted_data_{$field['id']}";
      $revision_table = "field_deleted_revision_{$field['id']}";
    }
    else {
      $table = "field_data_{$field['field_name']}";
      $revision_table = "field_revision_{$field['field_name']}";
    }
    $column = $field['field_name'] . '_format';
    db_change_field($table, $column, $column, $spec);
    db_change_field($revision_table, $column, $column, $spec);
  }
}