Commit a01efe4a authored by Josha Hubbers's avatar Josha Hubbers Committed by paulvandenburg
Browse files

Issue #3080522 by paulvandenburg, JoshaHubbers: PDO exception after module upgrades

parent 86081510
Loading
Loading
Loading
Loading
+35 −0
Changes for modules/dvg/dvg_domain_prefix/dvg_domain_prefix.install: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Installation and uninstallation functions.
 */

/**
 * Fix problem with redirect update to add status field.
 */
function dvg_domain_prefix_update_7001() {
  $domains = domain_domains();
  $tables_to_alter = array('redirect');
  foreach ($domains as $domain) {
    $tables_to_alter[] = 'domain_' . $domain['domain_id'] . '_redirect';
  }

  foreach ($tables_to_alter as $table) {
    if (db_table_exists($table) && !db_field_exists($table, 'status')) {
      db_add_field($table, 'status', array(
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 1,
        'description' => 'Boolean indicating whether the redirect is enabled (visible to non-administrators).',
      ));
      db_drop_index($table, 'source_language');
      db_add_index($table, 'status_source_language', array(
        'status',
        'source',
        'language',
      ));
    }
  }
}