|
9 | 9 | - Launches the correct UI |
10 | 10 | - Handles missing dependencies gracefully |
11 | 11 |
|
| 12 | +NEW (DB-backed): |
| 13 | +- Initializes SQLite |
| 14 | +- Runs JSON → DB migration if needed |
| 15 | +- Injects Repository into Scheduler |
| 16 | +
|
12 | 17 | This file must not contain UI logic or storage logic. |
13 | 18 | """ |
14 | 19 |
|
@@ -49,12 +54,37 @@ def _launch_mode(mode: StartupMode): |
49 | 54 | """ |
50 | 55 | Launch the appropriate UI based on the resolved mode. |
51 | 56 | Lazy imports ensure no heavy UI frameworks load unless needed. |
| 57 | +
|
| 58 | + NEW: |
| 59 | + - DB initialization |
| 60 | + - Migration |
| 61 | + - Repository + Scheduler wiring |
52 | 62 | """ |
53 | 63 |
|
54 | | - # Create scheduler lazily (only if a UI is actually launching) |
| 64 | + # --------------------------------------------------------- |
| 65 | + # NEW: Initialize DB + Repository + Migration |
| 66 | + # --------------------------------------------------------- |
| 67 | + from storage.db import init_db |
| 68 | + from storage.repository import Repository |
| 69 | + from storage.migration import needs_migration, run_migration |
55 | 70 | from logic.scheduler import Scheduler |
56 | | - scheduler = Scheduler() |
57 | | - scheduler.load_tasks() |
| 71 | + |
| 72 | + # 1. Ensure DB + schema exist |
| 73 | + init_db() |
| 74 | + |
| 75 | + # 2. Create repository |
| 76 | + repo = Repository() |
| 77 | + |
| 78 | + # 3. Run migration if needed |
| 79 | + if needs_migration(repo): |
| 80 | + run_migration(repo) |
| 81 | + |
| 82 | + # 4. Create DB-backed scheduler |
| 83 | + scheduler = Scheduler(repo) |
| 84 | + |
| 85 | + # --------------------------------------------------------- |
| 86 | + # OLD UI routing (unchanged) |
| 87 | + # --------------------------------------------------------- |
58 | 88 |
|
59 | 89 | if mode == StartupMode.TK: |
60 | 90 | try: |
|
0 commit comments