-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
faker.sql
89 lines (79 loc) · 1.78 KB
/
faker.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
DROP TABLE IF EXISTS `tests`;
CREATE TABLE `tests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`value` int(5) NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
INSERT INTO tests(value)
VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE admins;
TRUNCATE posts;
TRUNCATE comments;
TRUNCATE categories;
TRUNCATE tags;
TRUNCATE tag_post;
SET FOREIGN_KEY_CHECKS=1;
INSERT INTO admins(name, email, password)
SELECT
CONCAT(@rownum := @rownum + 1, 'admin'),
CONCAT(@rownum := @rownum, 'admin@example.com'),
'$2a$10$2XMiLL9FXbmmre7IUOl4R.YQgKY0NnP/L5GhQ8ZRpEmfB4ovL.aP6' /* password */
FROM
/* create 1000 rows */
tests AS t1,
tests AS t2,
tests AS t3,
(SELECT @rownum := 0) AS v;
INSERT INTO categories(name)
SELECT
CONCAT(@rownum := @rownum + 1, 'category')
FROM
/* create 1000 rows */
tests AS t1,
tests AS t2,
tests AS t3,
(SELECT @rownum := 0) AS v;
INSERT INTO posts(admin_id, category_id, title, md_body, html_body)
SELECT
(@rownum := @rownum + 1),
@rownum,
CONCAT(@rownum, 'title'),
CONCAT(@rownum, 'md_body'),
CONCAT(@rownum, 'html_body')
FROM
/* create 1000 rows */
tests AS t1,
tests AS t2,
tests AS t3,
(SELECT @rownum := 0) AS v;
INSERT INTO comments(post_id, body)
SELECT
(@rownum := @rownum + 1),
CONCAT(@rownum, 'body')
FROM
/* create 1000 rows */
tests AS t1,
tests AS t2,
tests AS t3,
(SELECT @rownum := 0) AS v;
INSERT INTO tags(name)
SELECT
CONCAT(@rownum := @rownum + 1, 'tag')
FROM
/* create 1000 rows */
tests AS t1,
tests AS t2,
tests AS t3,
(SELECT @rownum := 0) AS v;
INSERT INTO tag_post(tag_id, post_id)
SELECT
(@rownum := @rownum + 1),
@rownum
FROM
/* create 1000 rows */
tests AS t1,
tests AS t2,
tests AS t3,
(SELECT @rownum := 0) AS v;
DROP TABLE IF EXISTS tests;