Database deployments Giulio Vian — 3 March 2021
In a Start-up far far away DBA Senior Dev Scrum Master Junior Dev
Free! too good to be true • 0 $/£/€ = gratis! • open source • any DB! • 1,400 stars • and works!
Months pass It’s Friday: Let’s deploy the latest version!
Unpleasant situation
Migration-based Source: https://www.red-gate.com/hub/product-learning/sql-source-control/moving-from-application-automation-to-true-devops-by-including-the-database
Baseline (aka v0.0.0)
Independent migration scripts Conflict?
let’s use dacpac
Truth revealed
State-based Source: https://www.red-gate.com/hub/product-learning/sql-source-control/moving-from-application-automation-to-true-devops-by-including-the-database
Baseline (aka v0.0.0)
Baseline (aka v0.0.1)
Diff script from schema-based tool uh oh
Help me
Migration based v1  v2 Hides conflicts Order matters State based v1  v2 Miss object renames Rollback drifts Schema evolution
Migration based v1  v2 State based v1  v2 What to use
Your path you must decide
Are the two mutually exclusive? No Dev can use a Schema diff tool like SSDT to draft migration scripts Migration script can be augmented stating the baseline version State-based tools have pre- and post-deploy phases for data migration We can add dependency check between migration scripts To warn about scripts interaction and dependency
Hardware spec: 1 KB RAM (16KB after upgrade) 4 KB ROM (8KB after upgrade) First computer Past Companies Communities Giulio Vian Senior DevOps Engineer @giulio_vian giuliovdev@hotmail.com
References Tools SQL Server Data Tools (SSDT) RedGate SQL Compare devart Flyway dbup dbdeploy.net Articles https://en.wikipedia.org/wiki/Sc hema_migration https://martinfowler.com/article s/evodb.html https://michaeljswart.com/2018 /01/100-online-deployments http://blog.dixo.net/2015/02/bl ue-turquoise-green-deployment Books Refactoring Databases: Evolutionary Database Design http://www.agiledata.org/
Thank you! Giulio Vian @giulio_vian giuliovdev@hotmail.com
Deployment Process
Database Refactoring Cycle Initial state Final state Implement the refactoring Test on non-production Refactoring completed deploy new schema, migrate data deploy new application version
Database Refactoring Cycle Initial state Final state Implement the refactoring Test on non-production Refactoring completed deploy new schema, migrate data deploy new application version
Database Refactoring Cycle Initial state Final state Transitional state Implement the refactoring Test on non-production Refactoring completed All systems use the new schema Coexistence of old and new schema Expand: deploy new schema, migrate data, add scaffolding code Contract: Drop old schema objects and scaffolding code
Recapping
applications DATa
La morale Tools are limited Know your stuff is the only way Discipline
Migration troubles with DbUp also FlyWay, Liquibase, etc.
State troubles with dacpac

Database deployments - dotnetsheff

Editor's Notes

  • #7 Source https://www.red-gate.com/hub/product-learning/sql-source-control/moving-from-application-automation-to-true-devops-by-including-the-database
  • #8 Source http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  • #9 Source http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  • #12 Source https://www.red-gate.com/hub/product-learning/sql-source-control/moving-from-application-automation-to-true-devops-by-including-the-database
  • #13 Source http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  • #14 Source http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  • #15 Source http://workingwithdevs.com/delivering-databases-migrations-vs-state/
  • #22 10,000+ employees (1,000+ in IT) ~$12 billion Revenue
  • #23 https://github.com/facebookincubator/OnlineSchemaChange https://www.percona.com/doc/percona-toolkit/3.0/pt-online-schema-change.html https://octopus.com/blog/databases-with-blue-green-deployments https://www.linkedin.com/pulse/blue-green-deployment-aws-database-synchronisation-james-chan
  • #31 Giovanni Francesco Barbieri detto il Guercino (1591-1666) Atlante che sostiene il globo celeste, 1646 Firenze, Museo Mozzi Bardini, inv. MCF-MB 1922-1148.a Il mito del titano Atlante condannato da Zeus a sorreggere la volta celeste per l’eternità ebbe notevole fortuna iconografica nel corso del Seicento. Tra le opere più famose è questa versione, dipinta per Lorenzo de’ Medici.