News for hackers. Stuff that matters.
Re:Zero-downtime Postgres migrations – the hard parts by Sinjo on Wednesday May 27, 2015 @08:16PM (#9615307)
You're right on the approach. One thing to be careful of is that there's no option to add a not-null constraint with the `NOT VALID` flag. That means it'll hold the AccessExclusive lock while it checks every row in the table meets the constraint.

You can work around this by adding a `CHECK` constraint which does the same thing, but it's a little inconvenient. There was some work being done to add this feature to not-null constraints (http://www.postgresql.org/message-id/20140517155857.GD7857@e...), but unfortunately it looks like it's gone stale.

There are no comments on this comment yet.