rdev/internal/db/migrations/014_build_events.sql
jordan c59d348040 chore: prepare for composable monorepo template implementation
This commit captures the current state before implementing the composable
monorepo template system. Key changes included:

Infrastructure:
- Add CockroachDB provisioner adapter for database provisioning
- Add Redis provisioner adapter for cache provisioning
- Add build events system with PostgreSQL storage
- Add WebSocket endpoint for real-time build progress

Code agent improvements:
- Fix Claude Code adapter to use default allowed tools instead of dangerously-skip-permissions
- Add context-aware stream closing for cancellation support
- Improve parser tests for edge cases

Build system:
- Add build event constants and metrics
- Remove deprecated git_operations.go (replaced by pod_git_operations.go)
- Add rollback logic for multi-step provisioning operations

Documentation:
- Add composable-monorepo feature documentation
- Add DNS/Cloudflare service documentation
- Update deployment and troubleshooting guides

Cookbooks:
- Add fullstack-app cookbook
- Refactor landing-test with shared library

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 11:39:28 -07:00

34 lines
2.0 KiB
SQL

-- Build Events: PostgreSQL-backed event persistence for SSE replay
-- Stores build events for reconnection support beyond in-memory buffer
CREATE TABLE IF NOT EXISTS build_events (
id TEXT PRIMARY KEY, -- Event ID (format: "{task_id}:{sequence}")
task_id TEXT NOT NULL, -- Build task ID
project_id TEXT NOT NULL, -- Project ID
type TEXT NOT NULL, -- Event type (build.started, build.output, etc.)
sequence BIGINT NOT NULL, -- Monotonic sequence within task
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(), -- When event occurred
data JSONB NOT NULL DEFAULT '{}', -- Event-specific payload
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() -- When stored (for cleanup)
);
-- Index for efficient task-based queries (replay by task ID)
CREATE INDEX IF NOT EXISTS idx_build_events_task_id ON build_events(task_id);
-- Index for efficient sequence-based replay (Last-Event-ID support)
CREATE INDEX IF NOT EXISTS idx_build_events_task_sequence ON build_events(task_id, sequence);
-- Index for cleanup queries (delete old events)
CREATE INDEX IF NOT EXISTS idx_build_events_created_at ON build_events(created_at);
-- Comments
COMMENT ON TABLE build_events IS 'Persisted build events for SSE replay support';
COMMENT ON COLUMN build_events.id IS 'Unique event ID (format: {task_id}:{sequence})';
COMMENT ON COLUMN build_events.task_id IS 'Build task this event belongs to';
COMMENT ON COLUMN build_events.project_id IS 'Project this event belongs to';
COMMENT ON COLUMN build_events.type IS 'Event type (build.started, build.output, build.completed, etc.)';
COMMENT ON COLUMN build_events.sequence IS 'Monotonically increasing sequence number within task';
COMMENT ON COLUMN build_events.timestamp IS 'When the event occurred';
COMMENT ON COLUMN build_events.data IS 'Event-specific payload as JSONB';
COMMENT ON COLUMN build_events.created_at IS 'When stored in database (used for cleanup)';