Spaces:
Paused
Paused
Download shared/sql/action_generation_schema.sql from VAH6002/ai_data_scientist: direct link, hf CLI and curl.
- Browser
- Download file 5.09 kB
-
https://huggingface.co/spaces/VAH6002/ai_data_scientist/resolve/main/shared/sql/action_generation_schema.sql
- Command line
-
hf download hf://spaces/VAH6002/ai_data_scientist/shared/sql/action_generation_schema.sql
-
curl -L -o action_generation_schema.sql https://huggingface.co/spaces/VAH6002/ai_data_scientist/resolve/main/shared/sql/action_generation_schema.sql
5.09 kB
| -- Action Generation MCP Server Database Schema | |
| -- Handles business recommendations, action items, and executive summaries | |
| -- Table for storing business recommendations | |
| CREATE TABLE IF NOT EXISTS business_recommendations ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| user_id VARCHAR NOT NULL, | |
| analysis_session_id UUID, | |
| model_id UUID, | |
| business_context TEXT NOT NULL, | |
| key_insights JSONB DEFAULT '[]', | |
| action_items JSONB DEFAULT '[]', | |
| kpi_recommendations JSONB DEFAULT '[]', | |
| timeline VARCHAR, | |
| confidence_score FLOAT DEFAULT 0.0, | |
| created_at TIMESTAMP DEFAULT NOW(), | |
| updated_at TIMESTAMP DEFAULT NOW() | |
| ); | |
| -- Table for storing executive summaries | |
| CREATE TABLE IF NOT EXISTS executive_summaries ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| user_id VARCHAR NOT NULL, | |
| analysis_session_id UUID, | |
| title VARCHAR NOT NULL, | |
| overview TEXT NOT NULL, | |
| key_findings JSONB DEFAULT '[]', | |
| recommendations JSONB DEFAULT '[]', | |
| next_steps JSONB DEFAULT '[]', | |
| created_at TIMESTAMP DEFAULT NOW() | |
| ); | |
| -- Table for storing exported reports | |
| CREATE TABLE IF NOT EXISTS exported_reports ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| user_id VARCHAR NOT NULL, | |
| analysis_session_id UUID, | |
| report_type VARCHAR NOT NULL CHECK (report_type IN ('pdf', 'html', 'json')), | |
| file_path VARCHAR NOT NULL, | |
| file_size_bytes BIGINT DEFAULT 0, | |
| export_parameters JSONB DEFAULT '{}', | |
| created_at TIMESTAMP DEFAULT NOW() | |
| ); | |
| -- Table for storing recommendation generation sessions | |
| CREATE TABLE IF NOT EXISTS recommendation_sessions ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| user_id VARCHAR NOT NULL, | |
| model_id UUID NOT NULL, | |
| business_context TEXT NOT NULL, | |
| generation_status VARCHAR DEFAULT 'running' CHECK (generation_status IN ('running', 'completed', 'failed')), | |
| error_message TEXT, | |
| gemini_prompt TEXT, | |
| gemini_response TEXT, | |
| processing_time_seconds FLOAT DEFAULT 0, | |
| created_at TIMESTAMP DEFAULT NOW(), | |
| completed_at TIMESTAMP | |
| ); | |
| -- Table for storing action item prioritization | |
| CREATE TABLE IF NOT EXISTS action_prioritization ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| user_id VARCHAR NOT NULL, | |
| recommendation_id UUID REFERENCES business_recommendations(id), | |
| action_item_index INTEGER NOT NULL, | |
| priority_score FLOAT NOT NULL, | |
| impact_estimation VARCHAR NOT NULL, | |
| implementation_timeline VARCHAR NOT NULL, | |
| required_resources JSONB DEFAULT '[]', | |
| risk_assessment TEXT, | |
| created_at TIMESTAMP DEFAULT NOW() | |
| ); | |
| -- Indexes for performance | |
| CREATE INDEX IF NOT EXISTS idx_business_recommendations_user_id ON business_recommendations(user_id); | |
| CREATE INDEX IF NOT EXISTS idx_business_recommendations_analysis_session_id ON business_recommendations(analysis_session_id); | |
| CREATE INDEX IF NOT EXISTS idx_business_recommendations_model_id ON business_recommendations(model_id); | |
| CREATE INDEX IF NOT EXISTS idx_executive_summaries_user_id ON executive_summaries(user_id); | |
| CREATE INDEX IF NOT EXISTS idx_executive_summaries_analysis_session_id ON executive_summaries(analysis_session_id); | |
| CREATE INDEX IF NOT EXISTS idx_exported_reports_user_id ON exported_reports(user_id); | |
| CREATE INDEX IF NOT EXISTS idx_exported_reports_analysis_session_id ON exported_reports(analysis_session_id); | |
| CREATE INDEX IF NOT EXISTS idx_recommendation_sessions_user_id ON recommendation_sessions(user_id); | |
| CREATE INDEX IF NOT EXISTS idx_recommendation_sessions_model_id ON recommendation_sessions(model_id); | |
| CREATE INDEX IF NOT EXISTS idx_action_prioritization_user_id ON action_prioritization(user_id); | |
| CREATE INDEX IF NOT EXISTS idx_action_prioritization_recommendation_id ON action_prioritization(recommendation_id); | |
| -- Row Level Security (RLS) policies | |
| ALTER TABLE business_recommendations ENABLE ROW LEVEL SECURITY; | |
| ALTER TABLE executive_summaries ENABLE ROW LEVEL SECURITY; | |
| ALTER TABLE exported_reports ENABLE ROW LEVEL SECURITY; | |
| ALTER TABLE recommendation_sessions ENABLE ROW LEVEL SECURITY; | |
| ALTER TABLE action_prioritization ENABLE ROW LEVEL SECURITY; | |
| -- RLS Policies for user isolation | |
| CREATE POLICY business_recommendations_user_isolation ON business_recommendations | |
| FOR ALL TO application_role | |
| USING (user_id = current_setting('app.current_user_id')); | |
| CREATE POLICY executive_summaries_user_isolation ON executive_summaries | |
| FOR ALL TO application_role | |
| USING (user_id = current_setting('app.current_user_id')); | |
| CREATE POLICY exported_reports_user_isolation ON exported_reports | |
| FOR ALL TO application_role | |
| USING (user_id = current_setting('app.current_user_id')); | |
| CREATE POLICY recommendation_sessions_user_isolation ON recommendation_sessions | |
| FOR ALL TO application_role | |
| USING (user_id = current_setting('app.current_user_id')); | |
| CREATE POLICY action_prioritization_user_isolation ON action_prioritization | |
| FOR ALL TO application_role | |
| USING (user_id = current_setting('app.current_user_id')); |