I'm running this on Microsoft SQL Server. When I run the update script to change from 7.x-3.20 to 7.x-4.0, I get the following error:

Update #7416 PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Object 'webform_submissions.serial' cannot be renamed because the object participates in enforced dependencies.: EXEC sp_rename :old, :new, :type; Array ( [:old] => webform_submissions.serial [:new] => serial_old [:type] => COLUMN ) in db_change_field() (line 3017 of C:\inetpub\wwwroot\includes\database\database.inc).

Comments

quicksketch’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

Thanks for filing this report. We don't have many SQLServer users so I appreciate the report. This may be difficult for me to fix because I don't have a instance of SQLServer at my disposal, and it's unlikely I'd take the time to set one up. I may need help from you to test potential fixes.

I think this may be caused by the indexes that are added to the "serial" database column when it is first created. Some DB backends don't allow you to modify a column while indexes exist on that column. Since we add a unique index but then later try to change the column to add the "NOT NULL" option, this might be causing the error. To fix this, we just need to add the index after the update is finished, rather than at the beginning when it first adds the column. I've attached a patch that does this very thing.

Could you test this out? You'll need to start from a backup of your database before you attempted the upgrade.

Status: Needs review » Needs work

The last submitted patch, 1: webform_serial_index_update-2241497.patch, failed testing.

quicksketch’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: webform_serial_index_update-2241497.patch, failed testing.

  • Commit 56941b5 on 7.x-4.x by quicksketch:
    Issue #2241497: PDO Exception on MSSQL in update 7416.
    
quicksketch’s picture

Status: Needs work » Fixed

I've gone ahead and committed this change, even if we don't have confirmation it resolves this particular problem. The documentation for db_change_field() specifically states that keys have to be removed before modifying columns that use them, so this puts us inline with that recommendation. I think there's a good chance this will resolve this MSSQL issue, but I don't have a way of confirming. @irriadin, if you get a chance to re-run your update after applying this patch, please post your results and set this back to "active" if it hasn't been fixed.

fenstrat’s picture

Version: 7.x-4.0-rc1 » 8.x-4.x-dev
Assigned: Unassigned » fenstrat
Status: Fixed » Patch (to be ported)

Needs porting to 8.x-4.x.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.0-rc1
Assigned: fenstrat » Unassigned
Status: Patch (to be ported) » Fixed

Committed and pushed 56941b5 to 8.x-4.x. Thanks!

  • Commit 9faaf94 on 8.x-4.x authored by quicksketch, committed by fenstrat:
    Issue #2241497 by quicksketch: PDO Exception on MSSQL in update 7416.
    
Ryan S’s picture

Sorry, I wasn't able to test until now, but the patch worked! Thanks!

quicksketch’s picture

@irriadin, woo! Thanks for the followup. This patch is in the latest releases already.

Status: Fixed » Closed (fixed)

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