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.

Files: 
CommentFileSizeAuthor
#1 enforced_dependencies_errors-1879022-1.patch1.32 KBomegamonk
PASSED: [[SimpleTest]]: [MySQL] 39,706 pass(es).
[ View ]

Comments

StatusFileSize
new1.32 KB
PASSED: [[SimpleTest]]: [MySQL] 39,706 pass(es).
[ View ]

Added the patch.

Version:7.18» 7.x-dev
Priority:Normal» Critical
Status:Active» Needs review

That seems like a serious upgrade bug, actually.

The patch looks like it makes sense in principle... haven't reviewed it carefully, though.

Title:Enforced dependencies errors updating to 7.18Enforced dependencies errors updating to recent versions of Drupal 7

Changing title to avoid confusion (since this definitely wasn't introduced in Drupal 7.18).

Status:Needs review» Needs work

The last submitted patch, enforced_dependencies_errors-1879022-1.patch, failed testing.

Status:Needs work» Needs review

Yes, that looks correct.

MS SQL Server is not really supported by core, but I assume it is broken with PostgreSQL as well...

Status:Needs review» Reviewed & tested by the community

db_change_field() docs specify this should be done anyway. Marking RTBC.

Status:Reviewed & tested by the community» Fixed

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Drupal 7.20 was a security release only, so this issue is now scheduled for Drupal 7.21 instead.

Fixing tags accordingly.

Issue tags:+7.22 release notes

Fixing 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 :)

.