· 6 years ago · May 24, 2019, 09:58 AM
1-- Структура на таблицата accounts
2CREATE TABLE IF NOT EXISTS `accounts` (
3 `id` int(11) NOT NULL AUTO_INCREMENT,
4 `plan_id` int(11) DEFAULT NULL,
5 `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
6 `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
7 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
8 `is_active` tinyint(1) NOT NULL,
9 `is_main` tinyint(1) NOT NULL,
10 `date_register` datetime NOT NULL,
11 PRIMARY KEY (`id`),
12 KEY `IDX_CAC89EACE899029B` (`plan_id`),
13 CONSTRAINT `FK_CAC89EACE899029B` FOREIGN KEY (`plan_id`) REFERENCES `plans` (`id`)
14) ENGINE=InnoDB AUTO_INCREMENT=76 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
15
16-- Структура на таблицата cities
17CREATE TABLE IF NOT EXISTS `cities` (
18 `id` int(11) NOT NULL AUTO_INCREMENT,
19 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
20 `seo_link` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
21 PRIMARY KEY (`id`)
22) ENGINE=InnoDB AUTO_INCREMENT=297 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
23
24-- Структура на таблицата clients
25CREATE TABLE IF NOT EXISTS `clients` (
26 `id` int(11) NOT NULL AUTO_INCREMENT,
27 `company_id` int(11) NOT NULL,
28 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
29 `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
30 `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
31 `date_added` datetime NOT NULL,
32 `city_id` int(11) DEFAULT NULL,
33 `note` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
34 `address` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
35 `send_notifications` tinyint(1) NOT NULL,
36 PRIMARY KEY (`id`),
37 KEY `IDX_C82E74979B1AD6` (`company_id`),
38 KEY `IDX_C82E748BAC62AF` (`city_id`),
39 CONSTRAINT `FK_C82E748BAC62AF` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`),
40 CONSTRAINT `FK_C82E74979B1AD6` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`)
41) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
42
43-- Структура на таблицата companies
44CREATE TABLE IF NOT EXISTS `companies` (
45 `id` int(11) NOT NULL AUTO_INCREMENT,
46 `city_id` int(11) NOT NULL,
47 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
48 `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
49 `description` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
50 `address` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
51 `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
52 `date_added` datetime NOT NULL,
53 `working_time` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
54 PRIMARY KEY (`id`),
55 KEY `IDX_8244AA3A8BAC62AF` (`city_id`),
56 CONSTRAINT `FK_8244AA3A8BAC62AF` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`)
57) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
58
59-- Структура на таблицата company_accounts
60CREATE TABLE IF NOT EXISTS `company_accounts` (
61 `id` int(11) NOT NULL AUTO_INCREMENT,
62 `account_id` int(11) NOT NULL,
63 `company_id` int(11) NOT NULL,
64 `staff_access` tinyint(1) NOT NULL,
65 `staff_manage` tinyint(1) NOT NULL,
66 `service_access` tinyint(1) NOT NULL,
67 `service_manage` tinyint(1) NOT NULL,
68 `client_access` tinyint(1) NOT NULL,
69 `client_manage` tinyint(1) NOT NULL,
70 `main_access` tinyint(1) NOT NULL,
71 `possition` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
72 `working_time` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
73 `event_access` tinyint(1) NOT NULL,
74 PRIMARY KEY (`id`),
75 KEY `IDX_D25F8BC19B6B5FBA` (`account_id`),
76 KEY `IDX_D25F8BC1979B1AD6` (`company_id`),
77 CONSTRAINT `FK_D25F8BC1979B1AD6` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`),
78 CONSTRAINT `FK_D25F8BC19B6B5FBA` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
79) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
80
81-- Структура на таблицата events
82CREATE TABLE IF NOT EXISTS `events` (
83 `id` int(11) NOT NULL AUTO_INCREMENT,
84 `company_id` int(11) NOT NULL,
85 `provider_id` int(11) NOT NULL,
86 `service_id` int(11) NOT NULL,
87 `created_by_id` int(11) NOT NULL,
88 `client_id` int(11) NOT NULL,
89 `start` datetime NOT NULL,
90 `end` datetime NOT NULL,
91 `description` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
92 `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
93 `date_created` datetime NOT NULL,
94 `status` int(11) NOT NULL,
95 PRIMARY KEY (`id`),
96 KEY `IDX_5387574A979B1AD6` (`company_id`),
97 KEY `IDX_5387574AA53A8AA` (`provider_id`),
98 KEY `IDX_5387574AED5CA9E6` (`service_id`),
99 KEY `IDX_5387574AB03A8386` (`created_by_id`),
100 KEY `IDX_5387574A19EB6921` (`client_id`),
101 CONSTRAINT `FK_5387574A19EB6921` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`),
102 CONSTRAINT `FK_5387574A979B1AD6` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`),
103 CONSTRAINT `FK_5387574AA53A8AA` FOREIGN KEY (`provider_id`) REFERENCES `accounts` (`id`),
104 CONSTRAINT `FK_5387574AB03A8386` FOREIGN KEY (`created_by_id`) REFERENCES `accounts` (`id`),
105 CONSTRAINT `FK_5387574AED5CA9E6` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`)
106) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
107
108-- Структура на таблицата messages
109CREATE TABLE IF NOT EXISTS `messages` (
110 `id` int(11) NOT NULL AUTO_INCREMENT,
111 `receiver_id` int(11) NOT NULL,
112 `sender_id` int(11) NOT NULL,
113 `subject` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
114 `message` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
115 `is_reply` int(11) NOT NULL,
116 `is_read` int(11) NOT NULL,
117 `sender_delete` int(11) NOT NULL,
118 `receiver_delete` int(11) NOT NULL,
119 `date_send` datetime NOT NULL,
120 PRIMARY KEY (`id`),
121 KEY `IDX_DB021E96CD53EDB6` (`receiver_id`),
122 KEY `IDX_DB021E96F624B39D` (`sender_id`),
123 CONSTRAINT `FK_DB021E96CD53EDB6` FOREIGN KEY (`receiver_id`) REFERENCES `accounts` (`id`),
124 CONSTRAINT `FK_DB021E96F624B39D` FOREIGN KEY (`sender_id`) REFERENCES `accounts` (`id`)
125) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
126
127-- Структура на таблицата notes
128CREATE TABLE IF NOT EXISTS `notes` (
129 `id` int(11) NOT NULL AUTO_INCREMENT,
130 `account_id` int(11) NOT NULL,
131 `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
132 `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
133 `date_added` datetime NOT NULL,
134 PRIMARY KEY (`id`),
135 KEY `IDX_11BA68C9B6B5FBA` (`account_id`),
136 CONSTRAINT `FK_11BA68C9B6B5FBA` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
137) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
138
139-- Структура на таблицата plans
140CREATE TABLE IF NOT EXISTS `plans` (
141 `id` int(11) NOT NULL AUTO_INCREMENT,
142 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
143 `companies_limit` int(11) NOT NULL,
144 `staffs_limit` int(11) NOT NULL,
145 `price` double NOT NULL,
146 PRIMARY KEY (`id`)
147) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
148
149-- Структура на таблицата requests
150CREATE TABLE IF NOT EXISTS `requests` (
151 `id` int(11) NOT NULL AUTO_INCREMENT,
152 `account_id` int(11) NOT NULL,
153 `request_from_id` int(11) NOT NULL,
154 `request_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
155 `type` int(11) NOT NULL,
156 `date_created` datetime NOT NULL,
157 `date_expired` datetime NOT NULL,
158 PRIMARY KEY (`id`),
159 KEY `IDX_7B85D6519B6B5FBA` (`account_id`),
160 KEY `IDX_7B85D65152EAAB5C` (`request_from_id`),
161 CONSTRAINT `FK_7B85D65152EAAB5C` FOREIGN KEY (`request_from_id`) REFERENCES `accounts` (`id`),
162 CONSTRAINT `FK_7B85D6519B6B5FBA` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`)
163) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
164
165-- Структура на таблицата services
166CREATE TABLE IF NOT EXISTS `services` (
167 `id` int(11) NOT NULL AUTO_INCREMENT,
168 `company_id` int(11) NOT NULL,
169 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
170 `description` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
171 `cost` double NOT NULL,
172 `time` int(11) NOT NULL,
173 `is_private` tinyint(1) NOT NULL,
174 PRIMARY KEY (`id`),
175 KEY `IDX_7332E169979B1AD6` (`company_id`),
176 CONSTRAINT `FK_7332E169979B1AD6` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`)
177) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
178
179-- Структура на таблицата service_providers
180CREATE TABLE IF NOT EXISTS `service_providers` (
181 `id` int(11) NOT NULL AUTO_INCREMENT,
182 `account_id` int(11) NOT NULL,
183 `service_id` int(11) NOT NULL,
184 PRIMARY KEY (`id`),
185 KEY `IDX_BAB4EE5D9B6B5FBA` (`account_id`),
186 KEY `IDX_BAB4EE5DED5CA9E6` (`service_id`),
187 CONSTRAINT `FK_BAB4EE5D9B6B5FBA` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`),
188 CONSTRAINT `FK_BAB4EE5DED5CA9E6` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`)
189) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;