Files
mkd/backend/migrations/add_plan_item_to_payment_invoices.sql
2026-02-04 00:17:04 +05:00

7 lines
612 B
SQL
Executable File
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.
-- Связь счета с пунктом плана работ (план/факт)
ALTER TABLE payment_invoices ADD COLUMN IF NOT EXISTS plan_item_id TEXT;
ALTER TABLE payment_invoices ADD COLUMN IF NOT EXISTS plan_item_building_id TEXT;
COMMENT ON COLUMN payment_invoices.plan_item_id IS 'ID пункта плана работ (building.annualPlan[].id)';
COMMENT ON COLUMN payment_invoices.plan_item_building_id IS 'ID дома плана (building.id)';
CREATE INDEX IF NOT EXISTS idx_payment_invoices_plan_item ON payment_invoices(plan_item_building_id, plan_item_id) WHERE plan_item_id IS NOT NULL;