Highly ambitious ATProtocol AppView service and sdks
at main 1.4 kB view raw
1-- Create logs table for sync jobs and jetstream activity 2CREATE TABLE logs ( 3 id BIGSERIAL PRIMARY KEY, 4 created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), 5 log_type VARCHAR(50) NOT NULL, -- 'sync_job', 'jetstream', etc. 6 job_id UUID NULL, -- For sync job logs, null for jetstream logs 7 user_did TEXT NULL, -- User associated with the log (for filtering) 8 slice_uri TEXT NULL, -- Slice associated with the log (for filtering) 9 level VARCHAR(20) NOT NULL DEFAULT 'info', -- 'debug', 'info', 'warn', 'error' 10 message TEXT NOT NULL, 11 metadata JSONB NULL -- Additional structured data (counts, errors, etc.) 12); 13 14-- Create indexes for efficient queries 15CREATE INDEX idx_logs_type_job_id ON logs (log_type, job_id); 16CREATE INDEX idx_logs_type_created_at ON logs (log_type, created_at); 17CREATE INDEX idx_logs_user_did ON logs (user_did); 18CREATE INDEX idx_logs_slice_uri ON logs (slice_uri); 19 20-- Add some helpful comments 21COMMENT ON TABLE logs IS 'Unified logging table for sync jobs, jetstream, and other system activities'; 22COMMENT ON COLUMN logs.log_type IS 'Type of log entry: sync_job, jetstream, system, etc.'; 23COMMENT ON COLUMN logs.job_id IS 'Associated job ID for sync job logs, null for other log types'; 24COMMENT ON COLUMN logs.level IS 'Log level: debug, info, warn, error'; 25COMMENT ON COLUMN logs.metadata IS 'Additional structured data as JSON (progress, errors, counts, etc.)';