Copy and alter strategy on a table

39 Views Asked by At

We have a postgresql table where we just recently found out that in our of our tables (table name = orders) in production, one of the column would need to change its type from Integer to Bigint. We can't do this directly in the production table so the plan is....

The plan is:

  1. Create a new table with the same specs as the old table. (orders_temp)
  2. Create the needed indexes and triggers for the new table
  3. Change the data type of that particular column from integer to BigInt
  4. Run a data copy job to copy data from old table to new (including replication when data migration is done)
  5. Switch table names:
    rename orders_temp to orders rename orders to orders_backup

Would this process have any complications?

0

There are 0 best solutions below