jeremyevans/sequel — pull request #515 by munkyboy (2012-07-13 21:32:37+00:00)
Title: MSSQL makes it difficult to drop a column which has a default value

In MSSQL, when you create a column with a default value, it results in a 'default constraint' being created. You can not drop said column unless you first drop the constraint. I believe Sequel's support for `drop_column(:my_col, :cascade => true)` is meant to solve this problem, at least for PostgreSQL. Unfortunately, AFAIK, there is no analogous statement in MSSQL. This patch adds a Database instance method to get the name of a default constraint for a given column. I'm currently using it like this:

```ruby
Sequel.migration do
up do
constraint_name = default_constraint_name(:items, :name)
alter_table(:items) do
drop_constraint constraint_name
drop_column :name
end
end
end
```

I considered adding a MSSQL handler for the `:cascade` option in `drop_column` but the resulting SQL is not as 'atomic' as what you normally get out of `drop_column`