mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-01 17:17:24 -04:00
fix: enable foreign key constraints and ensure jobs table prerequisite
- Add PRAGMA foreign_keys = ON at the beginning of create_trading_days_schema() - Create jobs table if it doesn't exist as a prerequisite for the foreign key constraint - Ensures referential integrity is properly enforced for the trading_days table
This commit is contained in:
@@ -13,6 +13,26 @@ def create_trading_days_schema(db: "Database") -> None:
|
||||
Args:
|
||||
db: Database instance to apply migration to
|
||||
"""
|
||||
# Enable foreign key constraint enforcement
|
||||
db.connection.execute("PRAGMA foreign_keys = ON")
|
||||
|
||||
# Create jobs table if it doesn't exist (prerequisite for foreign key)
|
||||
db.connection.execute("""
|
||||
CREATE TABLE IF NOT EXISTS jobs (
|
||||
job_id TEXT PRIMARY KEY,
|
||||
config_path TEXT NOT NULL,
|
||||
status TEXT NOT NULL CHECK(status IN ('pending', 'downloading_data', 'running', 'completed', 'partial', 'failed')),
|
||||
date_range TEXT NOT NULL,
|
||||
models TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
started_at TEXT,
|
||||
updated_at TEXT,
|
||||
completed_at TEXT,
|
||||
total_duration_seconds REAL,
|
||||
error TEXT,
|
||||
warnings TEXT
|
||||
)
|
||||
""")
|
||||
|
||||
# Create trading_days table
|
||||
db.connection.execute("""
|
||||
|
||||
Reference in New Issue
Block a user