Azure / sql-action

🚀 Deploy changes to your SQL database easily with SQL projects or SQL scripts and sql-action for GitHub workflows
MIT License
99 stars 54 forks source link

Does not support dropping a coumn when the table is not empty. #225

Closed wangrandk closed 3 weeks ago

wangrandk commented 3 months ago

when you want to drop a column on an existing tabel with data, even i set all value of the coumn to NULL, but the workflow still gives error:

*** Could not deploy package. Warning SQL72015: The column [dbo].[employees].[Salary] is being dropped, data loss could occur. Warning SQL72030: The project and target databases have different collation settings. Deployment errors might occur. Error SQL72014: Core Microsoft SqlClient Data Provider: Msg 50000, Level 16, State 127, Line 6 Rows were detected. The schema update is terminating because data loss might occur. Error SQL72045: Script execution error. The executed script: IF EXISTS (SELECT TOP 1 1 FROM [dbo].[employees]) RAISERROR (N'Rows were detected. The schema update is terminating because data loss might occur.', 16, 127) WITH NOWAIT;

how can i fix it or make a work round? anyone has best practice for it?

zijchen commented 3 months ago

Sqlpackage safeguards you against potential data loss. If you wish to disable that, you can add /p:BlockOnPossibleDataLoss=false to the arguments input. Refer to this page for full documentation: https://learn.microsoft.com/sql/tools/sqlpackage/sqlpackage-publish

dzsquared commented 3 weeks ago

Closing this issue as @zijchen provided the answer - please feel free to file additional issues with other questions!