Database
Overview
Schema Structure
Core Tables
1. chat_messages
CREATE TABLE chat_messages (
id SERIAL PRIMARY KEY,
message_id BIGINT NOT NULL,
chat_id BIGINT NOT NULL,
user_id BIGINT NOT NULL,
user_first_name VARCHAR(255) NOT NULL,
username VARCHAR(255),
role VARCHAR(50) NOT NULL,
content TEXT NOT NULL,
timestamp BIGINT NOT NULL,
reply_to_message_id BIGINT,
agent_id VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
UNIQUE(chat_id, message_id, agent_id)
);
-- Indexes
CREATE INDEX idx_chat_messages_chat_id_timestamp
ON chat_messages(chat_id, timestamp DESC);
CREATE INDEX idx_chat_messages_agent_id
ON chat_messages(agent_id);2. posts
3. user_data
4. command_metrics
5. gerta_poses
6. illustrations
7. agents
8. model_preferences
Type Definitions
Core Types
Database Operations
Message Operations
Agent Operations
Metrics Operations
Performance Considerations
1. Indexing Strategy
2. Query Optimization
3. Connection Management
Security Features
1. Data Protection
2. Access Control
Best Practices
1. Data Access
2. Schema Management
3. Performance
Related Documentation
Last updated