Database compatibility

Post on 17-Jan-2015

1.174 views 1 download

description

A few slides from an internal presentation made during Wealthfront Tech Talks about forward and backward compatibility.

Transcript of Database compatibility

Company Confidential - Wealthfront Inc.

Database compatibility(i.e. Application talking to a DB)

• Select statement– App. is reader, DB is writer

• Insert– App. is writer, DB is reader

Company Confidential - Wealthfront Inc.

DB: Rules of Engagement

• Adding a table: ✔• Removing a table: ✔– Table is unused

• Removing a column: ✔– Column is unused

• Adding a column: ✔– Nullable OR– Not-null with default value

• Renaming a column: ✖

Company Confidential - Wealthfront Inc.

DB: Dogfighting

• Table users with two columns id and value• Value is a percentage, stored as [0, 100]• Migrate to [0, 1] representation• Clustered servers talking to the DB• No downtime

Company Confidential - Wealthfront Inc.

DB: DogfightingReads id & valueWrites [0, 100] in value

create table users ( id int not null, value int not null);

Company Confidential - Wealthfront Inc.

DB: Dogfighting

alter table users modify value int, add value_dec decimal;

Company Confidential - Wealthfront Inc.

DB: DogfightingReads id & valueWrites [0, 100] in valueWrites [0, 1] in value_dec

Company Confidential - Wealthfront Inc.

DB: Dogfighting

update users set value_dec = value / 100 where value_dec is null;

Company Confidential - Wealthfront Inc.

DB: Dogfighting

Reads id & value_decWrites [0, 1] in value_dec

Company Confidential - Wealthfront Inc.

DB: Dogfighting

alter table users drop column value, modify value_dec decimal not null;

Company Confidential - Wealthfront Inc.

DB: Top Gun

• Table users with two columns id and value• Value is a percentage, stored as [0, 100]• Migrate to [0, 1] representation• Clustered servers talking to the DB• No downtime• No DDL change (value is decimal) NEW