-- user_login_logs: one row per successful login. user_devices.platform is the device type. CREATE TABLE IF NOT EXISTS user_login_logs ( id BIGINT NOT NULL AUTO_INCREMENT COMMENT '行 id,表内自增', user_id BIGINT NOT NULL COMMENT '登录用户', device_id BIGINT UNSIGNED NOT NULL COMMENT '客户端设备 id', device_type VARCHAR(16) NOT NULL COMMENT '设备类型:ios/android/harmony/windows/macos/web', device_name VARCHAR(128) NOT NULL DEFAULT '' COMMENT '设备展示名', app_version VARCHAR(32) NOT NULL DEFAULT '' COMMENT '客户端版本', language VARCHAR(16) NOT NULL DEFAULT '' COMMENT '登录语言', ip VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'PROXY RealIP', created_at DATETIME(3) NOT NULL COMMENT '本次登录时间', PRIMARY KEY (id), KEY idx_user_created (user_id, created_at) ) COMMENT='用户登录记录。每次成功登录追加一行;当前设备以 user_devices 为准'; ALTER TABLE user_devices MODIFY COLUMN platform VARCHAR(32) NOT NULL DEFAULT '' COMMENT '设备类型:ios/android/harmony/windows/macos/web';