-- Demo Seed Data for Likwid
-- This migration creates realistic governance data for demonstration purposes
-- 
-- IMPORTANT: This migration should ONLY be run on demo instances.
-- For production deployments, either:
--   1. Delete this migration file before running migrations
--   2. Use a separate database for demo (recommended)
--
-- The data includes:
--   - 3 demo accounts (contributor, moderator, observer) - password: [REDACTED]
--   - 10 fictional community members
--   - 3 communities (Aurora Framework, Civic Commons, Regional Makers)
--   - 7 proposals in various states
--   - Delegation relationships
--   - Moderation log entries
--   - Discussion comments

-- ============================================================================
-- DEMO USERS
-- ============================================================================

-- Demo accounts (password: [REDACTED] - bcrypt hash)
-- Hash generated with cost 12: $2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy
INSERT INTO users (id, username, email, password_hash, display_name, is_active) VALUES
    ('d0000001-0000-0000-0000-000000000001', 'contributor', 'contributor@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Demo Contributor', true),
    ('d0000001-0000-0000-0000-000000000002', 'moderator', 'moderator@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Demo Moderator', true),
    ('d0000001-0000-0000-0000-000000000003', 'observer', 'observer@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Demo Observer', true)
ON CONFLICT (username) DO NOTHING;

-- Fictional community members
INSERT INTO users (id, username, email, password_hash, display_name, is_active) VALUES
    ('d0000002-0000-0000-0000-000000000001', 'alice_dev', 'alice@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Alice Chen', true),
    ('d0000002-0000-0000-0000-000000000002', 'bob_maintainer', 'bob@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Bob Martinez', true),
    ('d0000002-0000-0000-0000-000000000003', 'carol_designer', 'carol@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Carol Nguyen', true),
    ('d0000002-0000-0000-0000-000000000004', 'david_infra', 'david@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'David Kim', true),
    ('d0000002-0000-0000-0000-000000000005', 'elena_community', 'elena@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Elena Rossi', true),
    ('d0000002-0000-0000-0000-000000000006', 'frank_policy', 'frank@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Frank Weber', true),
    ('d0000002-0000-0000-0000-000000000007', 'grace_legal', 'grace@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Grace Okonkwo', true),
    ('d0000002-0000-0000-0000-000000000008', 'henry_docs', 'henry@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Henry Liu', true),
    ('d0000002-0000-0000-0000-000000000009', 'iris_outreach', 'iris@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'Iris Johansson', true),
    ('d0000002-0000-0000-0000-000000000010', 'james_security', 'james@demo.likwid.org', '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/X4.S.NtqOGBNPB2Wy', 'James Park', true)
ON CONFLICT (username) DO NOTHING;

-- ============================================================================
-- DEMO COMMUNITIES
-- ============================================================================

-- Aurora Framework - Open Source Project
INSERT INTO communities (id, name, slug, description, settings, is_active) VALUES
    ('c0000001-0000-0000-0000-000000000001', 'Aurora Framework', 'aurora', 
     'A modern web framework for building scalable applications. This community governs technical decisions, RFC processes, and project direction.',
     '{"voting_method": "schulze", "require_read_before_vote": true, "min_discussion_days": 3}',
     true)
ON CONFLICT (slug) DO NOTHING;

-- Civic Commons Network - Political Movement
INSERT INTO communities (id, name, slug, description, settings, is_active) VALUES
    ('c0000001-0000-0000-0000-000000000002', 'Civic Commons Network', 'civic-commons',
     'A grassroots civic organization dedicated to participatory democracy and community engagement. We use quadratic voting for budget allocation and liquid delegation for policy decisions.',
     '{"voting_method": "quadratic", "delegation_enabled": true, "transparency_level": "full"}',
     true)
ON CONFLICT (slug) DO NOTHING;

-- Regional Makers Collective - Federation
INSERT INTO communities (id, name, slug, description, settings, is_active) VALUES
    ('c0000001-0000-0000-0000-000000000003', 'Regional Makers Collective', 'makers',
     'A federation of local makerspaces coordinating on shared resources, equipment purchases, and inter-chapter policies. Demonstrates federated governance across autonomous chapters.',
     '{"voting_method": "approval", "federation_enabled": true, "chapter_autonomy": true}',
     true)
ON CONFLICT (slug) DO NOTHING;

-- ============================================================================
-- COMMUNITY MEMBERSHIPS
-- ============================================================================

-- Aurora Framework members
INSERT INTO community_members (user_id, community_id, role) VALUES
    ('d0000001-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000001', 'member'),
    ('d0000001-0000-0000-0000-000000000002', 'c0000001-0000-0000-0000-000000000001', 'moderator'),
    ('d0000001-0000-0000-0000-000000000003', 'c0000001-0000-0000-0000-000000000001', 'member'),
    ('d0000002-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000001', 'admin'),
    ('d0000002-0000-0000-0000-000000000002', 'c0000001-0000-0000-0000-000000000001', 'maintainer'),
    ('d0000002-0000-0000-0000-000000000003', 'c0000001-0000-0000-0000-000000000001', 'member'),
    ('d0000002-0000-0000-0000-000000000004', 'c0000001-0000-0000-0000-000000000001', 'maintainer'),
    ('d0000002-0000-0000-0000-000000000008', 'c0000001-0000-0000-0000-000000000001', 'member'),
    ('d0000002-0000-0000-0000-000000000010', 'c0000001-0000-0000-0000-000000000001', 'member')
ON CONFLICT (user_id, community_id) DO NOTHING;

-- Civic Commons members
INSERT INTO community_members (user_id, community_id, role) VALUES
    ('d0000001-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000002', 'member'),
    ('d0000001-0000-0000-0000-000000000002', 'c0000001-0000-0000-0000-000000000002', 'moderator'),
    ('d0000001-0000-0000-0000-000000000003', 'c0000001-0000-0000-0000-000000000002', 'member'),
    ('d0000002-0000-0000-0000-000000000005', 'c0000001-0000-0000-0000-000000000002', 'admin'),
    ('d0000002-0000-0000-0000-000000000006', 'c0000001-0000-0000-0000-000000000002', 'delegate'),
    ('d0000002-0000-0000-0000-000000000007', 'c0000001-0000-0000-0000-000000000002', 'member'),
    ('d0000002-0000-0000-0000-000000000009', 'c0000001-0000-0000-0000-000000000002', 'member')
ON CONFLICT (user_id, community_id) DO NOTHING;

-- Makers Collective members
INSERT INTO community_members (user_id, community_id, role) VALUES
    ('d0000001-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000003', 'member'),
    ('d0000001-0000-0000-0000-000000000002', 'c0000001-0000-0000-0000-000000000003', 'moderator'),
    ('d0000001-0000-0000-0000-000000000003', 'c0000001-0000-0000-0000-000000000003', 'member'),
    ('d0000002-0000-0000-0000-000000000003', 'c0000001-0000-0000-0000-000000000003', 'member'),
    ('d0000002-0000-0000-0000-000000000004', 'c0000001-0000-0000-0000-000000000003', 'admin'),
    ('d0000002-0000-0000-0000-000000000008', 'c0000001-0000-0000-0000-000000000003', 'member'),
    ('d0000002-0000-0000-0000-000000000009', 'c0000001-0000-0000-0000-000000000003', 'member')
ON CONFLICT (user_id, community_id) DO NOTHING;

-- ============================================================================
-- VOTING IDENTITIES
-- ============================================================================

INSERT INTO voting_identities (user_id, community_id, pseudonym) VALUES
    ('d0000001-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000001', 'voter_aurora_001'),
    ('d0000001-0000-0000-0000-000000000002', 'c0000001-0000-0000-0000-000000000001', 'voter_aurora_002'),
    ('d0000002-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000001', 'voter_aurora_003'),
    ('d0000002-0000-0000-0000-000000000002', 'c0000001-0000-0000-0000-000000000001', 'voter_aurora_004'),
    ('d0000002-0000-0000-0000-000000000004', 'c0000001-0000-0000-0000-000000000001', 'voter_aurora_005'),
    ('d0000001-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000002', 'voter_civic_001'),
    ('d0000002-0000-0000-0000-000000000005', 'c0000001-0000-0000-0000-000000000002', 'voter_civic_002'),
    ('d0000002-0000-0000-0000-000000000006', 'c0000001-0000-0000-0000-000000000002', 'voter_civic_003'),
    ('d0000002-0000-0000-0000-000000000007', 'c0000001-0000-0000-0000-000000000002', 'voter_civic_004')
ON CONFLICT (user_id, community_id) DO NOTHING;

-- ============================================================================
-- TOPICS (for delegation)
-- ============================================================================

INSERT INTO topics (id, community_id, name, slug, description) VALUES
    ('a0000001-0000-0000-0000-000000000001', 'c0000001-0000-0000-0000-000000000001', 'Architecture', 'architecture', 'System architecture and design decisions'),
    ('a0000001-0000-0000-0000-000000000002', 'c0000001-0000-0000-0000-000000000001', 'API Design', 'api', 'Public API design and breaking changes'),
    ('a0000001-0000-0000-0000-000000000003', 'c0000001-0000-0000-0000-000000000001', 'Security', 'security', 'Security policies and vulnerability handling'),
    ('a0000001-0000-0000-0000-000000000004', 'c0000001-0000-0000-0000-000000000001', 'Documentation', 'docs', 'Documentation standards and practices'),
    ('a0000001-0000-0000-0000-000000000005', 'c0000001-0000-0000-0000-000000000002', 'Budget', 'budget', 'Financial decisions and budget allocation'),
    ('a0000001-0000-0000-0000-000000000006', 'c0000001-0000-0000-0000-000000000002', 'Policy', 'policy', 'Organizational policies and bylaws'),
    ('a0000001-0000-0000-0000-000000000007', 'c0000001-0000-0000-0000-000000000002', 'Outreach', 'outreach', 'Community outreach and partnerships'),
    ('a0000001-0000-0000-0000-000000000008', 'c0000001-0000-0000-0000-000000000003', 'Equipment', 'equipment', 'Shared equipment purchases and maintenance'),
    ('a0000001-0000-0000-0000-000000000009', 'c0000001-0000-0000-0000-000000000003', 'Events', 'events', 'Inter-chapter events and workshops')
ON CONFLICT (community_id, slug) DO NOTHING;

-- ============================================================================
-- PROPOSALS - AURORA FRAMEWORK
-- ============================================================================

-- Closed proposal: RFC for async runtime
INSERT INTO proposals (id, community_id, author_id, title, description, status, voting_method, topic_id, voting_starts_at, voting_ends_at, created_at) VALUES
    ('b0000001-0000-0000-0000-000000000001', 
     'c0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000001',
     'RFC-001: Adopt Tokio as the default async runtime',
     E'## Summary\n\nThis RFC proposes adopting Tokio as Aurora Framework''s default async runtime.\n\n## Motivation\n\nCurrently, Aurora supports multiple async runtimes, which causes:\n- Fragmented ecosystem\n- Duplicate testing effort\n- Confusion for new users\n\n## Proposal\n\nMake Tokio the default, with optional support for async-std via feature flags.\n\n## Alternatives Considered\n\n1. **Status quo** - Continue supporting all runtimes equally\n2. **async-std default** - Less ecosystem support\n3. **No default** - Too confusing for beginners',
     'closed',
     'schulze',
     'a0000001-0000-0000-0000-000000000001',
     NOW() - INTERVAL '30 days',
     NOW() - INTERVAL '23 days',
     NOW() - INTERVAL '45 days')
ON CONFLICT DO NOTHING;

-- Options for RFC-001
INSERT INTO proposal_options (id, proposal_id, label, description, sort_order) VALUES
    ('e0000001-0000-0000-0000-000000000001', 'b0000001-0000-0000-0000-000000000001', 'Adopt Tokio as default', 'Make Tokio the default runtime with async-std as optional', 1),
    ('e0000001-0000-0000-0000-000000000002', 'b0000001-0000-0000-0000-000000000001', 'Keep current multi-runtime support', 'Continue supporting all runtimes equally', 2),
    ('e0000001-0000-0000-0000-000000000003', 'b0000001-0000-0000-0000-000000000001', 'Defer decision', 'Postpone until more data is available', 3)
ON CONFLICT DO NOTHING;

-- Active voting proposal: Breaking change policy
INSERT INTO proposals (id, community_id, author_id, title, description, status, voting_method, topic_id, voting_starts_at, voting_ends_at, created_at) VALUES
    ('b0000001-0000-0000-0000-000000000002', 
     'c0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000002',
     'RFC-002: Semantic versioning and breaking change policy',
     E'## Summary\n\nDefine a clear policy for handling breaking changes in Aurora Framework.\n\n## Current Problem\n\nNo formal policy exists for:\n- When breaking changes are allowed\n- How to communicate them\n- Deprecation timelines\n\n## Proposed Policy\n\n1. Breaking changes only in major versions\n2. 6-month deprecation warnings\n3. Migration guides required\n4. LTS releases every 2 years',
     'voting',
     'schulze',
     'a0000001-0000-0000-0000-000000000002',
     NOW() - INTERVAL '2 days',
     NOW() + INTERVAL '5 days',
     NOW() - INTERVAL '14 days')
ON CONFLICT DO NOTHING;

-- Options for RFC-002
INSERT INTO proposal_options (id, proposal_id, label, description, sort_order) VALUES
    ('e0000001-0000-0000-0000-000000000004', 'b0000001-0000-0000-0000-000000000002', 'Strict semver with 6-month deprecation', 'Full proposal as described', 1),
    ('e0000001-0000-0000-0000-000000000005', 'b0000001-0000-0000-0000-000000000002', 'Strict semver with 3-month deprecation', 'Faster iteration with shorter warnings', 2),
    ('e0000001-0000-0000-0000-000000000006', 'b0000001-0000-0000-0000-000000000002', 'Epoch-based versioning', 'Major redesigns in epochs, minor breaking changes allowed', 3),
    ('e0000001-0000-0000-0000-000000000007', 'b0000001-0000-0000-0000-000000000002', 'No formal policy', 'Handle case by case', 4)
ON CONFLICT DO NOTHING;

-- Discussion proposal: Security disclosure process
INSERT INTO proposals (id, community_id, author_id, title, description, status, voting_method, topic_id, created_at) VALUES
    ('b0000001-0000-0000-0000-000000000003', 
     'c0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000010',
     'RFC-003: Security vulnerability disclosure process',
     E'## Summary\n\nEstablish a formal security vulnerability disclosure process for Aurora.\n\n## Background\n\nAs Aurora grows in adoption, we need a clear process for:\n- Receiving security reports\n- Coordinating fixes\n- Communicating with users\n- CVE assignment\n\n## Open Questions\n\n1. Should we have a bug bounty program?\n2. What is the appropriate disclosure timeline?\n3. Who should be on the security team?',
     'discussion',
     'approval',
     'a0000001-0000-0000-0000-000000000003',
     NOW() - INTERVAL '5 days')
ON CONFLICT DO NOTHING;

-- ============================================================================
-- PROPOSALS - CIVIC COMMONS
-- ============================================================================

-- Closed controversial proposal: Meeting format change (rejected)
INSERT INTO proposals (id, community_id, author_id, title, description, status, voting_method, topic_id, voting_starts_at, voting_ends_at, created_at) VALUES
    ('b0000001-0000-0000-0000-000000000004', 
     'c0000001-0000-0000-0000-000000000002',
     'd0000002-0000-0000-0000-000000000006',
     'Change monthly meetings to quarterly',
     E'## Proposal\n\nReduce the frequency of general assembly meetings from monthly to quarterly.\n\n## Rationale\n\nMonthly meetings have low attendance (average 23%). Quarterly meetings would:\n- Allow more preparation time\n- Reduce volunteer burnout\n- Enable higher-quality discussions\n\n## Opposition Arguments\n\nSome members argue this reduces democratic participation opportunities.',
     'closed',
     'approval',
     'a0000001-0000-0000-0000-000000000006',
     NOW() - INTERVAL '60 days',
     NOW() - INTERVAL '53 days',
     NOW() - INTERVAL '75 days')
ON CONFLICT DO NOTHING;

-- Options for quarterly meetings
INSERT INTO proposal_options (id, proposal_id, label, description, sort_order) VALUES
    ('e0000001-0000-0000-0000-000000000008', 'b0000001-0000-0000-0000-000000000004', 'Approve change to quarterly', 'Accept the proposal', 1),
    ('e0000001-0000-0000-0000-000000000009', 'b0000001-0000-0000-0000-000000000004', 'Reject - keep monthly', 'Maintain current schedule', 2)
ON CONFLICT DO NOTHING;

-- Active: Budget allocation using quadratic voting
INSERT INTO proposals (id, community_id, author_id, title, description, status, voting_method, topic_id, voting_starts_at, voting_ends_at, created_at) VALUES
    ('b0000001-0000-0000-0000-000000000005', 
     'c0000001-0000-0000-0000-000000000002',
     'd0000002-0000-0000-0000-000000000005',
     '2026 Q2 Budget Allocation',
     E'## Budget Overview\n\nTotal available: €15,000\n\n## Proposed Allocations\n\nUse quadratic voting to allocate budget across these initiatives:\n\n1. **Community Outreach** - Flyers, events, social media\n2. **Legal Fund** - Lawyer retainer for policy advocacy\n3. **Digital Infrastructure** - Website, tools, hosting\n4. **Training Programs** - Workshops for members\n5. **Emergency Reserve** - Unallocated contingency\n\nEach member receives 100 voice credits to allocate.',
     'voting',
     'quadratic',
     'a0000001-0000-0000-0000-000000000005',
     NOW() - INTERVAL '1 day',
     NOW() + INTERVAL '6 days',
     NOW() - INTERVAL '10 days')
ON CONFLICT DO NOTHING;

-- Options for budget allocation
INSERT INTO proposal_options (id, proposal_id, label, description, sort_order) VALUES
    ('e0000001-0000-0000-0000-000000000010', 'b0000001-0000-0000-0000-000000000005', 'Community Outreach', 'Marketing, events, awareness campaigns', 1),
    ('e0000001-0000-0000-0000-000000000011', 'b0000001-0000-0000-0000-000000000005', 'Legal Fund', 'Policy advocacy and legal support', 2),
    ('e0000001-0000-0000-0000-000000000012', 'b0000001-0000-0000-0000-000000000005', 'Digital Infrastructure', 'Websites, tools, and hosting', 3),
    ('e0000001-0000-0000-0000-000000000013', 'b0000001-0000-0000-0000-000000000005', 'Training Programs', 'Member education and workshops', 4),
    ('e0000001-0000-0000-0000-000000000014', 'b0000001-0000-0000-0000-000000000005', 'Emergency Reserve', 'Contingency fund', 5)
ON CONFLICT DO NOTHING;

-- ============================================================================
-- PROPOSALS - MAKERS COLLECTIVE
-- ============================================================================

-- Closed: Shared laser cutter purchase
INSERT INTO proposals (id, community_id, author_id, title, description, status, voting_method, topic_id, voting_starts_at, voting_ends_at, created_at) VALUES
    ('b0000001-0000-0000-0000-000000000006', 
     'c0000001-0000-0000-0000-000000000003',
     'd0000002-0000-0000-0000-000000000004',
     'Shared laser cutter purchase - Glowforge Pro',
     E'## Proposal\n\nPurchase a Glowforge Pro laser cutter (€6,500) for shared use across chapters.\n\n## Hosting\n\nThe machine would be hosted at the Central Chapter, with a booking system for all members.\n\n## Cost Sharing\n\n- 40% Central Chapter\n- 20% each for North, South, and East chapters\n\n## Maintenance\n\nMonthly maintenance fund of €50 contributed equally.',
     'closed',
     'approval',
     'a0000001-0000-0000-0000-000000000008',
     NOW() - INTERVAL '45 days',
     NOW() - INTERVAL '38 days',
     NOW() - INTERVAL '60 days')
ON CONFLICT DO NOTHING;

-- Options for laser cutter
INSERT INTO proposal_options (id, proposal_id, label, description, sort_order) VALUES
    ('e0000001-0000-0000-0000-000000000015', 'b0000001-0000-0000-0000-000000000006', 'Approve purchase', 'Buy the Glowforge Pro with proposed cost sharing', 1),
    ('e0000001-0000-0000-0000-000000000016', 'b0000001-0000-0000-0000-000000000006', 'Reject', 'Do not proceed with purchase', 2)
ON CONFLICT DO NOTHING;

-- Active: Inter-chapter workshop series
INSERT INTO proposals (id, community_id, author_id, title, description, status, voting_method, topic_id, voting_starts_at, voting_ends_at, created_at) VALUES
    ('b0000001-0000-0000-0000-000000000007', 
     'c0000001-0000-0000-0000-000000000003',
     'd0000002-0000-0000-0000-000000000009',
     'Summer 2026 Inter-Chapter Workshop Series',
     E'## Proposal\n\nOrganize a series of traveling workshops where experts from each chapter teach at other locations.\n\n## Proposed Topics\n\n1. CNC routing basics (North Chapter)\n2. Electronics prototyping (Central Chapter)\n3. 3D printing materials (South Chapter)\n4. Woodworking joinery (East Chapter)\n\n## Schedule\n\nOne weekend per month, June-September 2026.',
     'voting',
     'approval',
     'a0000001-0000-0000-0000-000000000009',
     NOW() - INTERVAL '3 days',
     NOW() + INTERVAL '4 days',
     NOW() - INTERVAL '12 days')
ON CONFLICT DO NOTHING;

-- Options for workshop series
INSERT INTO proposal_options (id, proposal_id, label, description, sort_order) VALUES
    ('e0000001-0000-0000-0000-000000000017', 'b0000001-0000-0000-0000-000000000007', 'Approve full series', 'Run all 4 workshops as proposed', 1),
    ('e0000001-0000-0000-0000-000000000018', 'b0000001-0000-0000-0000-000000000007', 'Pilot with 2 workshops', 'Start with 2 workshops to test format', 2),
    ('e0000001-0000-0000-0000-000000000019', 'b0000001-0000-0000-0000-000000000007', 'Defer to fall', 'Better timing after summer holidays', 3)
ON CONFLICT DO NOTHING;

-- ============================================================================
-- DELEGATIONS
-- ============================================================================

-- Alice delegates to Bob on architecture topics
INSERT INTO delegations (id, delegator_id, delegate_id, scope, community_id, topic_id, is_active, created_at) VALUES
    ('de000001-0000-0000-0000-000000000001',
     'd0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000002',
     'topic',
     'c0000001-0000-0000-0000-000000000001',
     'a0000001-0000-0000-0000-000000000001',
     true,
     NOW() - INTERVAL '90 days')
ON CONFLICT DO NOTHING;

-- Contributor delegates to Frank on policy topics in Civic Commons
INSERT INTO delegations (id, delegator_id, delegate_id, scope, community_id, topic_id, is_active, created_at) VALUES
    ('de000001-0000-0000-0000-000000000002',
     'd0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000006',
     'topic',
     'c0000001-0000-0000-0000-000000000002',
     'a0000001-0000-0000-0000-000000000006',
     true,
     NOW() - INTERVAL '60 days')
ON CONFLICT DO NOTHING;

-- Observer delegates to Elena globally in Civic Commons
INSERT INTO delegations (id, delegator_id, delegate_id, scope, community_id, is_active, created_at) VALUES
    ('de000001-0000-0000-0000-000000000003',
     'd0000001-0000-0000-0000-000000000003',
     'd0000002-0000-0000-0000-000000000005',
     'community',
     'c0000001-0000-0000-0000-000000000002',
     true,
     NOW() - INTERVAL '45 days')
ON CONFLICT DO NOTHING;

-- Revoked delegation example
INSERT INTO delegations (id, delegator_id, delegate_id, scope, community_id, is_active, revoked_at, created_at) VALUES
    ('de000001-0000-0000-0000-000000000004',
     'd0000002-0000-0000-0000-000000000003',
     'd0000002-0000-0000-0000-000000000001',
     'community',
     'c0000001-0000-0000-0000-000000000001',
     false,
     NOW() - INTERVAL '20 days',
     NOW() - INTERVAL '100 days')
ON CONFLICT DO NOTHING;

-- ============================================================================
-- MODERATION LOG
-- ============================================================================

-- Example moderation actions
INSERT INTO moderation_log (community_id, moderator_id, target_user_id, action_type, reason, details, created_at) VALUES
    ('c0000001-0000-0000-0000-000000000001',
     'd0000001-0000-0000-0000-000000000002',
     NULL,
     'content_edit',
     'Updated RFC-001 description for clarity',
     '{"proposal_id": "b0000001-0000-0000-0000-000000000001", "field": "description", "change_type": "formatting"}',
     NOW() - INTERVAL '40 days'),
    
    ('c0000001-0000-0000-0000-000000000002',
     'd0000001-0000-0000-0000-000000000002',
     'd0000002-0000-0000-0000-000000000009',
     'warning',
     'Off-topic discussion in budget proposal thread',
     '{"rule": "community_guidelines_3", "comment_id": "comment_example_001"}',
     NOW() - INTERVAL '8 days'),
    
    ('c0000001-0000-0000-0000-000000000003',
     'd0000001-0000-0000-0000-000000000002',
     NULL,
     'proposal_extended',
     'Extended voting deadline by 48 hours due to technical issues',
     '{"proposal_id": "b0000001-0000-0000-0000-000000000006", "original_end": "2026-01-10T00:00:00Z", "new_end": "2026-01-12T00:00:00Z"}',
     NOW() - INTERVAL '39 days');

-- ============================================================================
-- COMMENTS (for deliberation history)
-- ============================================================================

INSERT INTO comments (id, proposal_id, author_id, content, created_at) VALUES
    ('cc000001-0000-0000-0000-000000000001',
     'b0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000002',
     'I support this RFC. Tokio has the best ecosystem support and most active maintenance.',
     NOW() - INTERVAL '42 days'),
    
    ('cc000001-0000-0000-0000-000000000002',
     'b0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000004',
     'Concerned about async-std users being left behind. Can we ensure the migration path is clear?',
     NOW() - INTERVAL '41 days'),
    
    ('cc000001-0000-0000-0000-000000000003',
     'b0000001-0000-0000-0000-000000000001',
     'd0000002-0000-0000-0000-000000000001',
     'Good point, David. I will add a migration guide section to the RFC.',
     NOW() - INTERVAL '40 days'),
    
    ('cc000001-0000-0000-0000-000000000004',
     'b0000001-0000-0000-0000-000000000002',
     'd0000002-0000-0000-0000-000000000010',
     'From a security perspective, I strongly prefer the 6-month deprecation window. It gives downstream users adequate time to update.',
     NOW() - INTERVAL '10 days'),
    
    ('cc000001-0000-0000-0000-000000000005',
     'b0000001-0000-0000-0000-000000000005',
     'd0000002-0000-0000-0000-000000000007',
     'I think we should prioritize the legal fund given the upcoming policy changes at the regional level.',
     NOW() - INTERVAL '5 days')
ON CONFLICT DO NOTHING;

-- ============================================================================
-- DELEGATE PROFILES
-- ============================================================================

INSERT INTO delegate_profiles (user_id, display_name, bio, accepting_delegations, delegation_policy, total_delegators) VALUES
    ('d0000002-0000-0000-0000-000000000002',
     'Bob Martinez',
     'Aurora core maintainer since 2023. Focused on runtime and async systems.',
     true,
     'I vote based on technical merit and long-term maintainability. I prioritize backwards compatibility.',
     3),
    
    ('d0000002-0000-0000-0000-000000000006',
     'Frank Weber',
     'Policy researcher and community organizer. 10 years experience in participatory democracy.',
     true,
     'I consult with delegators before major votes. I prioritize inclusive decision-making processes.',
     5),
    
    ('d0000002-0000-0000-0000-000000000005',
     'Elena Rossi',
     'Community manager for Civic Commons. Focused on member engagement and organizational health.',
     true,
     'I vote to maximize member participation and organizational sustainability.',
     2)
ON CONFLICT (user_id) DO NOTHING;
