CREATE TABLE `message` (
`chat_id` BIGINT(20) NOT NULL COMMENT 'Unique chat identifier',
`sender_chat_id` BIGINT(20) NULL DEFAULT NULL COMMENT 'Sender of the message, sent on behalf of a chat',
`id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'Unique message identifier',
`message_thread_id` BIGINT(20) NULL DEFAULT NULL COMMENT 'Unique identifier of a message thread to which the message belongs; for supergroups only',
`user_id` BIGINT(20) NULL DEFAULT NULL COMMENT 'Unique user identifier',
`date` TIMESTAMP NULL DEFAULT NULL COMMENT 'Date the message was sent in timestamp format',
`forward_from` BIGINT(20) NULL DEFAULT NULL COMMENT 'Unique user identifier, sender of the original message',
`forward_from_chat` BIGINT(20) NULL DEFAULT NULL COMMENT 'Unique chat identifier, chat the original message belongs to',
`forward_from_message_id` BIGINT(20) NULL DEFAULT NULL COMMENT 'Unique chat identifier of the original message in the channel',
`forward_signature` TEXT NULL DEFAULT NULL COMMENT 'For messages forwarded from channels, signature of the post author if present' COLLATE 'utf8mb4_unicode_520_ci',
`forward_sender_name` TEXT NULL DEFAULT NULL COMMENT 'Sender\'s name for messages forwarded from users who disallow adding a link to their account in forwarded messages' COLLATE 'utf8mb4_unicode_520_ci',
`forward_date` TIMESTAMP NULL DEFAULT NULL COMMENT 'date the original message was sent in timestamp format',
`is_topic_message` TINYINT(1) NULL DEFAULT '0' COMMENT 'True, if the message is sent to a forum topic',
`is_automatic_forward` TINYINT(1) NULL DEFAULT '0' COMMENT 'True, if the message is a channel post that was automatically forwarded to the connected discussion group',
`reply_to_chat` BIGINT(20) NULL DEFAULT NULL COMMENT 'Unique chat identifier',
`reply_to_message` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Message that this message is reply to',
`via_bot` BIGINT(20) NULL DEFAULT NULL COMMENT 'Optional. Bot through which the message was sent',
`edit_date` TIMESTAMP NULL DEFAULT NULL COMMENT 'Date the message was last edited in Unix time',
`has_protected_content` TINYINT(1) NULL DEFAULT '0' COMMENT 'True, if the message can\'t be forwarded',
`media_group_id` TEXT NULL DEFAULT NULL COMMENT 'The unique identifier of a media message group this message belongs to' COLLATE 'utf8mb4_unicode_520_ci',
`author_signature` TEXT NULL DEFAULT NULL COMMENT 'Signature of the post author for messages in channels' COLLATE 'utf8mb4_unicode_520_ci',
`text` TEXT NULL DEFAULT NULL COMMENT 'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8mb4' COLLATE 'utf8mb4_unicode_520_ci',
`entities` TEXT NULL DEFAULT NULL COMMENT 'For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text' COLLATE 'utf8mb4_unicode_520_ci',
`caption_entities` TEXT NULL DEFAULT NULL COMMENT 'For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption' COLLATE 'utf8mb4_unicode_520_ci',
`audio` TEXT NULL DEFAULT NULL COMMENT 'Audio object. Message is an audio file, information about the file' COLLATE 'utf8mb4_unicode_520_ci',
`document` TEXT NULL DEFAULT NULL COMMENT 'Document object. Message is a general file, information about the file' COLLATE 'utf8mb4_unicode_520_ci',
`animation` TEXT NULL DEFAULT NULL COMMENT 'Message is an animation, information about the animation' COLLATE 'utf8mb4_unicode_520_ci',
`game` TEXT NULL DEFAULT NULL COMMENT 'Game object. Message is a game, information about the game' COLLATE 'utf8mb4_unicode_520_ci',
`photo` TEXT NULL DEFAULT NULL COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo' COLLATE 'utf8mb4_unicode_520_ci',
`sticker` TEXT NULL DEFAULT NULL COMMENT 'Sticker object. Message is a sticker, information about the sticker' COLLATE 'utf8mb4_unicode_520_ci',
`video` TEXT NULL DEFAULT NULL COMMENT 'Video object. Message is a video, information about the video' COLLATE 'utf8mb4_unicode_520_ci',
`voice` TEXT NULL DEFAULT NULL COMMENT 'Voice Object. Message is a Voice, information about the Voice' COLLATE 'utf8mb4_unicode_520_ci',
`video_note` TEXT NULL DEFAULT NULL COMMENT 'VoiceNote Object. Message is a Video Note, information about the Video Note' COLLATE 'utf8mb4_unicode_520_ci',
`caption` TEXT NULL DEFAULT NULL COMMENT 'For message with caption, the actual UTF-8 text of the caption' COLLATE 'utf8mb4_unicode_520_ci',
`has_media_spoiler` TINYINT(1) NULL DEFAULT '0' COMMENT 'True, if the message media is covered by a spoiler animation',
`contact` TEXT NULL DEFAULT NULL COMMENT 'Contact object. Message is a shared contact, information about the contact' COLLATE 'utf8mb4_unicode_520_ci',
`location` TEXT NULL DEFAULT NULL COMMENT 'Location object. Message is a shared location, information about the location' COLLATE 'utf8mb4_unicode_520_ci',
`venue` TEXT NULL DEFAULT NULL COMMENT 'Venue object. Message is a Venue, information about the Venue' COLLATE 'utf8mb4_unicode_520_ci',
`poll` TEXT NULL DEFAULT NULL COMMENT 'Poll object. Message is a native poll, information about the poll' COLLATE 'utf8mb4_unicode_520_ci',
`dice` TEXT NULL DEFAULT NULL COMMENT 'Message is a dice with random value from 1 to 6' COLLATE 'utf8mb4_unicode_520_ci',
`new_chat_members` TEXT NULL DEFAULT NULL COMMENT 'List of unique user identifiers, new member(s) were added to the group, information about them (one of these members may be the bot itself)' COLLATE 'utf8mb4_unicode_520_ci',
`left_chat_member` BIGINT(20) NULL DEFAULT NULL COMMENT 'Unique user identifier, a member was removed from the group, information about them (this member may be the bot itself)',
`new_chat_title` CHAR(255) NULL DEFAULT NULL COMMENT 'A chat title was changed to this value' COLLATE 'utf8mb4_unicode_520_ci',
`new_chat_photo` TEXT NULL DEFAULT NULL COMMENT 'Array of PhotoSize objects. A chat photo was change to this value' COLLATE 'utf8mb4_unicode_520_ci',
`delete_chat_photo` TINYINT(1) NULL DEFAULT '0' COMMENT 'Informs that the chat photo was deleted',
`group_chat_created` TINYINT(1) NULL DEFAULT '0' COMMENT 'Informs that the group has been created',
`supergroup_chat_created` TINYINT(1) NULL DEFAULT '0' COMMENT 'Informs that the supergroup has been created',
`channel_chat_created` TINYINT(1) NULL DEFAULT '0' COMMENT 'Informs that the channel chat has been created',
`message_auto_delete_timer_changed` TEXT NULL DEFAULT NULL COMMENT 'MessageAutoDeleteTimerChanged object. Message is a service message: auto-delete timer settings changed in the chat' COLLATE 'utf8mb4_unicode_520_ci',
`migrate_to_chat_id` BIGINT(20) NULL DEFAULT NULL COMMENT 'Migrate to chat identifier. The group has been migrated to a supergroup with the specified identifier',
`migrate_from_chat_id` BIGINT(20) NULL DEFAULT NULL COMMENT 'Migrate from chat identifier. The supergroup has been migrated from a group with the specified identifier',
`pinned_message` TEXT NULL DEFAULT NULL COMMENT 'Message object. Specified message was pinned' COLLATE 'utf8mb4_unicode_520_ci',
`invoice` TEXT NULL DEFAULT NULL COMMENT 'Message is an invoice for a payment, information about the invoice' COLLATE 'utf8mb4_unicode_520_ci',
`successful_payment` TEXT NULL DEFAULT NULL COMMENT 'Message is a service message about a successful payment, information about the payment' COLLATE 'utf8mb4_unicode_520_ci',
`user_shared` TEXT NULL DEFAULT NULL COMMENT 'Optional. Service message: a user was shared with the bot' COLLATE 'utf8mb4_unicode_520_ci',
`chat_shared` TEXT NULL DEFAULT NULL COMMENT 'Optional. Service message: a chat was shared with the bot' COLLATE 'utf8mb4_unicode_520_ci',
`connected_website` TEXT NULL DEFAULT NULL COMMENT 'The domain name of the website on which the user has logged in.' COLLATE 'utf8mb4_unicode_520_ci',
`write_access_allowed` TEXT NULL DEFAULT NULL COMMENT 'Service message: the user allowed the bot added to the attachment menu to write messages' COLLATE 'utf8mb4_unicode_520_ci',
`passport_data` TEXT NULL DEFAULT NULL COMMENT 'Telegram Passport data' COLLATE 'utf8mb4_unicode_520_ci',
`proximity_alert_triggered` TEXT NULL DEFAULT NULL COMMENT 'Service message. A user in the chat triggered another user\'s proximity alert while sharing Live Location.' COLLATE 'utf8mb4_unicode_520_ci',
`forum_topic_created` TEXT NULL DEFAULT NULL COMMENT 'Service message: forum topic created' COLLATE 'utf8mb4_unicode_520_ci',
`forum_topic_edited` TEXT NULL DEFAULT NULL COMMENT 'Service message: forum topic edited' COLLATE 'utf8mb4_unicode_520_ci',
`forum_topic_closed` TEXT NULL DEFAULT NULL COMMENT 'Service message: forum topic closed' COLLATE 'utf8mb4_unicode_520_ci',
`forum_topic_reopened` TEXT NULL DEFAULT NULL COMMENT 'Service message: forum topic reopened' COLLATE 'utf8mb4_unicode_520_ci',
`general_forum_topic_hidden` TEXT NULL DEFAULT NULL COMMENT 'Service message: the General forum topic hidden' COLLATE 'utf8mb4_unicode_520_ci',
`general_forum_topic_unhidden` TEXT NULL DEFAULT NULL COMMENT 'Service message: the General forum topic unhidden' COLLATE 'utf8mb4_unicode_520_ci',
`video_chat_scheduled` TEXT NULL DEFAULT NULL COMMENT 'Service message: video chat scheduled' COLLATE 'utf8mb4_unicode_520_ci',
`video_chat_started` TEXT NULL DEFAULT NULL COMMENT 'Service message: video chat started' COLLATE 'utf8mb4_unicode_520_ci',
`video_chat_ended` TEXT NULL DEFAULT NULL COMMENT 'Service message: video chat ended' COLLATE 'utf8mb4_unicode_520_ci',
`video_chat_participants_invited` TEXT NULL DEFAULT NULL COMMENT 'Service message: new participants invited to a video chat' COLLATE 'utf8mb4_unicode_520_ci',
`web_app_data` TEXT NULL DEFAULT NULL COMMENT 'Service message: data sent by a Web App' COLLATE 'utf8mb4_unicode_520_ci',
`reply_markup` TEXT NULL DEFAULT NULL COMMENT 'Inline keyboard attached to the message' COLLATE 'utf8mb4_unicode_520_ci',
PRIMARY KEY (`chat_id`, `id`) USING BTREE,
INDEX `user_id` (`user_id`) USING BTREE,
INDEX `forward_from` (`forward_from`) USING BTREE,
INDEX `forward_from_chat` (`forward_from_chat`) USING BTREE,
INDEX `reply_to_chat` (`reply_to_chat`) USING BTREE,
INDEX `reply_to_message` (`reply_to_message`) USING BTREE,
INDEX `via_bot` (`via_bot`) USING BTREE,
INDEX `left_chat_member` (`left_chat_member`) USING BTREE,
INDEX `migrate_from_chat_id` (`migrate_from_chat_id`) USING BTREE,
INDEX `migrate_to_chat_id` (`migrate_to_chat_id`) USING BTREE,
INDEX `reply_to_chat_2` (`reply_to_chat`, `reply_to_message`) USING BTREE,
CONSTRAINT `message_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT `message_ibfk_2` FOREIGN KEY (`chat_id`) REFERENCES `chat` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT `message_ibfk_3` FOREIGN KEY (`forward_from`) REFERENCES `user` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT `message_ibfk_4` FOREIGN KEY (`forward_from_chat`) REFERENCES `chat` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT `message_ibfk_5` FOREIGN KEY (`reply_to_chat`, `reply_to_message`) REFERENCES `message` (`chat_id`, `id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT `message_ibfk_6` FOREIGN KEY (`via_bot`) REFERENCES `user` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT,
CONSTRAINT `message_ibfk_7` FOREIGN KEY (`left_chat_member`) REFERENCES `user` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
)
COLLATE = 'utf8mb4_unicode_520_ci'
ENGINE = InnoDB
;