2. Issues with traditional Database
Development
1. Data is hard to manage. You can overwrite and redeploy your code from scratch every time, but
the same cannot be done with data. Databases have existing data which needs to be persisted
and hence it cannot be wiped off and recreated during deployments – just like the code.
2. Having no Source Control for your database objects implies that there is no versioning information
available for your database changes. Production is the version and system of truth. This makes it
almost impossible to unit test your changes and automate your deployments.
3. Developers must spend a lot of time in creating the DML scripts. They also need to account for the
tedious rollback scripts, in case the overall deployment had to be rolled back. The Database
Administrator must spend a lot of time in executing scripts against multiple environments.
4. Removing manual work and inefficiencies in your database development process is one of the
reasons why organizations are moving towards automating their database deployments.
3. DATABASE Continuous Integration LIFECYCLE MANAGEMENT
OVERVIEW
Coding Unit Testing
Static Code
Analysis
Source Control
Continuous
Integration
Continuous
Deployment
SHIFT LEFT – Catch issues as early as possible
5. • Free and No Installation required
• Need to have VIEW SERVER STATE or
VIEW DATABASE STATE permission
• SQL Cop has a set of predefined rules
to identify anti-patterns for database
development
1. SQLCOP
6. • Continuous Inspection of Code Quality
• Identify Code Smells, Bugs and
Vulnerabilities
• Analyzers for 20+ Programming Languages
• DevOps Integration
• Reject Check-in when Quality Gate not met
2. Sonar Cube
8. Source Control is the system of truth
COMPARE
SSDT SCHEMA
COMPARE
GENERATE
EXECUTE
DIFFERENCE SCRIPT
DATABASE PROJECT/
DACPAC
1. STATE BASED APPROACH DACPAC is a self-contained
deployment file which is used for
deploying SQL Server objects to an
instance of SQL Server. You can
also think of DACPAC to be like a
database snapshot file, which can
serve as the in-memory
representation of database objects
and can be stored for maintaining
version history.
When the DACPAC is deployed, it
uses the information in the
DACPAC file as the source database
schema. It compares this with the
defined target to generate an
appropriate change script, which is
then executed against the target to
sync up both the environments.
9. Database is the system of truth
STATE 1 STATE 2 STATE 3 STATE N
Migration 1 Migration 2 Migration N
2. Migration BASED APPROACH
10. STATE BASED APPROACH
1. System of Truth is the Source Code
2. Suited for frequent database changes
3. Suited for large sized teams
4. Source Code contains the current
state of the database
5. Less control on the migration script
6. Complex refactoring might take
multiple steps
MIGRATION BASED APPROACH
1. System of Truth is the Database
2. Suited for infrequent database changes
3. Suited for small sized teams
4. Must maintain a long list of migration
scripts within the source control.
5. More fine grain control on the
migration script
6. Complex refactoring can be handled by
a single script
11. DATABASE DRIFTS
Any change to the database schema or reference data
that was made directly in the database environment,
outside of the normal automated delivery pipeline.
Ensure that all migrations are idempotent – meaning that
running a script more than once has no additional impact.
12. Renaming a Column/Table/Stored Procedure/ View/ Function
Dropping a Column/Table
Remove a Stored Procedure/ View/ Function
Moving a Column from one table
Adding a Column/Table/Stored Procedure/ View/ Function
Non-Breaking Database Change
Breaking Database Change
BACKWARDS COMPATIBILITY
15. Red gate Data Tools in Visual Studio 2017
1. Ready Roll Core: allows you to develop, source control, and safely automate deployments of
database changes alongside application changes. Ready Roll Core is available in the
Enterprise edition of Visual Studio 2017.
2. SQL Prompt Core: offers advanced code completion for SQL. SQL Prompt Core is available in
the Enterprise edition of Visual Studio 2017.
3. SQL Search: lets you find SQL objects fast and easily explore across databases. SQL Search is
available in all editions of Visual Studio 2017.
20. Flyway is free and open source.
Flyway facilitates the Automatic Deployment of database changes.
Flyway creates a table name ‘schema_version‘ in your database.
Flyway supports number of databases – Oracle, SQL Server, MySQL,
PostgreSQL, MariaDB, SQLite, Redshift and more.
21. • Changes made to same file causes Merge
Conflict.
MAIN
BRANCH 1 BRANCH 2
• Conflicts are caused by merge issues
because of long running feature branches.
Resolving Merge Conflicts is Error Prone and Time Consuming.
• Longer running features has the
potential to create Merge issues.
File1.cs File2.cs
7 Changes 5 Changes
Reverse Integration
BRANCHING STRATEGY
22. FEATURE FLAGS
• Potential alternative to maintaining multiple feature
branches.
• Reduces the need for constant branching and
merging.
• Enables releases with unfinished features at no risk.
27. RESOURCES
• Continuous Integration with SQL Server Data Tools in Visual Studio 2017
• Database Static Code Analysis using SQL Cop
• Managing your Technical Debt using SonarQube
• Continuous Integration, Continuous Delivery and Continuous Deployment