Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit 597c90e

Browse files
author
Sai Wong
committed
Updated avatar and beefed up the ending.
1 parent bddcfdc commit 597c90e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

_posts/2015-10-16-add-columns-with-default-values-to-large-tables-in-rails-postgres.markdown

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: post
33
title: Rails Migration - How to add columns with default values to really large tables in Postgres + Rails
44
author: Sai Wong
55
summary:
6-
image: http://res.cloudinary.com/wework/image/upload/s--xpIlilub--/c_scale,q_jpegmini:1,w_1000/v1443207604/engineering/shutterstock_294201896.jpg
6+
image: http://res.cloudinary.com/wework/image/upload/s--GnhXQxhq--/c_scale,q_jpegmini:1,w_1000/v1445269362/engineering/shutterstock_262325693.jpg
77
categories: data
88
---
99

@@ -145,6 +145,9 @@ end
145145

146146
## Possible alternate solution
147147
- Handle NULL case in code to treat as the desired default value
148+
- Clean solution and quick turn around but required us to muck up the model to abstract out that case. Give that we may or may not have complete control over how that those values are extracted from the model, this may turn into lots of defensive code.
148149
- Add view in database to do mapping for us
150+
- Very clean solution though this would require us to maintain both the schema and the view whenever we do schema changes on to that table. Though we don't do changes on the schema often on this table, the extra maintance overhead was deemed not worth the value.
149151
- Add trigger to only update rows that are actively queried
150-
- ???
152+
- Also very clean solution though it came down to data integrity and since our data eventually gets slurped up by our data team, having a sane state on our data was highest priority. This meant that having a NULL state on a Boolean was not desired. Ultimately, we could of added the trigger to handle any current requests and just made the migration run slowly to backfill lesser accessed rows. Since we were able to run the entire migration within a night, we decided it wasn't worth the additional hassle.
153+

0 commit comments

Comments
 (0)