gengx
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
CREATE TABLE IF NOT EXISTS im_conversations (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
conversation_type TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
last_seq BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
last_message_id BIGINT UNSIGNED NULL,
|
||||
last_message_at DATETIME(3) NULL,
|
||||
status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_conversation_last (last_message_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS im_direct_conversations (
|
||||
conversation_id BIGINT UNSIGNED NOT NULL,
|
||||
user1_id BIGINT UNSIGNED NOT NULL,
|
||||
user2_id BIGINT UNSIGNED NOT NULL,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (conversation_id),
|
||||
UNIQUE KEY uk_direct_pair (user1_id, user2_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS im_conversation_members (
|
||||
conversation_id BIGINT UNSIGNED NOT NULL,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
join_seq BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
read_seq BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
delivered_seq BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
clear_seq BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
pinned TINYINT(1) NOT NULL DEFAULT 0,
|
||||
muted TINYINT(1) NOT NULL DEFAULT 0,
|
||||
status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
joined_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (conversation_id, user_id),
|
||||
KEY idx_member_user (user_id, updated_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS im_messages (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
conversation_id BIGINT UNSIGNED NOT NULL,
|
||||
seq BIGINT UNSIGNED NOT NULL,
|
||||
sender_id BIGINT UNSIGNED NOT NULL,
|
||||
client_msg_id CHAR(26) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
||||
message_type SMALLINT UNSIGNED NOT NULL,
|
||||
body MEDIUMBLOB NOT NULL,
|
||||
reply_to_message_id BIGINT UNSIGNED NULL,
|
||||
moderation_status TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
recalled_at DATETIME(3) NULL,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_conv_seq (conversation_id, seq),
|
||||
UNIQUE KEY uk_sender_client_msg (sender_id, client_msg_id),
|
||||
KEY idx_conv_created (conversation_id, created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS im_user_sync_events (
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
event_seq BIGINT UNSIGNED NOT NULL,
|
||||
event_type SMALLINT UNSIGNED NOT NULL,
|
||||
conversation_id BIGINT UNSIGNED NOT NULL,
|
||||
message_seq BIGINT UNSIGNED NOT NULL,
|
||||
event_data MEDIUMBLOB NULL,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (user_id, event_seq),
|
||||
KEY idx_sync_created (created_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
Reference in New Issue
Block a user