-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
223 lines (202 loc) · 5.99 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
-- DROP DATABASE `tecnicas_ataque`;
CREATE DATABASE `tecnicas_ataque`;
USE `tecnicas_ataque`;
CREATE TABLE `roles`
(
`id` INT (100) NOT NULL auto_increment,
`name` VARCHAR (100) NOT NULL,
`permission_products` BIT NOT NULL,
`permission_roles` BIT NOT NULL,
`permission_audit` BIT NOT NULL,
`permission_users` BIT NOT NULL,
PRIMARY KEY (`id`)
)
engine = innodb;
INSERT INTO roles
(`name`,`permission_products`,`permission_roles`,`permission_audit`,`permission_users`)
VALUES ( 'administrador',1, 1, 1, 1);
INSERT INTO roles
(`name`,`permission_products`,`permission_roles`,`permission_audit`,`permission_users`)
VALUES ( 'cliente',1, 1, 0, 0);
CREATE TABLE `users`
(
`id` INT (11) NOT NULL auto_increment,
`name` VARCHAR (100) NOT NULL,
`email` VARCHAR (100) NOT NULL,
`username` VARCHAR (100) NOT NULL,
`pass` VARCHAR (100) NOT NULL,
`role` INT (11) NOT NULL,
`active` BIT,
PRIMARY KEY (`id`)
)
engine = innodb;
INSERT INTO users
(`name`,
`email`,
`username`,
`pass`,
`role`,
`active`)
VALUES ( 'Gabriel Pena',
'gabriel.p16@gmail.com',
'gabo',
Md5('123'),
1,
1 );
INSERT INTO users
(`name`,
`email`,
`username`,
`pass`,
`role`,
`active`)
VALUES ( 'Daniel Perez',
'daniel@gmail.com',
'dani',
Md5('123'),
2s,
1 );
CREATE TABLE `products`
(
`id` INT (11) NOT NULL auto_increment,
`name` VARCHAR (100) NOT NULL,
`qty` INT (5) NOT NULL,
`price` INT (10) NOT NULL,
`expiration_date` VARCHAR (10) NOT NULL,
`expiration_status` VARCHAR (15) NOT NULL,
`users_id` INT (11) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT fk_products_1 FOREIGN KEY (users_id) REFERENCES users (id)
)
engine = innodb;
INSERT INTO products
(`name`,
`qty`,
`price`,
`expiration_date`,
`expiration_status`,
`users_id`)
VALUES ( 'Producto 1',
100,
2000,
'2020-10-20',
'not-expired',
1 );
INSERT INTO products
(`name`,
`qty`,
`price`,
`expiration_date`,
`expiration_status`,
`users_id`)
VALUES ( 'Producto 2',
150,
3000,
'2020-10-20',
'not-expired',
1 );
CREATE TABLE `users_roles`
(
`role_id` INT (11) NOT NULL,
`users_id` INT (11) NOT NULL,
CONSTRAINT fk_users_roles_1 FOREIGN KEY (role_id) REFERENCES roles (id),
CONSTRAINT fk_users_roles_2 FOREIGN KEY (users_id) REFERENCES users (id)
)
engine = innodb;
INSERT INTO users_roles
(`role_id`,
`users_id`)
VALUES ( 1,
1 );
INSERT INTO users_roles
(`role_id`,
`users_id`)
VALUES ( 2,
2 );
CREATE TABLE `audit_process_tracking`
(
`id` INT (11) NOT NULL auto_increment,
`action` VARCHAR (100) NOT NULL,
`date` TIMESTAMP NOT NULL,
`user_id` INT (11) NOT NULL,
`description` VARCHAR (200) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT fk_audit_process_tracking_1 FOREIGN KEY (user_id) REFERENCES
users (id)
)
engine = innodb;
INSERT INTO audit_process_tracking
(`action`,
`date`,
`user_id`,
`description`)
VALUES ( 'Add service',
CURRENT_TIMESTAMP,
1,
'Se agregó Producto: Producto 1' );
INSERT INTO audit_process_tracking
(`action`,
`date`,
`user_id`,
`description`)
VALUES ( 'Add service',
CURRENT_TIMESTAMP,
1,
'Se agregó Producto: Producto 2' );
INSERT INTO audit_process_tracking
(`action`,
`date`,
`user_id`,
`description`)
VALUES ( 'Add role',
CURRENT_TIMESTAMP,
1,
'Se agregó rol: Administrador' );
INSERT INTO audit_process_tracking
(`action`,
`date`,
`user_id`,
`description`)
VALUES ( 'Add role',
CURRENT_TIMESTAMP,
1,
'Se agregó rol: Cliente' );
CREATE TABLE `user_detail`
(
`id` INT (11) NOT NULL auto_increment,
`dni` VARCHAR (100) NOT NULL,
`address` VARCHAR (100) NOT NULL,
`bachelor_degree` VARCHAR (200) NOT NULL,
`social_media` VARCHAR (200) NOT NULL,
`parent_names` VARCHAR (200) NOT NULL,
`user_id` INT (11) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT fk_user_detail_1 FOREIGN KEY (user_id) REFERENCES users (id)
)
engine = innodb;
INSERT INTO user_detail
(`dni`,
`address`,
`bachelor_degree`,
`social_media`,
`parent_names`,
`user_id`)
VALUES ( '123591',
'Cr 16 # 145 - 30',
'Ingenieria de Sistemas',
'@gaboplums - @gabo_tweet',
'Alfonso Peña, Carmenza Rodriguez',
1 );
INSERT INTO user_detail
(`dni`,
`address`,
`bachelor_degree`,
`social_media`,
`parent_names`,
`user_id`)
VALUES ( '134982',
'Calle 134 # 15 - 34',
'Ingenieria de Sistemas',
'@perezoso - @perez_tweet',
'Daniel Perez, Camila Angel',
2 );