-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
153 lines (135 loc) · 7.59 KB
/
database.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
-- Adminer 4.2.2 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS `bank_accounts`;
CREATE TABLE `bank_accounts` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`number` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`code` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `bank_accounts` (`id`, `name`, `number`, `code`, `created`) VALUES
(1, 'Air Bank a.s.', '1009567032', '3030', '2016-03-11 17:01:52');
DROP TABLE IF EXISTS `clients`;
CREATE TABLE `clients` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`street` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`city` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`zip` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL,
`ic` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
`dic` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `clients` (`id`, `name`, `street`, `city`, `zip`, `ic`, `dic`, `created`) VALUES
(1, 'Český svaz akrobatického rokenrolu', 'Zátopkova 100/2', 'Praha 6 - Strahov', '160 17', '485 47 239', NULL, '2016-03-11 16:55:58'),
(2, 'Don’t Panic s.r.o.', 'Riegrovy sady 28', 'Praha 2', '120 00', '275 72 099', 'CZ275 72 099', '2016-03-11 16:56:55'),
(3, 'Viktorie servis, s.r.o.', 'Úmyslovice 59', 'Úmyslovice', '290 01', '291 43 551', 'CZ291 43 551', '2016-03-11 16:57:37'),
(4, 'LeMi CZ s.r.o.', 'Hnězdenská 587/18', 'Praha 8', '181 00', '247 83 111', 'CZ247 83 111', '2016-03-11 16:58:44');
DROP TABLE IF EXISTS `contractors`;
CREATE TABLE `contractors` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`street` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`zip` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL,
`ic` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
`dic` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`payer_vat` tinyint(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `contractors` (`id`, `name`, `street`, `city`, `zip`, `ic`, `dic`, `phone`, `email`, `payer_vat`, `created`) VALUES
(1, 'Zdeněk Vítek', 'Kurzova 2221/18', 'Praha 5', '155 00', '738 17 406', NULL, '+420 774 995 414', '[email protected]', 0, '2016-03-11 17:01:20');
DROP TABLE IF EXISTS `invoices`;
CREATE TABLE `invoices` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`token` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`number` varchar(8) COLLATE utf8_unicode_ci NOT NULL,
`issue_date` date DEFAULT NULL,
`date_due` date DEFAULT NULL,
`price` float DEFAULT NULL,
`price_vat` float DEFAULT NULL,
`paid` tinyint(1) NOT NULL DEFAULT '0',
`pricing` tinyint(1) NOT NULL DEFAULT '0',
`sent` tinyint(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL,
`users_id` int(10) unsigned NOT NULL,
`bank_accounts_id` tinyint(3) unsigned DEFAULT NULL,
`clients_id` tinyint(3) unsigned DEFAULT NULL,
`contractors_id` tinyint(3) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `users_id` (`users_id`),
KEY `bank_accounts_id` (`bank_accounts_id`),
KEY `clients_id` (`clients_id`),
KEY `contractors_id` (`contractors_id`),
CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
CONSTRAINT `invoices_ibfk_2` FOREIGN KEY (`bank_accounts_id`) REFERENCES `bank_accounts` (`id`) ON DELETE SET NULL,
CONSTRAINT `invoices_ibfk_3` FOREIGN KEY (`clients_id`) REFERENCES `clients` (`id`) ON DELETE SET NULL,
CONSTRAINT `invoices_ibfk_4` FOREIGN KEY (`contractors_id`) REFERENCES `contractors` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `invoices` (`id`, `token`, `number`, `issue_date`, `date_due`, `price`, `price_vat`, `paid`, `pricing`, `sent`, `created`, `users_id`, `bank_accounts_id`, `clients_id`, `contractors_id`) VALUES
(1, 'am4epb0zjeauveaanz52jao28irq0wzdkkgpfyge', '20160302', '2016-03-11', '2016-03-12', 54000, NULL, 0, 0, 0, '2016-03-11 16:41:21', 1, 1, 1, 1);
DROP TABLE IF EXISTS `invoice_items`;
CREATE TABLE `invoice_items` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`invoices_id` tinyint(3) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`price_per_unit` double DEFAULT NULL,
`units` double DEFAULT NULL,
`total` double DEFAULT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `invoices_id` (`invoices_id`),
CONSTRAINT `invoice_items_ibfk_1` FOREIGN KEY (`invoices_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `invoice_items` (`id`, `invoices_id`, `name`, `description`, `price_per_unit`, `units`, `total`, `created`) VALUES
(5, 1, 'Test', 'Description 2\n\n', 54000, 1, 54000, '2016-03-11 21:46:57');
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`languages_id` smallint(5) unsigned DEFAULT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`surname` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`password` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`password_token` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`password_expiration` datetime DEFAULT NULL,
`token` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`active` datetime DEFAULT NULL,
`created` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `languages_id` (`languages_id`),
CONSTRAINT `users_ibfk_1` FOREIGN KEY (`languages_id`) REFERENCES `languages` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `users` (`id`, `languages_id`, `email`, `name`, `surname`, `password`, `password_token`, `password_expiration`, `token`, `active`, `created`) VALUES
(1, NULL, '[email protected]', 'Zdeněk', 'Vítek', '$2y$10$kszIpACgkD30qh/21EvvdemR.uytq/Q3Anggx5BtoRqRcEcc4wnWO', NULL, NULL, '797e20f4219de5f7c32d08trw696f262d7833224', '2016-01-13 23:33:52', '2016-01-12 23:35:33');
DROP TABLE IF EXISTS `user_has_role`;
CREATE TABLE `user_has_role` (
`users_id` int(10) unsigned NOT NULL,
`user_roles_id` tinyint(3) unsigned NOT NULL,
KEY `users_id` (`users_id`),
KEY `user_roles_id` (`user_roles_id`),
CONSTRAINT `user_has_role_ibfk_1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
CONSTRAINT `user_has_role_ibfk_2` FOREIGN KEY (`user_roles_id`) REFERENCES `user_roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `user_has_role` (`users_id`, `user_roles_id`) VALUES
(1, 1);
DROP TABLE IF EXISTS `user_roles`;
CREATE TABLE `user_roles` (
`id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`key_name` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `user_roles` (`id`, `key_name`, `name`) VALUES
(1, 'admin', 'Admin');
-- 2016-03-16 18:50:20