-- 12_drop_ops.sql
-- Purge the dormant `ops` schema (workshop / tickets / dispatch / SLA / odometer)
-- and the dispatch/SLA artefacts that lived in `tracksolid`. These features were
-- never implemented and may take a different direction; the schema and views were
-- empty (or seed-only) and unused by the live map/dashboard pipeline.
--
-- Created by migrations 06 (ops schema + dispatch_log), 07 (v_sla_inflight) and
-- 08 (ops.cost_rates / ops.kpi_targets seed). Per the repo rule we do NOT rewrite
-- those applied migrations — this forward migration drops the objects instead. On
-- a fresh rebuild 06/07/08 create them, then this file removes them again.
--
-- Pre-drop snapshot of the only seeded tables: docs/reports/260605_ops_purge_backup.md
-- (the seed is also reproducible from 08_analytics_config.sql).
--
-- Every statement is IF EXISTS so the file is safe to re-apply.
--
-- NOTE: dwh_gold and tracksolid.v_utilisation_daily are intentionally NOT touched
-- here — that is a separate decision.

-- View first: it reads ops.tickets + tracksolid.dispatch_log, so it must go before
-- the objects it depends on (avoids an implicit CASCADE surprise).
DROP VIEW IF EXISTS tracksolid.v_sla_inflight;

-- The whole ops schema: tickets, service_log, odometer_readings, cost_rates,
-- kpi_targets, and the view vw_service_forecast. CASCADE clears intra-schema deps.
DROP SCHEMA IF EXISTS ops CASCADE;

-- Dispatch feature table — lived in the tracksolid schema, empty, only fed
-- v_sla_inflight (now dropped).
DROP TABLE IF EXISTS tracksolid.dispatch_log;
