Files
wyndham-ARR/database/007_report_channel_facts_view.sql
2026-07-29 16:38:05 +08:00

29 lines
979 B
PL/PgSQL

-- Privacy-minimized immutable-version facts for monthly BI and channel details
-- PostgreSQL 15+
-- Target database: booking_test (connect to that database before running).
-- Additive migration; do not edit applied migrations 001-006 in place.
BEGIN;
CREATE VIEW finance.v_report_channel_facts AS
SELECT
records.daily_version_id,
records.id AS daily_record_id,
records.arrival,
records.departure,
records.nights,
records.no_of_rooms,
records.company_name,
records.rate_code,
records.room_category_label,
records.real_price,
records.total_price,
records.channel_key
FROM finance.daily_records AS records
WHERE records.outcome = 'retained';
COMMENT ON VIEW finance.v_report_channel_facts IS
'Privacy-minimized retained facts queried through report_daily_versions; supports immutable report snapshots without guest name, confirmation number, displayed room number, comments, traces, products, or source coordinates.';
COMMIT;