-
Notifications
You must be signed in to change notification settings - Fork 5
/
Firefly.sql
162 lines (138 loc) · 6.66 KB
/
Firefly.sql
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
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
# Dump of table accounts
# ------------------------------------------------------------
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) unsigned NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`name` varchar(300) NOT NULL DEFAULT '',
`openingbalance` decimal(10,2) NOT NULL,
`openingbalancedate` date NOT NULL,
`currentbalance` decimal(10,2) NOT NULL,
`hidden` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `fireflyuser_id` (`user_id`),
CONSTRAINT `accounts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table balancemodifiers
# ------------------------------------------------------------
DROP TABLE IF EXISTS `balancemodifiers`;
CREATE TABLE `balancemodifiers` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`account_id` int(10) unsigned NOT NULL,
`date` date NOT NULL,
`balance` decimal(10,2) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `account_id_2` (`account_id`,`date`),
KEY `account_id` (`account_id`),
CONSTRAINT `balancemodifiers_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table component_transaction
# ------------------------------------------------------------
DROP TABLE IF EXISTS `component_transaction`;
CREATE TABLE `component_transaction` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`transaction_id` int(11) unsigned NOT NULL,
`component_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `transaction_id` (`transaction_id`,`component_id`),
KEY `component_id` (`component_id`),
CONSTRAINT `component_transaction_ibfk_1` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `component_transaction_ibfk_2` FOREIGN KEY (`component_id`) REFERENCES `components` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table limits
# ------------------------------------------------------------
DROP TABLE IF EXISTS `limits`;
CREATE TABLE `limits` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`deleted_at` datetime DEFAULT NULL,
`component_id` int(10) unsigned NOT NULL,
`amount` decimal(10,2) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`),
KEY `component_id` (`component_id`),
CONSTRAINT `componentlimits_ibfk_1` FOREIGN KEY (`component_id`) REFERENCES `components` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table transactions
# ------------------------------------------------------------
DROP TABLE IF EXISTS `transactions`;
CREATE TABLE `transactions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) unsigned NOT NULL,
`account_id` int(11) unsigned NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`description` varchar(500) NOT NULL DEFAULT '',
`amount` decimal(10,2) NOT NULL,
`date` date NOT NULL,
`ignore` tinyint(1) unsigned NOT NULL DEFAULT '0',
`mark` tinyint(1) unsigned NOT NULL DEFAULT '0',
`beneficiary_idX` int(10) unsigned DEFAULT NULL,
`budget_idX` int(10) unsigned DEFAULT NULL,
`category_idX` int(10) unsigned DEFAULT NULL,
`assigned` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `fireflyuser_id` (`user_id`),
KEY `account_id` (`account_id`),
KEY `beneficiary_id` (`beneficiary_idX`),
KEY `budget_id` (`budget_idX`),
KEY `category_id` (`category_idX`),
CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `transactions_ibfk_2` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `transactions_ibfk_5` FOREIGN KEY (`category_idX`) REFERENCES `categories` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `transactions_ibfk_6` FOREIGN KEY (`beneficiary_idX`) REFERENCES `beneficiaries` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `transactions_ibfk_7` FOREIGN KEY (`budget_idX`) REFERENCES `budgets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table transfers
# ------------------------------------------------------------
DROP TABLE IF EXISTS `transfers`;
CREATE TABLE `transfers` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`user_id` int(11) unsigned NOT NULL,
`accountfrom_id` int(11) unsigned NOT NULL,
`accountto_id` int(11) unsigned NOT NULL,
`description` varchar(500) NOT NULL,
`amount` decimal(10,2) unsigned NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`),
KEY `account_from` (`accountfrom_id`),
KEY `account_to` (`accountto_id`),
KEY `fireflyuser_id` (`user_id`),
CONSTRAINT `transfers_ibfk_1` FOREIGN KEY (`accountfrom_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `transfers_ibfk_2` FOREIGN KEY (`accountto_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `transfers_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table users
# ------------------------------------------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`deleted_at` datetime DEFAULT NULL,
`email` varchar(150) NOT NULL DEFAULT '',
`password` varchar(60) NOT NULL,
`activation` varchar(64) DEFAULT NULL,
`reset` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;