-- Refresh the records.* expansion after migration 002 added Finance source-link columns.
-- PostgreSQL 15+
-- Target database: booking_test.

BEGIN;

CREATE OR REPLACE VIEW finance.v_active_daily_facts AS
SELECT records.*
FROM finance.current_daily_versions AS current_version
JOIN finance.daily_records AS records
  ON records.daily_version_id = current_version.daily_version_id
WHERE records.outcome = 'retained';

COMMENT ON VIEW finance.v_active_daily_facts IS
  'All columns from retained rows in each business date current active daily version, refreshed after schema migrations add row fields.';

COMMIT;
