Two names, or permanent alias, for the same Postgres table, and column -- during migration

Viewed 152

How can I create a permanent alias for a table (and also a column) such that queries against either name work?

I'd like to do this to enable renaming tables in our software. Our migrations need to run against live clusters, thus there's a period where the software version will be older than the DB version. It has to work with the old names of the tables and columns.

I see that it's possible to create a view with rules for insert, update, and delete, which I think is fairly close, but I'm wondering if there is a simpler approach. This approach also doesn't work if I wish to simply rename a column in a table (that is, without having to rename the table at the same time).

0 Answers
Related