atlas: Bug: When deleting colums Atlas should delete constaints first (SQL Server)

When deleting columns, Atlas is generating SQL:

ALTER TABLE <TableName> DROP COLUMN <ColumnName>

But this will fail if there is a default constraint on the column:

Msg 5074, Level 16, State 1, Line 3
The object 'DEFAUL_...' is dependent on column '<ColumnName>'.
Msg 4922, Level 16, State 9, Line 3
ALTER TABLE DROP COLUMN <ColumnName> failed because one or more objects access this column.

Atlas should drop default constraint before dropping the column.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

I want to change it from DEFAULT_ to DF_ to match what Microsoft SQL Server Management Studio names them.

Me too, I’ll patch this soon.

We use mixed “Versioned Migration Authoring”.

Problem is that we have an existing live database. We scripted the database using schema inspect. But because Atlas does not have default constrains names when we do migrate diff it generates migration that will not work on live.

And because Atlas ignores default constrains names, there could be schema drift too. So created migration could fail on other environments.