person: дополнительные почты (additional_emails) и уникальность основной почты
All checks were successful
ci / test (push) Successful in 25s
ci / deploy (push) Successful in 1m46s

Миграция 012: колонка additional_emails (почты через ";") и уникальный индекс по
lower(email); блоки условные, на сервере (таблица принадлежит роли Mathesar) уже
созданное не трогают. Документация person: команда внесена в таблицу.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 17:56:01 +03:00
parent 516565a247
commit 9e4b039e5e
3 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
-- person: основная почта (email, @khbuild.pro) и дополнительные почты через ";" (additional_emails), например yuyaryshev@gmail.com.
-- Условные блоки: на сервере таблицу person после подключения Mathesar ведёт другая роль и колонка с индексом уже созданы вручную,
-- поэтому ALTER и CREATE INDEX выполняются, только если их ещё нет (иначе khb_app не владелец и миграция упала бы).
do $$
begin
if not exists (select 1 from information_schema.columns where table_schema = 'public' and table_name = 'person' and column_name = 'additional_emails') then
alter table person add column additional_emails text;
comment on column person.email is 'Основная почта на @khbuild.pro';
comment on column person.additional_emails is 'Дополнительные почты через ";", например yuyaryshev@gmail.com';
end if;
if not exists (select 1 from pg_indexes where schemaname = 'public' and indexname = 'person_email_lower_key') then
create unique index person_email_lower_key on person (lower(email)) where email is not null;
end if;
end $$;