-- Migration 028: District Rooms Seed Data
-- Purpose: Create initial rooms for Energyunion and GREENFOOD districts
-- Based on: docs/foundation/District_Interface_Architecture_v1.md
-- Date: 2025-11-29

-- ============================================================================
-- 1. ENERGYUNION District Rooms
-- ============================================================================

INSERT INTO rooms (id, owner_type, owner_id, type, space_scope, visibility, name, description, primary_agent_id, is_portal)
VALUES 
    -- District Center
    ('energyunion-center', 'microdao', 'energyunion', 'district-room', 'district', 'members', 'Energy Center', 'Central hub of Energyunion district', 'helion', false),
    
    -- Public Rooms
    ('energyunion-news', 'microdao', 'energyunion', 'district-room', 'district', 'public-city', 'Energy News', 'Latest news from Energyunion', 'helion', false),
    ('energyunion-help', 'microdao', 'energyunion', 'district-room', 'district', 'public-city', 'Energy Help', 'Support and assistance for energy platform', 'helion', false),
    ('energyunion-events', 'microdao', 'energyunion', 'district-room', 'district', 'public-city', 'Energy Events', 'Events and activities in energy sector', 'helion', false),
    
    -- District Portal on City Square
    ('energyunion-city-portal', 'microdao', 'energyunion', 'front-room', 'city', 'public-city', 'Energyunion Portal', 'Energyunion district entrance on City Square', 'helion', true)
ON CONFLICT (id) DO UPDATE SET
    name = EXCLUDED.name,
    description = EXCLUDED.description,
    primary_agent_id = EXCLUDED.primary_agent_id;

-- Set portal target
UPDATE rooms SET portal_target_microdao_id = 'energyunion', map_x = 100, map_y = 50, zone = 'energy-sector'
WHERE id = 'energyunion-city-portal';

-- ============================================================================
-- 2. GREENFOOD District Rooms
-- ============================================================================

INSERT INTO rooms (id, owner_type, owner_id, type, space_scope, visibility, name, description, primary_agent_id, is_portal)
VALUES 
    -- District Center
    ('greenfood-center', 'microdao', 'greenfood', 'district-room', 'district', 'members', 'GreenFood Center', 'Central hub of GREENFOOD district', 'erp-agent', false),
    
    -- Public Rooms
    ('greenfood-news', 'microdao', 'greenfood', 'district-room', 'district', 'public-city', 'GreenFood News', 'Latest news from GREENFOOD', 'erp-agent', false),
    ('greenfood-help', 'microdao', 'greenfood', 'district-room', 'district', 'public-city', 'GreenFood Help', 'Support and assistance for agro platform', 'erp-agent', false),
    ('greenfood-marketplace', 'microdao', 'greenfood', 'district-room', 'district', 'public-city', 'GreenFood Marketplace', 'Agricultural products and services', 'erp-agent', false),
    
    -- District Portal on City Square
    ('greenfood-city-portal', 'microdao', 'greenfood', 'front-room', 'city', 'public-city', 'GREENFOOD Portal', 'GREENFOOD district entrance on City Square', 'erp-agent', true)
ON CONFLICT (id) DO UPDATE SET
    name = EXCLUDED.name,
    description = EXCLUDED.description,
    primary_agent_id = EXCLUDED.primary_agent_id;

-- Set portal target
UPDATE rooms SET portal_target_microdao_id = 'greenfood', map_x = 200, map_y = 50, zone = 'agro-sector'
WHERE id = 'greenfood-city-portal';

-- ============================================================================
-- 3. Update City Square with district portals
-- ============================================================================

-- Add team_agent_ids to city rooms
UPDATE rooms SET team_agent_ids = ARRAY['daria', 'daarwizz']
WHERE id = 'city-square';

-- ============================================================================
-- Done
-- ============================================================================

SELECT 'Migration 028 completed: District rooms created for Energyunion and GREENFOOD' as result;

