Обсуждение: rename column and trigger on column

Поиск
Список
Период
Сортировка

rename column and trigger on column

От
Chris Sutton
Дата:
create table ref_table (
  id serial primary key
  ref_name varchar);

create table data_table (
  a int4 references ref_table);

which of course creates 3 triggers.

If you do:

alter table data_table rename column a to b;

The trigger on data_table still looks for column named "a" so sometime in
the future you will probably get:

ERROR:  constraint <unnamed>: table data_table does not
have an attribute a

Possible solutions, along with telling the db admin to pay attention ;)

1. Check for triggers on column before allowing rename and if they
exist, give a warning of the trigger that needs to be recreated

2. Rebuild the trigger automatically

3. Delete the trigger