Expand Contract Pattern
for Continuous Delivery of Databases
https://pixabay.com/en/hands-hand-raised-hands-raised-220163/
Good Karma
Story-telling CRM because Facts Tell but Stories Sell http://goodkarmayoga.in/
Iterations https://pixabay.com/illustrations/recursion-icon-iteration-icon-2865934/
Evolvability https://www.dreamstime.com/
Sacrificial Architecture
https://www.martinfowler.com/bliki/SacrificialArchitecture.html
Move fast and break nothing
https://github.blog/2015-12-15-move-fast/
Upgrading Rails
https://github.blog/2018-09-28-upgrading-github-from-rails-3-2-to-5-2/
Techniques https://pixabay.com/photos/watercolor-tusche-indian-ink-wet-384873
/
Incremental https://pixabay.com/vectors/arrow-business-financial-graph-1295953/
Parallel Implementation https://www.martinfowler.com/bliki/ParallelChange.html
https://martinfowler.com/bliki/BranchByAbstraction.html
Branch by Abstraction
https://continuousdelivery.com/implementing/architecture/
Strangler Pattern
https://pixabay.com/vectors/abc-alphabet-blocks-toy-148517/Basics
https://martinfowler.com/books/refactoring.html
Refactoring is a controlled technique for improving the design of
an existing code base. Its essence is applying a series of small
behavior-preserving transformations, each of which "too small to
be worth doing".
However the cumulative effect of each of these transformations
is quite significant.
Refactoring
https://continuousdelivery.com/
Ability to get changes of all types—including new features,
configuration changes, bug fixes and experiments—into
production, or into the hands of users, safely and quickly in a
sustainable way.
Continuous Delivery
Database? https://pixabay.com/illustrations/question-help-question-mark-answer-1127660/
A database refactoring is a small change to your
database schema (the table structures, data itself,
stored procedures, and triggers) which improves its
design without changing its semantics.
http://databaserefactoring.com/
• Enables Continuous Delivery
• Supports evolutionary development
http://databaserefactoring.com/
https://www.dreamstime.com/stock-photos-example-stamp-image28420393
Split Column
customer_id
booking_date
status
trial_bookings
Transition
customer_id
status[old field]
booking_date
attendance_status
membership_status
trial_bookings
Initial sync https://git-scm.com/downloads/logos
UPDATE trial_bookings
SET attendance_status = 1, membership_status = 0
WHERE status = 1
UPDATE trial_bookings
SET attendance_status = 0, membership_status = 1
WHERE status = 2
UPDATE trial_bookings
SET attendance_status = 1, membership_status = 1
WHERE status = 3
Sync https://git-scm.com/downloads/logos
Transition https://git-scm.com/downloads/logos
customer_id status booking_date attendance_status membership_status
10001 1 2017-01-01 1 0
10002 2 2017-01-01 0 1
10003 3 2017-01-01 1 1
New Schema
customer_id
booking_date
attendance_status
membership_status
trial_bookings
New SchemaTransition PeriodOld Schema
customer_id
booking_date
attendance_status
membership_status
trial_bookings
customer_id
booking_date
attendance_status
membership_status
trial_bookings
customer_id
status[old field]
booking_date
attendance_status
membership_status
trial_bookings
Split Table
billing_cycles
customer_id
validity_starts_at
valid_until
payment_mode
Payment_made_at
amount_paid
payments
billing_cycle_id
payment_mode
payment_made_at
amount_paid
Transition
billing_cycles
customer_id
validity_starts_at
valid_until
billable_amount
payment_mode
payment_made_at
amount_paid
* 1
Initial sync https://git-scm.com/downloads/logos
INSERT INTO payments (
billing_cycle_id, payment_mode, payment_made_at, amount_paid
)
SELECT id, payment_mode, payment_made_at, amount_paid
FROM billing_cycles
Sync https://git-scm.com/downloads/logos
Transition https://git-scm.com/downloads/logos
customer_id validity_starts_at validity_until billable_amount payment_mode payment_made_at amount_paid
10001 2017-01-01 2017-03-01 10000 1 2017-01-01 10000
10002 2017-04-01 2017-05-01 5000 0 2017-04-01 5000
10003 2017-06-01 2017-12-31 15000 1 2017-06-01 10000
billing_cycle_id payment_mode payment_made_at amount_paid
15001 1 2017-01-01 10000
15002 0 2017-04-01 5000
15003 1 2017-06-01 10000
billing_cycles
payments
payments
billing_cycle_id
payment_mode
payment_made_at
amount_paid
New Schema
billing_cycles
customer_id
validity_starts_at
valid_until * 1
New Schema
Transition Period
Old Schema
payments
billing_cycle_id
payment_mode
payment_made_at
amount_paid
billing_cycles
customer_id
validity_starts_at
valid_until
payment_mode
Payment_made_at
amount_paid
billing_cycles
customer_id
validity_starts_at
valid_until
payment_mode
payment_made_at
amount_paid
billable_amount payments
billing_cycle_id
payment_mode
payment_made_at
amount_paid
billing_cycles
customer_id
validity_starts_at
valid_until
https://martinfowler.com/articles/evodb.html
Types of Refactoring
★ Structural Refactoring
★ Data Quality Refactoring
★ Referential Integrity Refactoring
★ Transformation
★ Architectural Refactoring
★ Method Refactoring
https://pixabay.com/vectors/abc-alphabet-blocks-toy-148517/Basics
Versioning https://git-scm.com/downloads/logos
Strategies https://git-scm.com/downloads/logos
★ Build Number
★ Timestamp
★ Unique Identifier
https://pixabay.com/photos/gears-cogs-machine-machinery-1236578/
Automation
Tests https://pixabay.com/vectors/button-yes-no-red-green-icon-32259/
Deploy https://pixabay.com/vectors/rocket-icon-symbol-gui-internet-1976107/
https://pixabay.com/en/strategy-arrows-building-startup-3224515/
Migration https://pixabay.com/photos/canada-geese-flying-formation-575262/
Transition period https://pixabay.com/photos/bridge-iron-old-pedestrian-metal-3181356/
Tools
Murphy’s Law https://www.flickr.com/photos/smemon/5471883005
Low risk releases https://pixabay.com/en/button-red-round-shiny-155149/
Small reversible steps https://www.slideshare.net/jallspaw/ops-metametrics-the-currency-you-pay-for-change
Atomicity and Ratcheting
Split Table - Database Refactoring
Continuous Delivery of Databases
Expand Contract Pattern - Continuous Delivery of Databases
Database Refactoring
Four Principles of Low-Risk Software Releases
Branch by Abstraction
Move Fast @ Github
Legacy Application Strangulation
Make Large Scale Changes Incrementally with Branch By Abstraction
Leena S N
@leenasn / leenasn@gmail.com
https://medium.com/@leenasn

Expand Contract Pattern for Continuous Delivery of Databases