Include the schedule data date (last_recalc_date from XER) in the get_project_summary tool response. This shows when the schedule was last calculated in P6. Changes: - Add last_recalc_date column to projects table schema - Parse last_recalc_date in PROJECT table handler - Include last_recalc_date in db loader - Return data_date field in get_project_summary query - Update contract test to verify data_date presence
79 lines
2.4 KiB
Python
79 lines
2.4 KiB
Python
"""SQLite database schema for XER MCP Server."""
|
|
|
|
SCHEMA_SQL = """
|
|
-- Projects
|
|
CREATE TABLE IF NOT EXISTS projects (
|
|
proj_id TEXT PRIMARY KEY,
|
|
proj_short_name TEXT NOT NULL,
|
|
plan_start_date TEXT,
|
|
plan_end_date TEXT,
|
|
last_recalc_date TEXT,
|
|
loaded_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
);
|
|
|
|
-- Activities
|
|
CREATE TABLE IF NOT EXISTS activities (
|
|
task_id TEXT PRIMARY KEY,
|
|
proj_id TEXT NOT NULL,
|
|
wbs_id TEXT,
|
|
task_code TEXT NOT NULL,
|
|
task_name TEXT NOT NULL,
|
|
task_type TEXT NOT NULL,
|
|
target_start_date TEXT,
|
|
target_end_date TEXT,
|
|
act_start_date TEXT,
|
|
act_end_date TEXT,
|
|
total_float_hr_cnt REAL,
|
|
driving_path_flag INTEGER DEFAULT 0,
|
|
status_code TEXT,
|
|
FOREIGN KEY (proj_id) REFERENCES projects(proj_id)
|
|
);
|
|
|
|
-- Relationships
|
|
CREATE TABLE IF NOT EXISTS relationships (
|
|
task_pred_id TEXT PRIMARY KEY,
|
|
task_id TEXT NOT NULL,
|
|
pred_task_id TEXT NOT NULL,
|
|
pred_type TEXT NOT NULL,
|
|
lag_hr_cnt REAL DEFAULT 0,
|
|
FOREIGN KEY (task_id) REFERENCES activities(task_id),
|
|
FOREIGN KEY (pred_task_id) REFERENCES activities(task_id)
|
|
);
|
|
|
|
-- WBS (Work Breakdown Structure)
|
|
CREATE TABLE IF NOT EXISTS wbs (
|
|
wbs_id TEXT PRIMARY KEY,
|
|
proj_id TEXT NOT NULL,
|
|
parent_wbs_id TEXT,
|
|
wbs_short_name TEXT NOT NULL,
|
|
wbs_name TEXT,
|
|
FOREIGN KEY (proj_id) REFERENCES projects(proj_id),
|
|
FOREIGN KEY (parent_wbs_id) REFERENCES wbs(wbs_id)
|
|
);
|
|
|
|
-- Calendars (internal use only)
|
|
CREATE TABLE IF NOT EXISTS calendars (
|
|
clndr_id TEXT PRIMARY KEY,
|
|
clndr_name TEXT NOT NULL,
|
|
day_hr_cnt REAL,
|
|
week_hr_cnt REAL
|
|
);
|
|
|
|
-- Indexes for performance
|
|
CREATE INDEX IF NOT EXISTS idx_activities_proj ON activities(proj_id);
|
|
CREATE INDEX IF NOT EXISTS idx_activities_wbs ON activities(wbs_id);
|
|
CREATE INDEX IF NOT EXISTS idx_activities_type ON activities(task_type);
|
|
CREATE INDEX IF NOT EXISTS idx_activities_critical ON activities(driving_path_flag)
|
|
WHERE driving_path_flag = 1;
|
|
CREATE INDEX IF NOT EXISTS idx_activities_dates ON activities(target_start_date, target_end_date);
|
|
CREATE INDEX IF NOT EXISTS idx_relationships_task ON relationships(task_id);
|
|
CREATE INDEX IF NOT EXISTS idx_relationships_pred ON relationships(pred_task_id);
|
|
CREATE INDEX IF NOT EXISTS idx_wbs_parent ON wbs(parent_wbs_id);
|
|
CREATE INDEX IF NOT EXISTS idx_wbs_proj ON wbs(proj_id);
|
|
"""
|
|
|
|
|
|
def get_schema() -> str:
|
|
"""Return the complete SQLite schema."""
|
|
return SCHEMA_SQL
|