File size: 17,578 Bytes
4ef118d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
"""
SQLite schema for local storage provider.

This is a pragmatic subset of the Supabase schema adapted for SQLite.
JSON/array fields are stored as TEXT (JSON-encoded).
"""

SCHEMA_STATEMENTS: list[str] = [
    """
    CREATE TABLE IF NOT EXISTS spaces (
      id TEXT PRIMARY KEY,
      emoji TEXT NOT NULL DEFAULT '',
      label TEXT NOT NULL,
      description TEXT,
      is_deep_research INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS agents (
      id TEXT PRIMARY KEY,
      is_default INTEGER NOT NULL DEFAULT 0,
      emoji TEXT NOT NULL DEFAULT '',
      avatar_type TEXT NOT NULL DEFAULT 'emoji',
      avatar_image TEXT,
      avatar_shape TEXT NOT NULL DEFAULT 'circle',
      banner_mode TEXT NOT NULL DEFAULT 'none',
      banner_image TEXT,
      name TEXT NOT NULL,
      description TEXT,
      prompt TEXT,
      is_deep_research INTEGER NOT NULL DEFAULT 0,
      provider TEXT,
      default_model_provider TEXT,
      lite_model_provider TEXT,
      default_model_source TEXT NOT NULL DEFAULT 'list',
      lite_model_source TEXT NOT NULL DEFAULT 'list',
      use_global_model_settings INTEGER NOT NULL DEFAULT 1,
      lite_model TEXT,
      default_model TEXT,
      response_language TEXT,
      base_tone TEXT,
      traits TEXT,
      warmth TEXT,
      enthusiasm TEXT,
      headings TEXT,
      emojis TEXT,
      custom_instruction TEXT,
      temperature REAL,
      top_p REAL,
      frequency_penalty REAL,
      presence_penalty REAL,
      tool_ids TEXT NOT NULL DEFAULT '[]',
      skill_ids TEXT NOT NULL DEFAULT '[]',
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS conversations (
      id TEXT PRIMARY KEY,
      space_id TEXT,
      last_agent_id TEXT,
      agent_selection_mode TEXT NOT NULL DEFAULT 'auto',
      title TEXT NOT NULL DEFAULT 'New Conversation',
      title_emojis TEXT NOT NULL DEFAULT '[]',
      api_provider TEXT NOT NULL DEFAULT 'gemini',
      is_search_enabled INTEGER NOT NULL DEFAULT 0,
      is_thinking_enabled INTEGER NOT NULL DEFAULT 0,
      is_favorited INTEGER NOT NULL DEFAULT 0,
      session_summary TEXT DEFAULT NULL,
      scrapbook_id TEXT,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS conversation_messages (
      id TEXT PRIMARY KEY,
      conversation_id TEXT NOT NULL,
      role TEXT NOT NULL,
      content TEXT NOT NULL,
      provider TEXT,
      model TEXT,
      agent_id TEXT,
      agent_name TEXT,
      agent_emoji TEXT,
      agent_is_default INTEGER NOT NULL DEFAULT 0,
      thinking_process TEXT,
      tool_calls TEXT,
      tool_call_history TEXT NOT NULL DEFAULT '[]',
      research_step_history TEXT NOT NULL DEFAULT '[]',
      related_questions TEXT,
      sources TEXT,
      document_sources TEXT DEFAULT '[]',
      grounding_supports TEXT,
      stream_blocks TEXT NOT NULL DEFAULT '[]',
      stream_schema_version INTEGER NOT NULL DEFAULT 1,
      created_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS conversation_events (
      id TEXT PRIMARY KEY,
      conversation_id TEXT NOT NULL,
      event_type TEXT NOT NULL,
      payload TEXT,
      created_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS attachments (
      id TEXT PRIMARY KEY,
      message_id TEXT NOT NULL,
      type TEXT NOT NULL,
      data TEXT NOT NULL,
      created_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS space_documents (
      id TEXT PRIMARY KEY,
      space_id TEXT NOT NULL,
      name TEXT NOT NULL,
      file_type TEXT NOT NULL,
      content_text TEXT NOT NULL,
      embedding_provider TEXT,
      embedding_model TEXT,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS conversation_documents (
      conversation_id TEXT NOT NULL,
      document_id TEXT NOT NULL,
      created_at TEXT NOT NULL,
      PRIMARY KEY (conversation_id, document_id)
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS document_sections (
      id TEXT PRIMARY KEY,
      document_id TEXT NOT NULL,
      external_section_id INTEGER NOT NULL,
      title_path TEXT NOT NULL DEFAULT '[]',
      level INTEGER DEFAULT 0,
      loc TEXT,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS document_chunks (
      id TEXT PRIMARY KEY,
      document_id TEXT NOT NULL,
      section_id TEXT,
      title_path TEXT NOT NULL DEFAULT '[]',
      external_chunk_id TEXT,
      chunk_index INTEGER,
      content_type TEXT,
      text TEXT NOT NULL,
      token_count INTEGER,
      chunk_hash TEXT,
      loc TEXT,
      source_hint TEXT,
      embedding TEXT NOT NULL DEFAULT '[]',
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE UNIQUE INDEX IF NOT EXISTS idx_document_chunks_document_hash
      ON document_chunks(document_id, chunk_hash);
    """,
    """
    CREATE TABLE IF NOT EXISTS space_agents (
      space_id TEXT NOT NULL,
      agent_id TEXT NOT NULL,
      sort_order INTEGER NOT NULL DEFAULT 0,
      is_primary INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL,
      PRIMARY KEY (space_id, agent_id)
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS scrapbook (
      id TEXT PRIMARY KEY,
      title TEXT NOT NULL DEFAULT '',
      emoji TEXT,
      summary TEXT NOT NULL DEFAULT '',
      content TEXT NOT NULL DEFAULT '',
      source_url TEXT,
      platform TEXT NOT NULL DEFAULT 'manual',
      thumbnail TEXT,
      tags TEXT NOT NULL DEFAULT '[]',
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_scrapbook_created_at
      ON scrapbook(created_at DESC);
    """,
    """
    CREATE TABLE IF NOT EXISTS home_notes (
      id TEXT PRIMARY KEY,
      content TEXT NOT NULL DEFAULT '',
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS home_shortcuts (
      id TEXT PRIMARY KEY,
      title TEXT NOT NULL,
      url TEXT NOT NULL,
      icon_type TEXT NOT NULL DEFAULT 'lucide',
      icon_name TEXT,
      icon_url TEXT,
      position INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS user_settings (
      key TEXT PRIMARY KEY,
      value TEXT,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS memory_domains (
      id TEXT PRIMARY KEY,
      user_id TEXT,
      domain_key TEXT NOT NULL,
      aliases TEXT NOT NULL DEFAULT '[]',
      scope TEXT,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE UNIQUE INDEX IF NOT EXISTS idx_memory_domains_user_key
      ON memory_domains(user_id, domain_key);
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_memory_domains_updated_at
      ON memory_domains(updated_at DESC);
    """,
    """
    CREATE TABLE IF NOT EXISTS memory_summaries (
      id TEXT PRIMARY KEY,
      domain_id TEXT NOT NULL,
      summary TEXT NOT NULL,
      evidence TEXT,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE UNIQUE INDEX IF NOT EXISTS idx_memory_summaries_domain_id_unique
      ON memory_summaries(domain_id);
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_memory_summaries_updated_at
      ON memory_summaries(updated_at DESC);
    """,
    """
    CREATE TABLE IF NOT EXISTS user_tools (
      id TEXT PRIMARY KEY,
      user_id TEXT NOT NULL,
      name TEXT NOT NULL,
      description TEXT,
      type TEXT NOT NULL DEFAULT 'http',
      config TEXT,
      input_schema TEXT,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE TABLE IF NOT EXISTS pending_form_runs (
      id TEXT PRIMARY KEY,
      run_id TEXT NOT NULL UNIQUE,
      conversation_id TEXT,
      requirements_data TEXT NOT NULL DEFAULT '[]',
      user_id TEXT,
      agent_model TEXT,
      status TEXT NOT NULL DEFAULT 'pending',
      submitted_at TEXT,
      expires_at TEXT NOT NULL,
      messages TEXT,
      created_at TEXT NOT NULL
    );
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_pending_form_runs_run_id
      ON pending_form_runs(run_id);
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_pending_form_runs_expires_at
      ON pending_form_runs(expires_at);
    """,
    """
    INSERT OR IGNORE INTO spaces (
      id, emoji, label, description, is_deep_research, created_at, updated_at
    ) VALUES
      ('space-life', '🏠', 'Life', 'Daily planning and practical help.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-dev', 'πŸ’»', 'Code Development', 'Software development and debugging.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-travel', '✈️', 'Travel', 'Trip planning and destination info.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-entertainment', '🎬', 'Movies & Music', 'Recommendations for films and music.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-study', 'πŸ“š', 'Learning', 'Study plans and knowledge growth.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-health', 'πŸ’ͺ', 'Health', 'Exercise, sleep, and nutrition guidance.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-finance', 'πŸ’°', 'Finance', 'Budgeting, saving, and risk awareness.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-writing', '✍️', 'Writing', 'Drafting, rewriting, and polish.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
      ('space-career', 'πŸš€', 'Career', 'Resume, interview, and job strategy.', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
    """,
    """
    INSERT OR IGNORE INTO agents (
      id, is_default, emoji, name, description, prompt, is_deep_research,
      base_tone, traits, warmth, enthusiasm, headings, emojis, tool_ids, skill_ids,
      created_at, updated_at
    ) VALUES
      (
        'agent-life-assistant', 0, '🏠', 'Life Assistant',
        'Helps with routines, tasks, and daily decisions.',
        'You are a practical life assistant. Give actionable steps, ask for constraints, and keep responses concise and useful.',
        0, 'friendly', 'practical', 'gentle', 'medium', 'structured', 'light',
        '["local_time","web_search","calculator","interactive_form"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-code-assistant', 0, 'πŸ’»', 'Code Assistant',
        'Engineering-focused coding and debugging assistant.',
        'You are a senior coding assistant. Clarify requirements, provide correct runnable solutions, and include testing advice.',
        0, 'technical', 'concise', 'direct', 'low', 'structured', 'none',
        '["web_search","json_repair","extract_text","summarize_text"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-travel-planner', 0, '✈️', 'Travel Planner',
        'Plans routes, schedules, and budgets for trips.',
        'You are a travel planner. Confirm origin, budget, duration, and preferences, then return a clear itinerary with options.',
        0, 'professional', 'detailed', 'supportive', 'medium', 'structured', 'light',
        '["web_search","search_news","search_wikipedia","local_time","interactive_form"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-movie-music-curator', 0, '🎬', 'Movie & Music Curator',
        'Curates movie and music recommendations by taste.',
        'You are a recommendation curator. Identify user taste and provide tiered suggestions with short reasons.',
        0, 'creative', 'detailed', 'friendly', 'medium', 'structured', 'expressive',
        '["web_search","search_news","search_wikipedia","duckduckgo_image_search","duckduckgo_video_search"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-study-coach', 0, 'πŸ“š', 'Study Coach',
        'Builds learning plans and review strategies.',
        'You are a study coach. Create phased plans, daily tasks, and review loops based on goals and available time.',
        0, 'professional', 'structured', 'supportive', 'medium', 'structured', 'light',
        '["interactive_form","summarize_text","extract_text","web_search"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-health-wellness', 0, 'πŸ’ͺ', 'Health Coach',
        'Supports healthy habits and lifestyle routines.',
        'You are a health coach. Focus on habit-level advice for sleep, exercise, and nutrition. Avoid diagnosis and suggest professional care when needed.',
        0, 'calm', 'practical', 'gentle', 'low', 'structured', 'none',
        '["interactive_form","local_time","calculator","web_search"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-finance-planner', 0, 'πŸ’°', 'Finance Planner',
        'Helps with budget, savings, and spending decisions.',
        'You are a finance planner. Ask for cashflow context and provide conservative, practical allocation suggestions.',
        0, 'professional', 'analytical', 'neutral', 'low', 'structured', 'none',
        '["interactive_form","calculator","summarize_text","search_news"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-writing-assistant', 0, '✍️', 'Writing Assistant',
        'Improves drafts, structure, and tone.',
        'You are a writing assistant. Clarify audience and style, then provide strong structure and polished alternatives.',
        0, 'friendly', 'detailed', 'gentle', 'medium', 'structured', 'light',
        '["interactive_form","summarize_text","extract_text","json_repair"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      ),
      (
        'agent-career-coach', 0, 'πŸš€', 'Career Coach',
        'Supports resume quality and interview preparation.',
        'You are a career coach. Provide concrete resume edits, interview prep questions, and role-fit guidance.',
        0, 'professional', 'direct', 'supportive', 'medium', 'structured', 'light',
        '["interactive_form","web_search","summarize_text","extract_text"]', '[]',
        CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
      );
    """,
    """
    INSERT OR IGNORE INTO space_agents (
      space_id, agent_id, sort_order, is_primary, created_at
    ) VALUES
      ('space-life', 'agent-life-assistant', 0, 1, CURRENT_TIMESTAMP),
      ('space-dev', 'agent-code-assistant', 0, 1, CURRENT_TIMESTAMP),
      ('space-travel', 'agent-travel-planner', 0, 1, CURRENT_TIMESTAMP),
      ('space-entertainment', 'agent-movie-music-curator', 0, 1, CURRENT_TIMESTAMP),
      ('space-study', 'agent-study-coach', 0, 1, CURRENT_TIMESTAMP),
      ('space-health', 'agent-health-wellness', 0, 1, CURRENT_TIMESTAMP),
      ('space-finance', 'agent-finance-planner', 0, 1, CURRENT_TIMESTAMP),
      ('space-writing', 'agent-writing-assistant', 0, 1, CURRENT_TIMESTAMP),
      ('space-career', 'agent-career-coach', 0, 1, CURRENT_TIMESTAMP);
    """,
    """
    UPDATE spaces
    SET emoji = CASE emoji
      WHEN 'HOME' THEN '🏠'
      WHEN 'DEV' THEN 'πŸ’»'
      WHEN 'TRIP' THEN '✈️'
      WHEN 'MEDIA' THEN '🎬'
      WHEN 'STUDY' THEN 'πŸ“š'
      WHEN 'HEALTH' THEN 'πŸ’ͺ'
      WHEN 'MONEY' THEN 'πŸ’°'
      WHEN 'WRITE' THEN '✍️'
      WHEN 'CAREER' THEN 'πŸš€'
      ELSE emoji
    END
    WHERE emoji IN ('HOME', 'DEV', 'TRIP', 'MEDIA', 'STUDY', 'HEALTH', 'MONEY', 'WRITE', 'CAREER');
    """,
    """
    UPDATE agents
    SET emoji = CASE emoji
      WHEN 'HOME' THEN '🏠'
      WHEN 'DEV' THEN 'πŸ’»'
      WHEN 'TRIP' THEN '✈️'
      WHEN 'MEDIA' THEN '🎬'
      WHEN 'STUDY' THEN 'πŸ“š'
      WHEN 'HEALTH' THEN 'πŸ’ͺ'
      WHEN 'MONEY' THEN 'πŸ’°'
      WHEN 'WRITE' THEN '✍️'
      WHEN 'CAREER' THEN 'πŸš€'
      ELSE emoji
    END
    WHERE emoji IN ('HOME', 'DEV', 'TRIP', 'MEDIA', 'STUDY', 'HEALTH', 'MONEY', 'WRITE', 'CAREER');
    """,
    # Email notification tables (supports Gmail, Outlook, QQ, 163 via IMAP)
    """
    CREATE TABLE IF NOT EXISTS email_provider_configs (
      id TEXT PRIMARY KEY,
      provider TEXT NOT NULL DEFAULT 'gmail',
      email TEXT NOT NULL,
      imap_password TEXT,
      is_enabled INTEGER NOT NULL DEFAULT 1,
      poll_interval_minutes INTEGER NOT NULL DEFAULT 15,
      summary_provider TEXT,
      summary_model TEXT,
      created_at TEXT NOT NULL,
      updated_at TEXT NOT NULL
    );
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_email_provider_configs_email
      ON email_provider_configs(email);
    """,
    """
    CREATE TABLE IF NOT EXISTS email_notifications (
      id TEXT PRIMARY KEY,
      config_id TEXT,
      provider TEXT NOT NULL DEFAULT 'gmail',
      message_id TEXT NOT NULL UNIQUE,
      subject TEXT,
      sender TEXT,
      received_at TEXT,
      summary TEXT,
      is_read INTEGER NOT NULL DEFAULT 0,
      created_at TEXT NOT NULL
    );
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_email_notifications_is_read
      ON email_notifications(is_read);
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_email_notifications_created_at
      ON email_notifications(created_at DESC);
    """,
    """
    CREATE INDEX IF NOT EXISTS idx_email_notifications_config_id
      ON email_notifications(config_id);
    """,
]