Doctrine 1
  1. Doctrine 1
  2. DC-584

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

    Details

    • 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:
      None
    • Environment:
      PHP 5.3
      MSSQL Server 2008

      Description

      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

        Activity

        Hide
        Craig Marvelley added a comment -

        Added patch and test cases for this issue.

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

          People

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

            Dates

            • Created:
              Updated:
              Resolved: