DT5	
Concurrent	Session	
11/9/17	1:30	PM	
	
	
	
	
	
Databases	in	a	Continuous	
Integration/Delivery	Process	
	
Presented	by:	
	
Steve	Jones	
Redgate	Software	
	
Brought	to	you	by:		
		
	
	
	
	
350	Corporate	Way,	Suite	400,	Orange	Park,	FL	32073		
888---268---8770	··	904---278---0524	-	info@techwell.com	-	https://www.techwell.com/
Steve	Jones	
Redgate	Software	
	
Steve	Jones	has	been	working	with	databases	and	computers	for	more	than	two	
decades.	He	has	worked	with	SQL	Server	since	1991—from	v4.2	through	SQL	
Server	2016.	He	has	been	a	DBA,	developer,	and	manager	in	a	variety	of	large	and	
small	companies	across	multiple	industries.	A	founder	of	SQLServerCentral	in	
2001,	Steve	has	been	publishing	technical	articles	and	facilitating	discussions	
among	SQL	Server	professionals	ever	since.	He	currently	is	the	full-time	editor	of	
SQLServerCentral,	as	well	as	an	evangelist	for	Redgate	Software.	Steve	is	a	ten-
year	Microsoft	Data	Platform	MVP	who	lives	on	a	horse	ranch	in	Colorado.
10/30/17	
1	
Including the Database in a
DevOps Process

Steve	Jones	
Editor,	SQLServerCentral	
Redgate	So;ware	
@way0utwest	
1.  The database can be built*
2.  The database can be tested*
3.  The database can be released*
Three Takeaways
* like other software
Three Takeaways
10/30/17	
2	
Agenda
•  Who	am	I?	
•  The	DevOps	So;ware	Development	Pipeline	
•  Principles	of	DevOps	
•  Evolving	Database	Development	
www.voiceofthedba.com
sjones@sqlservercentral.com
@way0utwest
Steve Jones
SQLServerCentral founder
Redgate Software Evangelist
/in/way0utwest
10/30/17	
3	
The Three Ways
•  Principles	underlying	DevOps	from	Gene	Kim	
•  Systems	Thinking	
•  Amplify	Feedback	Loops	
•  Culture	of	ExperimentaTon	and	Learning	
What is DevOps?
“DevOps	is	the	union	of	people,	process,	and	products	to	enable	
conTnuous	delivery	of	value	to	our	end	users.”	
-	Donovan	Brown
10/30/17	
4	
DevOps in Prac?ce
• Culture	
•  DBAs	and	developers	working	together	
• AutomaTon	
•  Introduce	tools	to	the	database	
• Lean	
•  make	db	changes	simpler,	evolve	the	db	
• Measurement	
•  consider	impact	of	db	change	
• Sharing		
•  understand	how	a	db	change	impacts	development	and	operaTons	
The Applica?on Development Pipeline
OperaTons	Development	
Dev
Dev
Dev
Continuous integration
Build
Test
Publish
Sync
Trigger
Report
Artifact
repository
QA	
Beta	
Staging	
ProducTon
10/30/17	
5	
The Database Development Pipeline
OperaTons	Development	
Dev
Dev
Dev
Continuous integration
Build
Test
Publish
Sync
Trigger
Report
Artifact
repository
Shared	
Dev
QA	
Beta	
Staging	
ProducTon	
Evolving Database Development
•  The	foundaTon	is	Version	Control	
•  Treat	the	database	code	just	like	applicaTon	code	
•  Capture	our	DDL	(and	DML)	
•  VCS	OrganizaTon	
•  Can	be	same	repo	or	separate	repo	(I	prefer	separate)	
•  Use	a	sub	folder	for	the	DDL	
•  Use	Pull	Requests	for	code	review
10/30/17	
6	
SQL and Version Control
•  The	process	is		
•  Get	changed	code	to	a	text	file	
•  Commit	to	the	VCS	
•  Comments	are	why	changes	were	made,	not	what.	
•  OpTons	for	database	DDL	and	DML	
•  ScripTng	–	SMO	in	SQL	Server	
•  Third	Party	Tools	
•  File	|	Save	
Demo
Store	database	code	in	a	VCS
10/30/17	
7	
Database Con?nuous Integra?on
• Database	Build	Process	
•  Pull	code	from	VCS	
•  Order	code	according	to	rules	of	SQL	
•  Execute	code	on	a	database	
•  Run	tests	
•  Package	code	for	downstream	release	
• Use	a	Build	Server	just	like	applicaTon	code	
•  TFS	Build,	Bamboo,	Team	City,	Cruise	Control,	Jenkins,	whatever	
Database Tes?ng
•  Tests	must	be	automated	
•  Developers	are	not	responsible	for	tesTng	exisTng	code	
•  Developers	are	responsible	for	tesTng	their	new	code	
•  One	test	a	day	for	new	code	will	build	a	suite	
•  For	SQL	Server	
•  tSQLt	
•  Microso;	Unit	TesTng	Projects	
•  DBUnit	
•  TSQLUnit	
•  Custom	scripted	tests	
	
*	For	best	results,	use	curated	test	data
10/30/17	
8	
Demo
Implement	ConTnuous	IntegraTon	
Generate the Update Script
•  For	code	(stored	procedures,	funcTons,	views,	modules,	etc.)	
•  Take	latest	version	from	VCS	
•  For	tables	
•  Use	Comparison	or	migraTon	scripts	to	make	changes.	
•  Tools	
•  Comparison	tools	(SQL	Compare,	etc)	
•  MigraTon	Tools	(ReadyRoll,	FlywayDB,	Liquibase,	etc)
10/30/17	
9	
Deploy the Code
•  Use	a	consistent	process	
•  Use	automaTon	where	you	can,	use	manual	steps	(documented)	
where	you	cannot	
•  Slowly	and	conTnuously	improve	the	process	
•  Use	a	Release	Management	Server	
•  Octopus	Deploy	
•  TFS	
•  Bamboo	
Demo
Release	to	Downstream	Environments
10/30/17	
10	
Release Issues
•  Rollback	
•  For	code	(views,	procs,	funcTons)	–	Deploy	the	previous	version	
•  For	tables	–	Need	custom	code	
•  In	general,	I	am	a	fan	of	dark	deploys	and	roll	forward	
•  Environment	Data	
•  Data	that	varies	by	environment	(queue	names,	security,	etc)	
•  Script	and	deploy	with	deploy	once	scripts	(maybe	separate	pipeline)	
•  Use	tokens	where	possible	and	store	config	data	in	the	environment	
Summary
•  Understand	and	apply	the	DevOps	principles	to	the	db	
•  Systems	Thinking	
•  Feedback	Loops	
•  ExperimentaTon	and	Learning	
•  Treat	the	database	like	applicaTon	code	
•  Build	the	excepTons	into	your	process	
•  Adapt	to	your	environment	
•  Do	more	of	what	works	
•  Do	less	of	what	doesn’t
10/30/17	
11	
The End
www.voiceofthedba.com
sjones@sqlservercentral.com
@way0utwest
/in/way0utwest
References
•  You’re	Doing	DevOps	Wrong	-	hnps://techcrunch.com/2016/07/04/youre-doing-devops-wrong/	
•  Codifying	DevOps	PracTces	-	hnp://www.jedi.be/blog/2012/05/12/codifying-devops-area-pracTces/	
•  3	DevOps	Principles	to	Apply	to	Your	IT	Team	-	
hnp://blogs.atlassian.com/2015/09/3-key-devops-principles-apply-team/	
•  DevOps	DisTlled,	Part	1:	hnp://www.ibm.com/developerworks/library/se-devops/part1/index.html	
•  Closing	the	Gap	Between	Database	Con6nuous	Delivery	and	Code	Con6nuous	Delivery	
-  hnp://devops.com/2014/11/19/closing-gap-database-conTnuous-delivery-code-conTnuous-delivery/	
-  Where’s	the	Database	in	DevOps	-	hnps://www.red-gate.com/library/wheres-the-database-in-devops	
-  How	do	Databases	Fit	into	DevOps	-	
hnps://blog.devopsguys.com/2015/02/19/how-do-databases-fit-into-devops/
10/30/17	
12	
Images
•  hnps://coupongy.files.wordpress.com/2013/06/scratching-head3.gif	
•  hnp://sipso;logic.com/qa-tesTng/	
•  hnp://www.qahipster.com/uploads/8/1/4/4/8144013/417638_orig.gif	
•  hnps://commons.wikimedia.org/wiki/File:Server-blades.svg	
•  hnp://sethkravitz.com/wp-content/uploads/2016/01/culture.jpg	
•  hnp://cdn.electric-cloud.com/wp-content/uploads/2015/04/end_to_end_automaTon.jpeg	
•  hnps://media.licdn.com/mpr/mpr/p/6/005/0b0/1ca/3876971.jpg	
•  hnp://studyjams.scholasTc.com/studyjams/assets/jams/math/measurement/image.jpg	
•  hnp://staTc1.squarespace.com/staTc/50e6cb55e4b0404f376ac3a9/t/51001a3ce4b0479a8076a5da/1358961213093/feedback.png	
•  hnps://www.govloop.com/blogs/4001-5000/4920-Experiment.gif	
•  hnp://onlinelearningTps.com/wp-content/uploads/2014/04/worlde-online-learning.gif	
•  hnp://successagency.com/blog/wp-content/uploads/2014/05/5.-CommunicaTon-gif.gif	
•  hnps://elizajanee.files.wordpress.com/2015/03/tumblr_n652boc6hf1rpfx57o1_400.gif	
•  hnp://cdn2.totallythebomb.com/wp-content/uploads/2011/09/stopsign.gif	
•  hnp://threesixtysafety.com/wp-content/uploads/effecTve-communicaTon.jpg	
•  hnp://www.millenniumrecycling.com/wp-content/uploads/2015/01/Process-Gif.gif

Databases in a Continuous Integration/Delivery Process