Files
agenciapsilmno/DBS/2026-03-11/supabase-snippets/Untitled query 157.sql
2026-03-12 08:58:36 -03:00

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 $$;