-- ============================================================================= -- GB5 BI platform — Phase 2: generalize the ApiService pilot's MDATASOURCE row into a -- reusable "this GB5 host, reachable for any of its own reports" data source. -- Database: SQL Server (tenant business DB) -- Plan: /Users/venkatv/.claude/plans/gb5-in-product-analytics-dapper-bear.md -- -- BICatalogBLL.CreateFromReportView (Phase 2) resolves a shared MDATASOURCE row by -- DATASOURCECODE = 'GB5_SELF_HOST' (DataSourceQB.GET_DATASOURCE_ID_BY_CODE) so that ANY -- existing GB5 report can back a new MBICATALOG row without provisioning a fresh -- MDATASOURCE row per report — one shared HostName is all any of them need. -- -- Prefers relabeling the ApiService pilot's own row (seeded manually, id=1, -- DATASOURCECODE='PILOT_APISVC_TEST', per pilot_apiservice_seed.sql) rather than creating a -- second row — HOSTNAME/DATASOURCETYPE are left completely untouched, only the code/name/ -- remarks change, so the pilot round-trip already proven against this row keeps working -- unchanged. Falls back to inserting a fresh row only if that pilot row was never seeded -- (a different environment) — HOSTNAME below is this session's known GB5DEMO business host; -- update it via the DataSource admin screen if run somewhere else. -- ============================================================================= IF EXISTS (SELECT 1 FROM MDATASOURCE WHERE DATASOURCEID = 1 AND DATASOURCECODE = 'PILOT_APISVC_TEST') BEGIN UPDATE MDATASOURCE SET DATASOURCECODE = 'GB5_SELF_HOST', DATASOURCENAME = 'GB5 Self-Hosted Reports (BI Engine)', REMARKS = 'Generalized from the original ApiService pilot row (Phase 2) — any BI catalog backed by an existing GB5 report on this same host reuses this row. HostName/DataSourceType intentionally untouched.' WHERE DATASOURCEID = 1; END ELSE IF NOT EXISTS (SELECT 1 FROM MDATASOURCE WHERE DATASOURCECODE = 'GB5_SELF_HOST') BEGIN INSERT INTO MDATASOURCE (DATASOURCEID, DATASOURCECODE, DATASOURCENAME, DATASOURCETYPE, HOSTNAME, REMARKS, CREATEDBYID, MODIFIEDBYID) VALUES (1, 'GB5_SELF_HOST', 'GB5 Self-Hosted Reports (BI Engine)', 4, 'http://217.216.78.142:5102', 'This session''s known GB5DEMO business host — update via the DataSource admin screen if run in a different environment.', -1, -1); END GO -- ============================================================================= -- END OF MIGRATION 20260806_BIGeneralize_SelfHostDataSource (SQL Server) -- =============================================================================