-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sql
More file actions
87 lines (81 loc) · 3.04 KB
/
Copy pathsetup.sql
File metadata and controls
87 lines (81 loc) · 3.04 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
87
-- DigiTracker Database Setup
-- Run against your MySQL database: simple-lamp
-- Usage: mysql -u root -p simple-lamp < setup.sql
USE `simple-lamp`;
-- Users table (keep compatible with existing data)
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`email` varchar(100) DEFAULT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Loans
CREATE TABLE IF NOT EXISTS `loans` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`lender` varchar(100) DEFAULT NULL,
`principal_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
`remaining_amount` decimal(12,2) NOT NULL DEFAULT 0.00,
`monthly_payment` decimal(12,2) NOT NULL DEFAULT 0.00,
`interest_rate` decimal(5,2) DEFAULT 0.00,
`start_date` date DEFAULT NULL,
`due_date` date NOT NULL,
`status` enum('active','paid','overdue') NOT NULL DEFAULT 'active',
`notes` text DEFAULT NULL,
`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Expenses
CREATE TABLE IF NOT EXISTS `expenses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`category` varchar(50) DEFAULT 'general',
`amount` decimal(12,2) NOT NULL DEFAULT 0.00,
`due_date` date NOT NULL,
`is_recurring` tinyint(1) NOT NULL DEFAULT 0,
`recurrence` enum('weekly','monthly','quarterly','yearly') DEFAULT 'monthly',
`status` enum('pending','paid','overdue') NOT NULL DEFAULT 'pending',
`notes` text DEFAULT NULL,
`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Invoices
CREATE TABLE IF NOT EXISTS `invoices` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`invoice_number` varchar(50) DEFAULT NULL,
`vendor_name` varchar(100) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`amount` decimal(12,2) NOT NULL DEFAULT 0.00,
`invoice_date` date DEFAULT NULL,
`due_date` date DEFAULT NULL,
`status` enum('unpaid','paid','overdue') NOT NULL DEFAULT 'unpaid',
`file_path` varchar(255) DEFAULT NULL,
`notes` text DEFAULT NULL,
`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Warranties
CREATE TABLE IF NOT EXISTS `warranties` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`product_name` varchar(100) NOT NULL,
`brand` varchar(100) DEFAULT NULL,
`model_number` varchar(100) DEFAULT NULL,
`purchase_date` date DEFAULT NULL,
`warranty_expiry` date NOT NULL,
`vendor` varchar(100) DEFAULT NULL,
`file_path` varchar(255) DEFAULT NULL,
`notes` text DEFAULT NULL,
`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;