Files
iistwin/migrations/0085_form_fields_soft_delete.sql

13 lines
1.0 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Мягкое удаление полей формы: удалённые скрываются везде (getFormFields),
-- но определение и значения в задачах сохраняются — доступны в архиве
-- и в блоке «Удалённые поля» карточки задачи, возможно восстановление.
ALTER TABLE form_fields ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ;
-- Код удалённого поля освобождается: unique теперь только среди активных.
-- Старый constraint снимаем по всем известным именам (drizzle называл его _unique).
ALTER TABLE form_fields DROP CONSTRAINT IF EXISTS form_fields_form_id_code_unique;
ALTER TABLE form_fields DROP CONSTRAINT IF EXISTS form_fields_form_id_code_key;
DROP INDEX IF EXISTS form_fields_form_id_code_unique;
CREATE UNIQUE INDEX IF NOT EXISTS form_fields_form_id_code_active_key
ON form_fields (form_id, code) WHERE deleted_at IS NULL;