Database compatibility

10
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.

description

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

Transcript of Database compatibility

Page 1: 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

Page 2: Database compatibility

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: ✖

Page 3: Database compatibility

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

Page 4: Database compatibility

Company Confidential - Wealthfront Inc.

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

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

Page 5: Database compatibility

Company Confidential - Wealthfront Inc.

DB: Dogfighting

alter table users modify value int, add value_dec decimal;

Page 6: Database compatibility

Company Confidential - Wealthfront Inc.

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

Page 7: Database compatibility

Company Confidential - Wealthfront Inc.

DB: Dogfighting

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

Page 8: Database compatibility

Company Confidential - Wealthfront Inc.

DB: Dogfighting

Reads id & value_decWrites [0, 1] in value_dec

Page 9: Database compatibility

Company Confidential - Wealthfront Inc.

DB: Dogfighting

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

Page 10: Database compatibility

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