Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Update Your Database Schema with Zero Downtime ...

Edson Yanaga
November 16, 2017

Update Your Database Schema with Zero Downtime Migrations

You joined the DevOps movement and want to release software even faster and safer. And how do you achieve this multiple times per day without disrupting your users in production? With Zero Downtime! But what about my data? What about my relational database schema? Join us on this session and we’ll show that with code might be “easy”, and data may be “hard”, but it’s definitely possible and practical.

Edson Yanaga

November 16, 2017
Tweet

More Decks by Edson Yanaga

Other Decks in Technology

Transcript

  1. Join developers.redhat.com ALTER TABLE customers ADD COLUMN correct VARCHAR(20); UPDATE

    customers SET correct = wrong WHERE id BETWEEN 1 AND 100; UPDATE customers SET correct = wrong WHERE id BETWEEN 101 AND 200; ALTER TABLE customers DELETE COLUMN wrong; 15
  2. Join developers.redhat.com 16 Scenarios Add a Column Rename a Column

    Change Type/Format of a Column Delete a Column
  3. Join developers.redhat.com 17 Add a Column 1 ADD COLUMN 2

    Code computes the read value and writes to new column 3 Update data using shards 4 Code reads and writes from the new column
  4. Join developers.redhat.com 18 Rename a Column 1 ADD COLUMN 2

    Code reads from the old column and writes to both 3 Copy data using small shards 4 Code reads from the new column and writes to both 5 Code reads and writes from the new column 6 Delete the old column (later)
  5. Join developers.redhat.com 19 Change Type/Format of a Column 1 ADD

    COLUMN 2 Code reads from the old column and writes to both 3 Copy data using small shards 4 Code reads from the new column and writes to both 5 Code reads and writes from the new column 6 Delete the old column (later)
  6. Join developers.redhat.com 20 Delete a Column 1 DON’T 2 Stop

    using the read value but keep writing to the column 3 Stop writing to the column 3 Delete the column