feat: migrate core data stores to MySQL with compatibility fixes

This commit is contained in:
2026-02-28 19:35:51 +08:00
parent dc04db6538
commit 650b46ed99
9 changed files with 660 additions and 16 deletions

View File

@@ -88,9 +88,14 @@ class TaskManager:
result TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
''')
cursor.execute('CREATE INDEX IF NOT EXISTS idx_status ON tasks(status)')
cursor.execute('CREATE INDEX IF NOT EXISTS idx_customer ON tasks(customer_id)')
cursor.execute('CREATE INDEX IF NOT EXISTS idx_created ON tasks(created_at)')
cursor.execute("SHOW INDEX FROM tasks")
exists = {str(r.get("Key_name", "")) for r in cursor.fetchall()}
if "idx_status" not in exists:
cursor.execute('CREATE INDEX idx_status ON tasks(status)')
if "idx_customer" not in exists:
cursor.execute('CREATE INDEX idx_customer ON tasks(customer_id)')
if "idx_created" not in exists:
cursor.execute('CREATE INDEX idx_created ON tasks(created_at)')
conn.commit()
conn.close()
else: