1

What is the best way to go about updating table names and column names in a postgresql database that already has loads of data but, as part of an overall web app upgrade, the database is also being modified, and those modifications include renaming poorly named tables (the largest table is named, “data”!) and column names?

Especially I am concerned about breaking things such as many PK’s are bigserial or serial, and then PK and FK naming will not longer be consistent without manually re-naming all of them.

Is there a recommended way to go about these changes?

If I start renaming tables, and then columns, and then PK, FK, and sequences, am I running the risk of breaking constraints or sequences? Or would it be better to leave the names of PK, FK, and sequences "as is"?

  • you can rename tables and columns without breaking foreign keys. the name of the actual FK constraint will however not be changed, that's true – a_horse_with_no_name Dec 15 '18 at 14:06
  • What would happen to all functions that references this tables/columns? – McNets Dec 15 '18 at 16:43
  • @McNets - For the functions coded for the application, I have no worries about manually checking and re-writing those, as the number of functions is relatively small and task to verify if working or not is straightforward. – mg1075 Dec 15 '18 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.