yunzer_go/server/database/yz_users.sql
2025-10-27 23:13:08 +08:00

33 lines
1.7 KiB
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.

-- 创建用户表
CREATE TABLE yz_users (
id INT PRIMARY KEY AUTO_INCREMENT COMMENT '用户ID',
username VARCHAR(50) NOT NULL COMMENT '用户名',
password VARCHAR(255) NOT NULL COMMENT '加密后的密码',
salt VARCHAR(100) NOT NULL COMMENT '密码盐值',
email VARCHAR(100) DEFAULT NULL COMMENT '邮箱地址',
avatar VARCHAR(500) DEFAULT NULL COMMENT '头像URL',
nickname VARCHAR(50) DEFAULT NULL COMMENT '昵称',
role VARCHAR(20) DEFAULT 'user' COMMENT '用户角色admin-管理员user-普通用户',
status TINYINT DEFAULT 1 COMMENT '用户状态0-禁用1-启用',
last_login_time DATETIME DEFAULT NULL COMMENT '最后登录时间',
last_login_ip VARCHAR(45) DEFAULT NULL COMMENT '最后登录IP',
login_count INT DEFAULT 0 COMMENT '登录次数',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
create_by VARCHAR(50) DEFAULT NULL COMMENT '创建人',
update_by VARCHAR(50) DEFAULT NULL COMMENT '更新人',
-- 索引
UNIQUE KEY uk_username (username),
INDEX idx_email (email),
INDEX idx_role (role),
INDEX idx_status (status),
INDEX idx_create_time (create_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户表';
-- 插入默认管理员用户
-- 密码为 yunzer123已使用scrypt算法加密
INSERT INTO yz_users (username, password, salt, email, nickname, role, status, create_by) VALUES
('admin', 'encrypted_password_here', 'salt_here', 'admin@yunzer.com', '超级管理员', 'admin', 1, 'system'),
('test', 'encrypted_password_here', 'salt_here', 'test@yunzer.com', '测试用户', 'user', 1, 'system');