57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
import os
|
|
import sqlite3
|
|
|
|
DB_NAME = "/home/puh/scud_context_api/scud_orion_ai.db"
|
|
|
|
def init_db():
|
|
os.makedirs(os.path.dirname(DB_NAME), exist_ok=True)
|
|
conn = sqlite3.connect(DB_NAME)
|
|
cursor = conn.cursor()
|
|
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS tasks (
|
|
task_id TEXT PRIMARY KEY,
|
|
module TEXT,
|
|
title TEXT,
|
|
status TEXT DEFAULT 'BACKLOG',
|
|
priority TEXT DEFAULT 'HIGH',
|
|
due_date TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
completed_at TIMESTAMP
|
|
);
|
|
""")
|
|
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS chat_sessions (
|
|
session_id TEXT PRIMARY KEY,
|
|
history_json TEXT NOT NULL,
|
|
updated_at TEXT DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
""")
|
|
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS system_prompts (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT UNIQUE NOT NULL,
|
|
prompt_text TEXT NOT NULL,
|
|
is_active INTEGER DEFAULT 1,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
""")
|
|
|
|
# Добавление новой таблицы для сессионных состояний
|
|
cursor.execute("""
|
|
CREATE TABLE IF NOT EXISTS session_states (
|
|
session_id TEXT PRIMARY KEY,
|
|
state_type TEXT NOT NULL,
|
|
pending_data TEXT NOT NULL,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
""")
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
print(f"[✓] Единая база данных SQLite ({DB_NAME}) успешно инициализирована!")
|
|
|
|
if __name__ == "__main__":
|
|
init_db() |