Initialize Twilight project, set up basic framework, initialize DB module

This commit is contained in:
2025-08-07 04:32:34 -03:00
parent 00d61545eb
commit 24d2344f37
29 changed files with 4095 additions and 0 deletions
+152
View File
@@ -0,0 +1,152 @@
CREATE KEYSPACE IF NOT EXISTS payphone
WITH replication = {
'class': 'NetworkTopologyStrategy',
'replication_factor': 3
};
CREATE TABLE IF NOT EXISTS payphone.users (
user_id BIGINT PRIMARY KEY,
name TEXT,
email TEXT,
is_masked BOOLEAN,
is_moderator BOOLEAN,
joined_at TIMESTAMP,
last_seen_at TIMESTAMP,
is_supporter_since TIMESTAMP,
is_supporter_until TIMESTAMP
);
CREATE TABLE IF NOT EXISTS payphone.calls (
call_id BIGINT PRIMARY KEY,
started_at TIMESTAMP,
finished_at TIMESTAMP,
);
CREATE TABLE IF NOT EXISTS payphone.channels (
channel_id BIGINT PRIMARY KEY,
server_id BIGINT,
name TEXT,
is_searching BOOLEAN,
recently_called_channel_ids LIST<BIGINT>
);
CREATE TABLE IF NOT EXISTS payphone.participants (
call_id BIGINT,
user_id BIGINT,
user_name TEXT,
user_avatar_url TEXT,
user_mask TEXT,
PRIMARY KEY (call_id, user_id)
);
-- TTL 30 days.
CREATE TABLE IF NOT EXISTS payphone.messages (
call_id BIGINT,
message_id BIGINT,
author_id BIGINT,
author_name TEXT,
author_avatar_url TEXT,
author_mask ASCII,
content TEXT,
attachments LIST<TEXT>,
sticker BIGINT,
replying_to_id BIGINT,
is_deleted BOOLEAN,
is_edited BOOLEAN,
is_censored BOOLEAN,
PRIMARY KEY (call_id, message_id)
);
CREATE TABLE IF NOT EXISTS payphone.servers (
server_id BIGINT PRIMARY KEY,
name TEXT,
prefix TEXT,
);
CREATE TABLE IF NOT EXISTS payphone.reports (
report_id BIGINT,
message_author_id BIGINT,
message_author_name TEXT,
message_author_avatar_url TEXT,
message_author_mask ASCII,
message_id BIGINT,
message_content TEXT,
message_attachments LIST<TEXT>,
message_sticker BIGINT,
message_replying_to_id BIGINT,
message_replying_to_content TEXT,
message_replying_to_attachments LIST<TEXT>,
message_replying_to_sticker BIGINT,
created_at TIMESTAMP,
reviewed_at TIMESTAMP,
created_by_ids SET<BIGINT>,
reviewed_by_id BIGINT,
resolution ASCII,
PRIMARY KEY (message_author_id, report_id)
);
CREATE TABLE IF NOT EXISTS payphone.user_incidents (
user_id BIGINT,
incident_id BIGINT,
-- ban, warning
type ASCII,
call_id BIGINT,
report_id BIGINT,
message_id BIGINT,
message_content TEXT,
message_attachments LIST<TEXT>,
message_sticker BIGINT,
message_replying_to_id BIGINT,
message_replying_to_content TEXT,
message_replying_to_attachments LIST<TEXT>,
message_replying_to_sticker BIGINT,
reason TEXT,
created_by_id BIGINT,
created_at TIMESTAMP,
expires_at TIMESTAMP,
duration ASCII,
PRIMARY KEY (user_id)
);
CREATE TABLE IF NOT EXISTS payphone.server_incidents (
server_id BIGINT PRIMARY KEY,
incident_id BIGINT,
reason TEXT,
created_by_id BIGINT,
created_at TIMESTAMP,
expires_at TIMESTAMP,
duration ASCII
);