federationlib/database/peers_telegram_chat.sql
2023-06-23 03:53:47 -04:00

26 lines
No EOL
2.3 KiB
SQL

create table peers_telegram_chat
(
federated_address varchar(255) not null comment 'The primary standard federated address to which this record is associated to what peer'
primary key,
id bigint not null comment ' Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.',
type tinytext not null comment 'Type of chat, can be either “private”, “group”, “supergroup” or “channel”',
title varchar(255) null comment 'Optional. Title, for supergroups, channels and group chats',
username varchar(255) null comment 'Optional. Username, for private chats, supergroups and channels if available',
first_name varchar(255) null comment 'Optional. First name of the other party in a private chat',
last_name varchar(255) null comment 'Optional. Last name of the other party in a private chat',
is_forum tinyint(1) default 0 null comment 'Optional. True, if the supergroup chat is a forum (has topics enabled)',
updated_timestamp bigint default unix_timestamp() not null comment 'The Unix Timestamp for when this record was last updated',
updated_client varchar(36) not null comment 'The Client UUID that last updated the peer''s metadata',
constraint peers_telegram_chat_federated_address_uindex
unique (federated_address),
constraint peers_telegram_chat_id_uindex
unique (id),
constraint peers_telegram_chat_clients_uuid_fk
foreign key (updated_client) references clients (uuid),
constraint peers_telegram_chat_peers_federated_address_fk
foreign key (federated_address) references peers (federated_address)
)
comment 'Table for housing metadata information for Telegram Chats';
create index peers_telegram_chat_username_index
on peers_telegram_chat (username);