PostgreSQL zero-downtime migration of a primary key from int to bigint (with Ruby on Rails specific notes)
04-Mar-2022 2007
A primary key integer field approaching overflow is a devops nightmare. We explain step by step to how we made the migration with zero downtime.You have an auto increment primary key int field and it’s nearing the maximum value for int: 2,147,483,647. If you run out of the values your PostgreSQL installation will go into a forced shutdown, most likely taking your application with it. The solution is, of course, to change the primary key to a bigint. However, if you’re running out of INTs, chances are that your table is also very large and a simple ALTER COLUMN command will take hours to run. Since it will lock the whole table it will require you to plan a maintenance window.
PostgreSQL zero-downtime migration of a primary key from int to bigint (with Ruby on Rails specific notes) #ruby #rubydeveloper #rubyonrails #PostgreSQL #zero-downtime #migration #primary #bigint #(with #Rails #specific #notes) https://rubyonrails.ba/link/postgresql-zero-downtime-migration-of-a-primary-key-from-int-to-bigint-with-ruby-on-rails-specific-notes