-- =============================================================================
-- 004_map_layers_drop_columns.sql
-- Post-migration cleanup: removes the per-page config columns from
-- public.map_layers now that map_layer_page_config is the authoritative source.
--
-- DO NOT RUN until:
--   - All pages (including map_v5.js) are confirmed live on the junction table.
--   - All hardcoded layersData arrays have been removed from JS files.
--   - The system has been stable in production.
-- =============================================================================

CREATE TABLE public.map_layers_backup_2026_06_28 AS SELECT * FROM map_layers;

ALTER TABLE public.map_layers
    DROP COLUMN IF EXISTS visible,
    DROP COLUMN IF EXISTS layer_editable,
    DROP COLUMN IF EXISTS layer_allow_create,
    DROP COLUMN IF EXISTS snap_to_this,
    DROP COLUMN IF EXISTS focus_on_load;
