Skip to content

Commit d60d2ef

Browse files
authored
Merge pull request #1192 from massadm/db_schema_update
Schema migration
2 parents 6f4da17 + 37961c0 commit d60d2ef

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Invite Links
2+
CREATE TABLE IF NOT EXISTS `chat_invite_link` (
3+
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry'
4+
PRIMARY KEY,
5+
`invite_link` VARCHAR(2083) CHARACTER SET 'ascii' COLLATE 'ascii_general_ci' NOT NULL COMMENT 'The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”',
6+
# IE7 has a 2083 character limit for HTTP GET operations: http://support.microsoft.com/kb/208427
7+
`creator_id` BIGINT NOT NULL COMMENT 'Creator of the link',
8+
`is_primary` BOOLEAN NOT NULL COMMENT 'True, if the link is primary',
9+
`is_revoked` BOOLEAN NOT NULL COMMENT 'True, if the link is revoked',
10+
`expire_date` TIMESTAMP NULL COMMENT 'Point in time (Unix TIMESTAMP) when the link will expire or has been expired',
11+
`member_limit` MEDIUMINT UNSIGNED NULL COMMENT 'Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999',
12+
13+
FOREIGN KEY (`creator_id`) REFERENCES `user` (`id`)
14+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
15+
16+
# New update type
17+
CREATE TABLE IF NOT EXISTS `chat_member_updated` (
18+
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry'
19+
PRIMARY KEY,
20+
`chat_id` BIGINT NOT NULL COMMENT 'Chat the user belongs to',
21+
`user_id` BIGINT NOT NULL COMMENT 'Performer of the action, which resulted in the change',
22+
`date` TIMESTAMP NOT NULL COMMENT 'Date the change was done in Unix time',
23+
`old_chat_member` TEXT NOT NULL COMMENT 'Previous information about the chat member',
24+
`new_chat_member` TEXT NOT NULL COMMENT 'New information about the chat member',
25+
`chat_invite_link_id` BIGINT UNSIGNED NULL COMMENT 'Chat invite link, which was used by the user to join the chat; for joining by invite link events only',
26+
27+
FOREIGN KEY (`chat_id`) REFERENCES `chat` (`id`),
28+
FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
29+
FOREIGN KEY (`chat_invite_link_id`) REFERENCES `chat_invite_link` (`id`)
30+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
31+
32+
# Updates about member status changes in chats
33+
ALTER TABLE `telegram_update` ADD COLUMN `my_chat_member_update_id`
34+
BIGINT UNSIGNED NULL COMMENT 'The bot''s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.';
35+
ALTER TABLE `telegram_update` ADD FOREIGN KEY (`my_chat_member_update_id`) REFERENCES `chat_member_updated` (`id`);
36+
ALTER TABLE `telegram_update` ADD COLUMN `chat_member_update_id`
37+
BIGINT UNSIGNED NULL COMMENT 'A chat member''s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates.';
38+
ALTER TABLE `telegram_update` ADD FOREIGN KEY (`chat_member_update_id`) REFERENCES `chat_member_updated` (`id`);
39+
40+
# New service messages
41+
ALTER TABLE `message` ADD COLUMN `message_auto_delete_timer_changed`
42+
TEXT COMMENT 'MessageAutoDeleteTimerChanged object. Message is a service message: auto-delete timer settings changed in the chat' AFTER `channel_chat_created`;
43+
ALTER TABLE `message` ADD COLUMN `voice_chat_started`
44+
TEXT COMMENT 'VoiceChatStarted object. Message is a service message: voice chat started' AFTER `proximity_alert_triggered`;
45+
ALTER TABLE `message` ADD COLUMN `voice_chat_ended`
46+
TEXT COMMENT 'VoiceChatEnded object. Message is a service message: voice chat ended' AFTER `voice_chat_started`;
47+
ALTER TABLE `message` ADD COLUMN `voice_chat_participants_invited`
48+
TEXT COMMENT 'VoiceChatParticipantsInvited object. Message is a service message: new participants invited to a voice chat' AFTER `voice_chat_ended`;

0 commit comments

Comments
 (0)