Samir Behara, Senior Developer, EBSCO DevOps, Continuous Integration & Database Lifecycle Management: Rule them all Samir Behara, Senior Developer, EBSCO @samirbehara www.dotnetvibes.com
SAMIR BEHARA Senior Developer, EBSCO Samir Behara builds software solutions using cutting edge Microsoft technologies, primarily C# and SQL Server. Has a Bachelor Degree in Computer Science with 12 years of IT experience. Co-Chapter Lead of Steel City SQL Server User Group , Birmingham, AL SAMIR BEHARA Senior Developer, EBSCO
DATABASE RELEASE? EMAIL THE SCRIPTS & I WILL EXECUTE IT
DATABASE LIFECYCLE MANAGEMENT OVERVIEW Continuous Integration Static Code Analysis Continuous Deployment Source Control Coding Unit Testing SHIFT LEFT – Catch issues as early as possible
COST OF DEVELOPING SOFTWARE
TESTING PYRAMID UI Tests Integration Tests Unit Tests
TEST DRIVEN DEVELOPMENT RED GREEN REFACTOR
TECHNICAL DEBT
STATIC CODE ANALYSIS SQL Cop Free and No Installation required SQL Cop has a set of predefined rules to identify anti-patterns for database development Need to have VIEW SERVER STATE or VIEW DATABASE STATE permission
STATIC CODE ANALYSIS SonarQube 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
RELEASE PIPELINE CODE BUILD INTEGRATE TEST RELEASE DEPLOY Continuous Integration Continuous Delivery Continuous Deployment
DEVELOPMENT CONTINUOUS INTEGRATION BUILD Trigger SOURCE CONTROL TEST Feedback Mechanism
CONTINUOUS DEPLOYMENT CONTINUOUS DELIVERY CODE Auto BUILD Auto STAGING Manual PRODUCTION CONTINUOUS DEPLOYMENT CODE Auto BUILD Auto STAGING Auto PRODUCTION
Source Control is the system of truth STATE BASED APPROACH Source Control is the system of truth COMPARE EXECUTE DATABASE PROJECT/ DACPAC SSDT SCHEMA COMPARE GENERATE DIFFERENCE SCRIPT
MIGRATION BASED APPROACH Database is the system of truth STATE 1 STATE 2 STATE 3 STATE N Migration 1 Migration 2 Migration N
MIGRATION BASED APPROACH STATE BASED APPROACH MIGRATION BASED APPROACH System of Truth is the Source Code Suited for frequent database changes Suited for large sized teams Source Code contains the current state of the database Less control on the migration script Complex refactoring might take multiple steps System of Truth is the Database Suited for infrequent database changes Suited for small sized teams Have to maintain a long list of migration scripts within the source control More fine grain control on the migration script Complex refactoring can be handled by a single script
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.
BACKWARDS COMPATIBILITY Non-Breaking Database Change Adding a Column/Table/Stored Procedure/ View/ Function Breaking Database Change Renaming a Column/Table/Stored Procedure/ View/ Function Dropping a Column/Table Remove a Stored Procedure/ View/ Function Moving a Column from one table
Expand Transition Phase Contract EXPAND AND CONTRACT PATTERN Initial Refactoring is applied Data is migrated Perform Cleanup to complete the refactoring
DISCONNECTED DATABASE DEVELOPMENT CODE EDITING EXPERIENCE VERSION CONTROL DISCONNECTED DATABASE DEVELOPMENT DECLARATIVE APPROACH SQL SERVER DATA TOOLS DACPAC DEPLOPYMENTS CODE EDITING EXPERIENCE SCHEMA & DATA COMPARE
SSDT INSTALLATION IN VISUAL STUDIO 2017
MORE CONTROL ON MIGRATION SCRIPT INCREMENTAL CHANGE SHIFT LEFT MORE CONTROL ON MIGRATION SCRIPT REDGATE READYROLL HYBRID APPROACH PROGRAMMABLE OBJECTS OFFLINE SCHEMA MODEL
READYROLL INSTALLATION IN VISUAL STUDIO 2017
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.
BRANCHING STRATEGY MAIN Reverse Integration MAIN Changes made to same file causes Merge Conflict. Longer running features has the potential to create Merge issues. Conflicts are caused by merge issues because of long running feature branches. BRANCH 1 BRANCH 2 File1.cs File2.cs 7 Changes 5 Changes Resolving Merge Conflicts is Error Prone and Time Consuming.
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.
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
@samirbehara samirbehara@gmail.com dotnetvibes.com