-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
executable file
·81 lines (64 loc) · 2.93 KB
/
database.sql
File metadata and controls
executable file
·81 lines (64 loc) · 2.93 KB
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
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
CREATE TABLE `chats` (
`chat_id` int NOT NULL,
`sender` int NOT NULL,
`receiver` int NOT NULL,
`last_message` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `media` (
`media_id` int NOT NULL,
`msg_id` int NOT NULL,
`filename` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`original` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `messages` (
`msg_id` int NOT NULL,
`chat_id` int NOT NULL,
`sender` int NOT NULL,
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `profiles` (
`user_id` int NOT NULL,
`google_id` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`username` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`email_verified` int NOT NULL,
`picture` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`chats` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
`notify_sub` json DEFAULT NULL,
`token` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`token_generated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_active` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`creation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ;
ALTER TABLE `chats`
ADD PRIMARY KEY (`chat_id`);
ALTER TABLE `media`
ADD PRIMARY KEY (`media_id`);
ALTER TABLE `messages`
ADD PRIMARY KEY (`msg_id`);
ALTER TABLE `profiles`
ADD PRIMARY KEY (`user_id`);
ALTER TABLE `chats`
MODIFY `chat_id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `media`
MODIFY `media_id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `messages`
MODIFY `msg_id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `profiles`
MODIFY `user_id` int NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;