-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
63 lines (57 loc) · 1.63 KB
/
schema.sql
File metadata and controls
63 lines (57 loc) · 1.63 KB
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
-- Medician Tables
CREATE TABLE IF NOT EXISTS items (
id TEXT PRIMARY KEY,
name TEXT,
brand TEXT,
quantity INTEGER,
unit TEXT,
expiry_date TEXT,
dosage TEXT,
indications TEXT,
image_path TEXT,
created_at INTEGER
);
CREATE TABLE IF NOT EXISTS memos (
id TEXT PRIMARY KEY,
content TEXT,
created_at INTEGER,
updated_at INTEGER
);
-- Pastebin Tables
CREATE TABLE IF NOT EXISTS pastes (
id TEXT PRIMARY KEY,
content TEXT,
language TEXT,
created_at INTEGER
);
-- Subscriptions Tables
CREATE TABLE IF NOT EXISTS subscriptions (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
price REAL NOT NULL,
currency TEXT DEFAULT 'CNY',
billing_cycle TEXT NOT NULL, -- 'monthly', 'yearly', 'weekly', 'onetime'
start_date TEXT NOT NULL, -- YYYY-MM-DD
category TEXT, -- 'entertainment', 'utility', 'software', 'insurance', 'other'
description TEXT,
active INTEGER DEFAULT 1, -- 1=active, 0=inactive
created_at INTEGER
);
-- AI Chat Tables
CREATE TABLE IF NOT EXISTS ai_sessions (
id TEXT PRIMARY KEY,
title TEXT,
created_at INTEGER,
updated_at INTEGER
);
CREATE TABLE IF NOT EXISTS ai_messages (
id TEXT PRIMARY KEY,
session_id TEXT NOT NULL,
role TEXT NOT NULL, -- 'user' or 'assistant'
content TEXT NOT NULL,
created_at INTEGER,
FOREIGN KEY (session_id) REFERENCES ai_sessions(id) ON DELETE CASCADE
);
-- Indexes for AI Chat performance optimization
CREATE INDEX IF NOT EXISTS idx_ai_messages_session_id ON ai_messages(session_id);
CREATE INDEX IF NOT EXISTS idx_ai_sessions_updated_at ON ai_sessions(updated_at);