I'm working on SQL Server and am trying to drop a column. The table schema is as below:
CREATE TABLE [dbo].[XYZ](
[ID] [int] NOT NULL,
[DSC] [varchar](255) NULL,
[LOWER_LIMIT] [int] NOT NULL,
[UPPER_LIMIT] [int] NOT NULL,
CONSTRAINT [XP_XYZ] PRIMARY KEY CLUSTERED
(
[ID] ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
When I attempt to drop the column :
ALTER TABLE [SENSOR]
DROP COLUMN LOWER_LIMIT;
I'm asked to drop the constraint before:
The object 'DF__SENSOR__LOWER_LI__08B54D69' is dependent on column 'LOWER_LIMIT'.
Msg 4922, Level 16, State 9, Line 45
ALTER TABLE DROP COLUMN LOWER_LIMIT failed because one or more objects access this column.
Now I'm writing a flyway script to drop the column and I would not know the constraint until I run the drop command as the constraint changes in higher environments I attempt to drop the column. How do I draft my flyway to drop this column?