Summary
CI/CD for SQL Database Projects brings the same automation, consistency, and safety nets to database development that application teams rely on for their code.
In this module, you learned how to:
- Create, build, and validate SQL Database Projects: Define database objects in declarative T-SQL files, build them into
.dacpacartifacts, and validate references and syntax against a target platform using the SDK-styleMicrosoft.Build.Sqlproject format. - Configure source control and manage reference data: Place SQL database projects in Git, organize files by object type, and use predeployment and post-deployment scripts with SQLCMD
:rincludes to manage reference data alongside the schema. - Manage branching, pull requests, and conflict resolution: Use feature branches for database changes, review T-SQL diffs in pull requests, resolve merge conflicts at the object level, and validate merged results with a project build.
- Detect and resolve schema drift: Compare live databases against SQL database projects using schema comparison tools, automate drift detection with SqlPackage Extract, and review planned changes with deployment reports and scripts.
- Implement CI/CD pipelines with deployment controls: Build and deploy
.dacpacfiles with GitHub Actions (azure/sql-action) and Azure DevOps (SqlAzureDacpacDeployment), manage secrets through repository secrets and Azure Key Vault, and protect production with environment approvals, branch policies, and code owners. - Design and implement a testing strategy: Create SQL Server unit tests with test conditions (Row Count, Scalar Value, Expected Schema), write negative tests for error handling, and integrate tests into CI/CD pipelines to catch logic errors before deployment.
Learn more
- What are SQL database projects?
- Get started with SQL database projects
- SQL Server Data Tools, SDK-style (preview)
- Predeployment and post-deployment scripts
- Schema comparison overview
- Compare a database and a project
- SQL projects automation
- About branches and branch policies
- Verify database code by using SQL Server unit tests
- Azure SQL Deploy action (GitHub)
- SqlAzureDacpacDeployment task reference