21 lines
495 B
SQL
21 lines
495 B
SQL
do $$
|
|
begin
|
|
if exists (
|
|
select 1
|
|
from information_schema.columns
|
|
where table_schema = 'public'
|
|
and table_name = 'patient_patient_tag'
|
|
and column_name = 'patient_tag_id'
|
|
)
|
|
and not exists (
|
|
select 1
|
|
from information_schema.columns
|
|
where table_schema = 'public'
|
|
and table_name = 'patient_patient_tag'
|
|
and column_name = 'tag_id'
|
|
) then
|
|
alter table public.patient_patient_tag
|
|
rename column patient_tag_id to tag_id;
|
|
end if;
|
|
end $$;
|