AeThex-Connect/supabase/migrations/20260110130000_gameforge_integration.sql
MrPiglr 185e76c0c4
Phase 3: GameForge Integration - Auto-Provisioning & Role-Based Channels
🏗️ Database Schema
- Create gameforge_integrations table
- Add gameforge_project_id to conversations
- Create audit_logs table for operation tracking
- Add metadata and is_archived columns
- Implement indexes and triggers

🔧 Backend Services
- GameForgeIntegrationService (450+ lines)
  - Auto-provision projects and channels
  - Team member synchronization
  - Role-based permission enforcement
  - System notification delivery
  - Project archival management

🔐 Authentication & Security
- GameForge API key authentication
- HMAC-SHA256 signature validation
- Timestamp verification (5-minute window)
- Replay attack prevention
- Audit logging

🌐 API Endpoints (8 endpoints)
- POST /api/gameforge/projects - Provision project
- PATCH /api/gameforge/projects/:id/team - Update team
- DELETE /api/gameforge/projects/:id - Archive project
- GET /api/gameforge/projects/:id/channels - List channels
- POST /api/gameforge/projects/:id/channels - Create channel
- PATCH /api/gameforge/channels/:id - Update channel
- DELETE /api/gameforge/channels/:id - Delete channel
- POST /api/gameforge/projects/:id/notify - Send notification

🎨 Frontend Components
- GameForgeChat - Embedded chat container
- ChannelList - Channel navigation with icons
- ChannelView - Message display and input
- Responsive CSS with mobile support

📚 Documentation
- PHASE3-GAMEFORGE.md - Complete technical docs
- GAMEFORGE-EXAMPLES.md - Integration code samples
- API reference with request/response examples
- Testing guidelines and checklist

 Features
- Automatic channel provisioning on project creation
- Role-based channel permissions (dev, art, testing, etc.)
- System notifications (builds, commits, deployments)
- Team member sync with role updates
- Custom channel creation
- Project archival

📊 Stats
- 16 new files created
- 2 files updated
- ~2,750 lines of code
- 8 API endpoints
- 7 React components
2026-01-10 04:57:23 +00:00

66 lines
3 KiB
PL/PgSQL

-- Phase 3: GameForge Integration Migration
-- Auto-provision communication channels for GameForge projects
-- Migration: 20260110130000
-- GameForge project integrations
CREATE TABLE IF NOT EXISTS gameforge_integrations (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
project_id VARCHAR(255) UNIQUE NOT NULL, -- GameForge project ID
domain VARCHAR(255) UNIQUE NOT NULL, -- e.g., hideandseek@forge.aethex.dev
auto_provision_channels BOOLEAN DEFAULT true,
channel_config JSONB DEFAULT '{}', -- Default channel configuration
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- Add GameForge project reference to conversations
ALTER TABLE conversations
ADD COLUMN IF NOT EXISTS gameforge_project_id VARCHAR(255) REFERENCES gameforge_integrations(project_id) ON DELETE CASCADE;
-- Add metadata column to conversations if not exists (for channel permissions)
ALTER TABLE conversations
ADD COLUMN IF NOT EXISTS metadata JSONB DEFAULT '{}';
-- Add is_archived column to conversations if not exists
ALTER TABLE conversations
ADD COLUMN IF NOT EXISTS is_archived BOOLEAN DEFAULT false;
-- Audit log for GameForge operations
CREATE TABLE IF NOT EXISTS audit_logs (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id) ON DELETE SET NULL,
action VARCHAR(100) NOT NULL,
resource_type VARCHAR(100) NOT NULL,
resource_id VARCHAR(255),
metadata JSONB DEFAULT '{}',
created_at TIMESTAMP DEFAULT NOW()
);
-- Indexes for performance
CREATE INDEX IF NOT EXISTS idx_gameforge_integrations_project_id ON gameforge_integrations(project_id);
CREATE INDEX IF NOT EXISTS idx_conversations_gameforge_project ON conversations(gameforge_project_id) WHERE gameforge_project_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_conversations_archived ON conversations(is_archived);
CREATE INDEX IF NOT EXISTS idx_audit_logs_user_id ON audit_logs(user_id);
CREATE INDEX IF NOT EXISTS idx_audit_logs_created_at ON audit_logs(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_audit_logs_resource ON audit_logs(resource_type, resource_id);
-- Trigger to update updated_at timestamp on gameforge_integrations
CREATE OR REPLACE FUNCTION update_gameforge_integration_timestamp()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER gameforge_integration_updated
BEFORE UPDATE ON gameforge_integrations
FOR EACH ROW
EXECUTE FUNCTION update_gameforge_integration_timestamp();
-- Comments
COMMENT ON TABLE gameforge_integrations IS 'Links GameForge projects to AeThex Connect communication infrastructure';
COMMENT ON TABLE audit_logs IS 'Audit trail for GameForge integration operations';
COMMENT ON COLUMN conversations.gameforge_project_id IS 'Links conversation to GameForge project for auto-provisioned channels';
COMMENT ON COLUMN conversations.metadata IS 'Stores channel-specific data like permissions, channel type, etc.';
COMMENT ON COLUMN conversations.is_archived IS 'Soft delete for archived projects';