while updating from 1.0 to dev:

The following updates returned messages

pdm module

Update #7002
Failed: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL DEFAULT ''' at line 1: ALTER TABLE {pdm} ADD `attributes` NOT NULL DEFAULT ''; Array ( ) in db_add_field() (Zeile 2841 von /path/to/workspace/includes/database/database.inc).

CommentFileSizeAuthor
#4 pdm_upgrade_errors.patch673 byteserikhopp

Comments

Andre-B’s picture

Issue summary: View changes
Andre-B’s picture

/**
 * Add a disable_ajax field to schema.
 */
function pdm_update_7002() {
  $field = array(
    'type' => 'varchar',
    'size' => '255',
    'not null' => TRUE,
    'default' => '',
  );
  if (!db_field_exists('pdm', 'attributes')) {
    db_add_field('pdm', 'attributes', $field);
  }
  if (!db_field_exists('pdm_archive', 'attributes')) {
    db_add_field('pdm_archive', 'attributes', $field);
  }
}

/**
 * Add new pdm_archive table to schema.
 */
function pdm_update_7010() {
  if (!db_table_exists('pdm_archive')) {
    $schema = pdm_schema();
    db_create_table('pdm_archive', $schema['pdm_archive']);
  }
}

this is messed up too - there is no pdm_archive table in 7002 because it is added in 7010

Andre-B’s picture

pdm_update_7002 needs to be

/**
 * Add a disable_ajax field to schema.
 */
function pdm_update_7002() {
  $field = array(
    'type' => 'varchar',
    'length' => '255',
    'not null' => TRUE,
    'default' => '',
  );
  if (!db_field_exists('pdm', 'attributes')) {
    db_add_field('pdm', 'attributes', $field);
  }
}

if I understood correctly there is no size for varchar but length, so pdm_update_7011 needs to become

/**
 * Add a attributes field to schema.
 *
 * Likely not needed in an upgrade from 1.1, but needed in an upgrade from 1.0
 */
function pdm_update_7011() {
  $field = array(
    'type' => 'varchar',
    'length' => '255',
    'not null' => TRUE,
    'default' => '',
  );
  if (!db_field_exists('pdm', 'attributes')) {
    db_add_field('pdm', 'attributes', $field);
  }
  if (!db_field_exists('pdm_archive', 'attributes')) {
    db_add_field('pdm_archive', 'attributes', $field);
  }
}

as well

erikhopp’s picture

Status: Active » Needs review
StatusFileSize
new673 bytes

It looks like I've run into this and can confirm that the issues and fixes Andre-B cites here are correct. I've create a patch with the changes suggested which seems to get you through the upgrade process ok. Though I think I've run into additional errors afterwards. That will be a new ticket.

glynster’s picture

RTBC this resolves the problem!

soyarma’s picture

Applied to dev

  • erikhopp authored 9b40d54 on 7.x-1.x
    Issue #2149857 by Andre-B: update path broken
    
soyarma’s picture

Assigned: Unassigned » soyarma
Status: Needs review » Closed (fixed)