fix: scope login audit records by tenant
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
-- MySQL 8.0. Admin message governance and authentication audit tables.
|
||||
-- Execute this script in each tenant business database.
|
||||
-- Execute this script in the shared meeting_im database; tenant_id provides tenant isolation.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS im_user_login_logs (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
tenant_id BIGINT NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
username VARCHAR(64) NOT NULL DEFAULT '',
|
||||
account_type VARCHAR(24) NOT NULL DEFAULT '',
|
||||
@@ -24,6 +25,7 @@ CREATE TABLE IF NOT EXISTS im_user_login_logs (
|
||||
metadata JSON NULL,
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (id),
|
||||
INDEX idx_im_user_login_tenant_time (tenant_id, login_at DESC, id DESC),
|
||||
INDEX idx_im_user_login_user_time (user_id, login_at DESC, id DESC),
|
||||
INDEX idx_im_user_login_ip_time (ip, login_at DESC, id DESC),
|
||||
INDEX idx_im_user_login_device_time (device_id(64), login_at DESC),
|
||||
|
||||
Reference in New Issue
Block a user