Problem/Motivation
While updating a Drupal 7.13 installation to Drupal 7.18, I ran across a couple of errors. The errors occurred when using Microsoft SQL, but not when using MySQL.
The upgrade error messages are:
system module
Update #7073
•Failed: PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Object 'file_managed.uri' cannot be renamed because the object participates in enforced dependencies.: EXEC sp_rename :old, :new, :type; Array ( [:old] => file_managed.uri [:new] => uri_old [:type] => COLUMN ) in db_change_field() (line 2988 of C:\inetpub\wwwroot\DrupalKickstart\includes\database\database.inc).
and
node module
Update #7013
•Failed: PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Object 'node.vid' cannot be renamed because the object participates in enforced dependencies.: EXEC sp_rename :old, :new, :type; Array ( [:old] => node.vid [:new] => vid_old [:type] => COLUMN ) in db_change_field() (line 2988 of C:\inetpub\wwwroot\DrupalKickstart\includes\database\database.inc).
Proposed resolution
Referencing the db_change_field() comments, "To maintain database portability, you have to explicitly recreate all indices and primary keys that are using the changed field". The comments go on to say that ALL affected keys (unique keys, in this instance) have to be dropped. I created a patch that drops the unique key and re-adds it after db_change_field() has run for both the system and node updates mentioned in the error.
Comment | File | Size | Author |
---|---|---|---|
#1 | enforced_dependencies_errors-1879022-1.patch | 1.32 KB | omegamonk |
Comments
Comment #1
omegamonk CreditAttribution: omegamonk commentedAdded the patch.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedThat seems like a serious upgrade bug, actually.
The patch looks like it makes sense in principle... haven't reviewed it carefully, though.
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedChanging title to avoid confusion (since this definitely wasn't introduced in Drupal 7.18).
Comment #5
Berdir#1: enforced_dependencies_errors-1879022-1.patch queued for re-testing.
Comment #6
BerdirYes, that looks correct.
MS SQL Server is not really supported by core, but I assume it is broken with PostgreSQL as well...
Comment #7
catchdb_change_field() docs specify this should be done anyway. Marking RTBC.
Comment #8
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/da660bb
Comment #10
David_Rothstein CreditAttribution: David_Rothstein commentedDrupal 7.20 was a security release only, so this issue is now scheduled for Drupal 7.21 instead.
Fixing tags accordingly.
Comment #11
David_Rothstein CreditAttribution: David_Rothstein commentedFixing tags since Drupal 7.21 only contained a fix to deal with fallout from the Drupal 7.20 security release. Hopefully this is really the last time I do this and this will be released in Drupal 7.22 for real :)
Comment #12
David_Rothstein CreditAttribution: David_Rothstein commented.