-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.sql
More file actions
26 lines (23 loc) · 847 Bytes
/
Database.sql
File metadata and controls
26 lines (23 loc) · 847 Bytes
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
CREATE DATABASE IF NOT EXISTS Tracer_Bot;
USE Tracer_Bot;
CREATE TABLE IF NOT EXISTS Users (
Id INT AUTO_INCREMENT PRIMARY KEY,
Telegram_Id BIGINT NOT NULL UNIQUE,
Github_Username VARCHAR(255),
Github_Token TEXT,
Created_At TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_telegram_id (Telegram_Id)
);
CREATE TABLE IF NOT EXISTS User_Repo_Connections (
Id INT AUTO_INCREMENT PRIMARY KEY,
Telegram_Id BIGINT NOT NULL,
Repo_Name VARCHAR(255) NOT NULL,
Chat_Id BIGINT NOT NULL,
Chat_Type ENUM('private', 'group', 'supergroup') NOT NULL,
Topic_Id BIGINT NULL,
Created_At TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY unique_connection (Telegram_Id, Repo_Name, Chat_Id, Topic_Id),
INDEX idx_telegram_id (Telegram_Id),
INDEX idx_repo_name (Repo_Name),
INDEX idx_chat_id (Chat_Id)
);