Skill 2.3.7
Detect schema drift by using SQL Database Projects
Key Concepts
A schema comparison between the project (or its dacpac) and the target database lists every object that differs, and is available in VS Code, Visual Studio and through SqlPackage. SqlPackage /Action:DeployReport produces an XML report of what a publish would change, so unexpected drops or alters reveal drift; /Action:Script produces the deployment script for review. A pipeline can run the report before deployment and fail or require approval when differences appear outside the planned change.
When a database was published with /p:RegisterDataTierApplication=True, SqlPackage /Action:DriftReport lists changes made since it was registered, and the publish property BlockWhenDriftDetected stops a deployment to a drifted registered database. Drift is resolved either by bringing the change into the project (if it should stay) or by letting the next deployment remove it.