-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
95 lines (81 loc) · 2.41 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
-- ---
-- Table 'chats'
--
-- ---
CREATE TABLE IF NOT EXISTS `chats` (
`chat_id` BIGINT(30) NOT NULL,
`name` VARCHAR(64) NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
`greet_message` VARCHAR(4000) NULL,
`leave_message` VARCHAR(4000) NULL,
`rules` VARCHAR(4000) NULL,
PRIMARY KEY (`chat_id`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ---
-- Table 'chat_participants'
--
-- ---
CREATE TABLE IF NOT EXISTS `chat_participants`(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`chat_id` BIGINT(30) NOT NULL,
`user_id` BIGINT(30) NOT NULL,
`username` VARCHAR(40),
`first_name` VARCHAR(40),
`last_name` VARCHAR(40),
`msg_count` BIGINT DEFAULT 0,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
PRIMARY KEY (`id`),
FOREIGN KEY(chat_id) REFERENCES chats(chat_id)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ---
-- Table 'admins'
--
-- ---
CREATE TABLE IF NOT EXISTS `admins`(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`login` VARCHAR(64) NOT NULL,
`password` VARCHAR(64) NOT NULL,
`telegram_id` BIGINT(30) NULL,
PRIMARY KEY (`id`),
UNIQUE (login)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `songs` (
`id` BIGINT AUTO_INCREMENT,
`name` TEXT,
`text` TEXT,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `errors` (
`id` BIGINT AUTO_INCREMENT,
`text` TEXT,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ---
-- Table 'chat_participants'
--
-- ---
CREATE TABLE IF NOT EXISTS `quotes`(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`chat_id` BIGINT(30) NOT NULL,
`user_id` BIGINT(30) NOT NULL,
`text` text NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
PRIMARY KEY (`id`),
FOREIGN KEY(chat_id) REFERENCES chats(chat_id)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- ---
-- Table 'nfs'
--
-- ---
CREATE TABLE IF NOT EXISTS `nfs`(
`user_id` BIGINT(30) NOT NULL,
`chat_id` BIGINT(30) NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
`nf_timer` DATETIME NOT NULL,
`fails` INT DEFAULT 0,
PRIMARY KEY (`user_id`),
FOREIGN KEY(chat_id) REFERENCES chats(chat_id)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;