Initial commit MKD fixes

This commit is contained in:
Arsen
2026-02-04 00:17:04 +05:00
commit de94ad707b
312 changed files with 138754 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
-- Добавить назначение "мероприятие" и привязку к pr_events
-- 1. Расширить CHECK purpose_type: добавить 'event'
ALTER TABLE payment_invoices DROP CONSTRAINT IF EXISTS payment_invoices_purpose_type_check;
ALTER TABLE payment_invoices ADD CONSTRAINT payment_invoices_purpose_type_check
CHECK (purpose_type IN ('building', 'district', 'legal', 'office', 'hr', 'other', 'event'));
-- 2. Колонка привязки счёта к мероприятию
ALTER TABLE payment_invoices ADD COLUMN IF NOT EXISTS purpose_event_id BIGINT REFERENCES pr_events(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS idx_payment_invoices_purpose_event ON payment_invoices(purpose_event_id) WHERE purpose_event_id IS NOT NULL;
COMMENT ON COLUMN payment_invoices.purpose_event_id IS 'ID мероприятия (pr_events), если purpose_type = event';