Doctrine 1
  1. Doctrine 1
  2. DC-584

MSSQL Server: Cannot alter / drop columns which have indexes or constraints applied to them


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.2.3
    • Component/s: Migrations
    • Labels:
    • Environment:
      PHP 5.3
      MSSQL Server 2008


      SQL Server will not allow attempts to alter or drop columns with indexes or constraints applied to them, because they are dependent on the column. In addition to this, SQL Server's syntax for altering columns is different for that of adding them in that it does not allow default value constraints to be present in the alter statement.

      I've attached a patch which attempts to circumvent this issue by allowing the author of the changeset to provide a name for the default constraint, which SQL Server supports. Giving the constraint a name of our choosing allows us to reference and drop it before running a command against a constrained column.

      In the case of an ALTER query the default constraint portion is spliced and subsequently run.

      When dropping a column the author need only make sure they name the constraint, or know its name, then drop it before the query is run.

      1. DC584TestCase.php
        7 kB
        Craig Marvelley
      2. mssql_default_constraint_patch.patch
        5 kB
        Craig Marvelley


        Craig Marvelley added a comment -

        Added patch and test cases for this issue.

        Craig Marvelley added a comment - Added patch and test cases for this issue.


          • Assignee:
            Jonathan H. Wage
            Craig Marvelley
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: