spark-server/migrations/0006_user_login_logs.sql
2026-09-23 17:11:56 +08:00

16 lines
978 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- t_user_login_logs: one row per successful login. Device type lives on t_devices.
CREATE TABLE IF NOT EXISTS t_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='用户登录记录。每次成功登录追加一行;当次 App 见 app_id';