microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
356 stars 20 forks source link

Add support for ALTER COLUMN WITH (ONLINE=ON) #483

Open HamsterExAstris opened 3 months ago

HamsterExAstris commented 3 months ago

Is your feature request related to a problem? Please describe. SQL Server Enterprise Edition and Azure SQL support the concept of "online" schema operations, which perform the operations more slowly but with shorter locking periods. I would like to have the option for sqlpackage to generate scripts that take advantage of this functionality where possible for ALTER COLUMN commands.

Describe the solution you'd like Either when /p:PerformIndexOperationsOnline or a new parameter is enabled, emit WITH (ONLINE = ON) when scripting eligible ALTER COLUMN commands.

Describe alternatives you've considered A custom deployment contributor that finds eligible operations and updates the SQL before being emitted, similar to the one linked here for index operations.

Additional context

27 provided support for WITH (ONLINE = ON) for index operations. Per the documentation, ALTER COLUMN supports it as well, but enabling /p:PerformIndexOperationsOnline only enables it for index operations, not ALTER COLUMN.

jvdslikke commented 1 month ago

This could also be accomplished with the ELEVATE_ONLINE database scoped configuration setting: https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-database-scoped-configuration-transact-sql?view=sql-server-ver16#elevate_online---off--when_supported--fail_unsupported-