-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.js
More file actions
86 lines (77 loc) · 2.22 KB
/
database.js
File metadata and controls
86 lines (77 loc) · 2.22 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const sqlite3 = require('sqlite3').verbose();
const path = require('path');
const dbPath = path.resolve(__dirname, 'taskmaster.db');
const db = new sqlite3.Database(dbPath);
db.serialize(() => {
// Enhanced Tasks table
db.run(`
CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
description TEXT,
status TEXT DEFAULT 'todo',
priority TEXT DEFAULT 'medium',
tags TEXT,
due_date DATE,
completed_at DATETIME,
time_spent INTEGER DEFAULT 0,
category TEXT DEFAULT 'general',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Enhanced Notes table
db.run(`
CREATE TABLE IF NOT EXISTS notes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT,
color TEXT DEFAULT '#ffd700',
is_pinned BOOLEAN DEFAULT 0,
category TEXT DEFAULT 'general',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Activity Log table
db.run(`
CREATE TABLE IF NOT EXISTS activity_log (
id INTEGER PRIMARY KEY AUTOINCREMENT,
action_type TEXT NOT NULL,
item_type TEXT NOT NULL,
item_id INTEGER,
description TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Pomodoro Sessions table
db.run(`
CREATE TABLE IF NOT EXISTS pomodoro_sessions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
task_id INTEGER,
duration INTEGER,
completed BOOLEAN DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (task_id) REFERENCES tasks(id)
)
`);
// Settings table
db.run(`
CREATE TABLE IF NOT EXISTS settings (
key TEXT PRIMARY KEY,
value TEXT,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Insert default settings
db.run(`
INSERT OR IGNORE INTO settings (key, value)
VALUES
('theme', 'dark'),
('sound_enabled', 'true'),
('pomodoro_duration', '25'),
('notifications_enabled', 'true')
`);
console.log('✅ Enhanced Database initialized successfully');
});
module.exports = db;