-
Notifications
You must be signed in to change notification settings - Fork 3
/
database.sql
34 lines (30 loc) · 1.3 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
DROP DATABASE IF EXISTS `codoc19`;
CREATE DATABASE `codoc19`;
USE `codoc19`;
CREATE TABLE `users`(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
platform ENUM ('TELEGRAM','FACEBOOK') NOT NULL,
first_name TEXT,
username TEXT,
user_id INT NOT NULL UNIQUE KEY,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE `analytics`(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
feature ENUM('QA','TEST','QUIZ','STATS','STATS_CHART') NOT NULL,
data TEXT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES users(`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `charts`(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
tg_file_id TEXT,
chart_type ENUM ('DEATH','CASE','RECOVERED','DEATH_DAILY','CASE_DAILY','RECOVERED_DAILY') NOT NULL,
country VARCHAR (100) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES users(`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
ALTER TABLE `analytics` CHANGE `data` `data` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;
ALTER TABLE `users` CHANGE `first_name` `first_name` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;