Braintree Payments shares their refined approach to performing PostgreSQL schema changes without downtime in production environments. The post covers essential techniques including transactional DDL management, lock acquisition strategies, and safe operations for tables, columns, indexes, and constraints. Key strategies include using concurrent operations, breaking complex changes into smaller steps, and implementing forward/backward compatibility requirements. The team also open-sourced pg_ha_migrations, a Ruby gem that enforces DDL safety in Rails applications.

19m read timeFrom medium.com
Post cover image
Table of contents
PostgreSQL at Scale: Database Schema Changes Without DowntimeFirst, some basicsTransactionalityLockingTable operationsCreate tableDrop tableRename tableColumn operationsAdd columnChange column typeDrop columnIndex operationsCreate indexDrop indexRename indexReindexConstraintsNOT NULL ConstraintsForeign keysCheck constraintsUniqueness constraintsExclusion constraintsEnum TypesModifying enum valuesDeleting enum valuesAnnouncing Pg_ha_migrations for Ruby on RailsFootnotes

Sort: