eulerto / pgquarrel

pgquarrel compares PostgreSQL database schemas (DDL)
BSD 3-Clause "New" or "Revised" License
388 stars 42 forks source link

rename and schema move support #13

Open eulerto opened 8 years ago

eulerto commented 8 years ago

If we rename an object or attribute there isn't a way to know that 'foo' becomes 'bar' unless (i) we have a discovery algorithm (that can't be precise -- e.g. rename a table, rename a column and add another column) or (ii) tell explicitly that 'foo' is now 'bar'. AFAICS (ii) is the right way to solve this problem.

OP should explicity inform in configuration file that 'foo' becomes 'bar'. One idea is a 'transform' section that contains option=value pairs. Each pair has option (object or attribute -- goal is identify the object) and a value (indeed two values separated by comma). An example:

[transform] table=foo, bar ; ALTER TABLE foo RENAME to bar attribute=teste.a, teste.b ; ALTER TABLE teste RENAME COLUMN a TO b schema=adm, rh ; ALTER SCHEMA adm RENAME TO rh table=adm.foo, rh.foo ; ALTER TABLE adm.foo SET SCHEMA TO rh function=adm.foo(integer), bar ; ALTER FUNCTION adm.foo(integer) RENAME TO bar

It should support:

RENAME TO / SET SCHEMA

RENAME

MOVE SCHEMA