· 8 years ago · Dec 26, 2017, 07:40 PM
1-- --------------------------------------------------------
2-- Servidor: 127.0.0.1
3-- Versão do servidor: 5.7.20-log - MySQL Community Server (GPL)
4-- OS do Servidor: Win64
5-- HeidiSQL Versão: 9.5.0.5196
6-- --------------------------------------------------------
7
8/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
9/*!40101 SET NAMES utf8 */;
10/*!50503 SET NAMES utf8mb4 */;
11/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
12/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
13
14
15-- Copiando estrutura do banco de dados para controle_os
16CREATE DATABASE IF NOT EXISTS `controle_os` /*!40100 DEFAULT CHARACTER SET utf8 */;
17USE `controle_os`;
18
19-- Copiando estrutura para tabela controle_os.accessories
20CREATE TABLE IF NOT EXISTS `accessories` (
21 `id` int(11) NOT NULL AUTO_INCREMENT,
22 `name` varchar(50) NOT NULL,
23 `type` char(1) NOT NULL DEFAULT '',
24 `active` char(1) NOT NULL DEFAULT '1',
25 `created_at` datetime NOT NULL,
26 `creator_id` int(11) NOT NULL,
27 PRIMARY KEY (`id`),
28 KEY `creator_id` (`creator_id`),
29 CONSTRAINT `accessories_ibfk_1` FOREIGN KEY (`creator_id`) REFERENCES `admins` (`id`)
30) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
31
32-- Exportação de dados foi desmarcado.
33-- Copiando estrutura para tabela controle_os.admins
34CREATE TABLE IF NOT EXISTS `admins` (
35 `id` int(11) NOT NULL AUTO_INCREMENT,
36 `name` varchar(70) NOT NULL,
37 `login` varchar(50) NOT NULL,
38 `password` varchar(60) NOT NULL,
39 `permissions` int(1) NOT NULL,
40 `active` char(1) NOT NULL DEFAULT '1',
41 `created_at` datetime NOT NULL,
42 PRIMARY KEY (`id`)
43) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
44
45-- Exportação de dados foi desmarcado.
46-- Copiando estrutura para tabela controle_os.customers
47CREATE TABLE IF NOT EXISTS `customers` (
48 `id` char(36) NOT NULL,
49 `name` varchar(70) NOT NULL,
50 `login` varchar(50) NOT NULL,
51 `email` varchar(89) DEFAULT '',
52 PRIMARY KEY (`id`)
53) ENGINE=InnoDB DEFAULT CHARSET=utf8;
54
55-- Exportação de dados foi desmarcado.
56-- Copiando estrutura para tabela controle_os.orders
57CREATE TABLE IF NOT EXISTS `orders` (
58 `id` int(11) NOT NULL AUTO_INCREMENT,
59 `cgv_id` int(11) NOT NULL,
60 `type` varchar(15) NOT NULL DEFAULT '',
61 `locale` varchar(100) NOT NULL,
62 `complement` varchar(25) DEFAULT '',
63 `reference_point` varchar(100) DEFAULT '',
64 `priority` char(1) NOT NULL,
65 `done` char(1) NOT NULL DEFAULT '0',
66 `date` datetime NOT NULL,
67 `time` datetime NOT NULL,
68 `denied` char(1) DEFAULT '',
69 `active` char(1) NOT NULL DEFAULT '1',
70 `observation` varchar(500) DEFAULT NULL,
71 `denied_observation` varchar(500) DEFAULT '',
72 `cgv_status` char(1) NOT NULL DEFAULT '',
73 `user_signature` varchar(100) DEFAULT NULL,
74 `customer_signature` varchar(100) DEFAULT NULL,
75 `elapsed_time` int(11) DEFAULT NULL,
76 `tracker_id` char(20) DEFAULT NULL,
77 `tracker_location` varchar(100) DEFAULT NULL,
78 `panic_location` varchar(100) DEFAULT NULL,
79 `vehicle_id` char(36) NOT NULL,
80 `customer_id` char(36) NOT NULL DEFAULT '',
81 `user_id` int(11) NOT NULL,
82 `creator_id` int(11) NOT NULL,
83 `tester_id` int(11) DEFAULT NULL,
84 `created_at` datetime NOT NULL,
85 PRIMARY KEY (`id`),
86 KEY `vehicle_id` (`vehicle_id`),
87 KEY `customer_id` (`customer_id`),
88 KEY `user_id` (`user_id`),
89 KEY `creator_id` (`creator_id`),
90 KEY `tester_id` (`tester_id`),
91 CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`),
92 CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`),
93 CONSTRAINT `orders_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
94 CONSTRAINT `orders_ibfk_4` FOREIGN KEY (`creator_id`) REFERENCES `admins` (`id`),
95 CONSTRAINT `orders_ibfk_5` FOREIGN KEY (`tester_id`) REFERENCES `admins` (`id`)
96) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
97
98-- Exportação de dados foi desmarcado.
99-- Copiando estrutura para tabela controle_os.order_accessories
100CREATE TABLE IF NOT EXISTS `order_accessories` (
101 `id` int(11) NOT NULL AUTO_INCREMENT,
102 `accessorie_id` int(11) NOT NULL,
103 `order_id` int(11) NOT NULL,
104 `installed` char(1) NOT NULL DEFAULT '1',
105 PRIMARY KEY (`id`),
106 KEY `accessorie_id` (`accessorie_id`),
107 KEY `order_id` (`order_id`),
108 CONSTRAINT `order_accessories_ibfk_1` FOREIGN KEY (`accessorie_id`) REFERENCES `accessories` (`id`),
109 CONSTRAINT `order_accessories_ibfk_2` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`)
110) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
111
112-- Exportação de dados foi desmarcado.
113-- Copiando estrutura para tabela controle_os.users
114CREATE TABLE IF NOT EXISTS `users` (
115 `id` int(11) NOT NULL AUTO_INCREMENT,
116 `name` varchar(70) NOT NULL,
117 `email` varchar(89) NOT NULL,
118 `password` varchar(60) NOT NULL,
119 `address` varchar(100) NOT NULL,
120 `cpf` char(11) NOT NULL DEFAULT '',
121 `phone` char(11) NOT NULL DEFAULT '',
122 `rg` char(9) NOT NULL DEFAULT '',
123 `active` char(1) NOT NULL DEFAULT '1',
124 `created_at` datetime NOT NULL,
125 `creator_id` int(11) NOT NULL,
126 PRIMARY KEY (`id`),
127 KEY `creator_id` (`creator_id`),
128 CONSTRAINT `users_ibfk_1` FOREIGN KEY (`creator_id`) REFERENCES `admins` (`id`)
129) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
130
131-- Exportação de dados foi desmarcado.
132-- Copiando estrutura para tabela controle_os.vehicles
133CREATE TABLE IF NOT EXISTS `vehicles` (
134 `id` char(36) NOT NULL,
135 `plate` char(8) NOT NULL,
136 `brand` varchar(50) DEFAULT '',
137 `model` varchar(50) DEFAULT '',
138 `color` varchar(20) DEFAULT '',
139 `year` int(4) DEFAULT NULL,
140 `chassi` char(30) DEFAULT '',
141 `type` varchar(30) DEFAULT '',
142 `customer_id` char(36) NOT NULL,
143 PRIMARY KEY (`id`),
144 KEY `customer_id` (`customer_id`),
145 CONSTRAINT `vehicles_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`)
146) ENGINE=InnoDB DEFAULT CHARSET=utf8;
147
148-- Exportação de dados foi desmarcado.
149/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
150/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
151/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;