feat: 实现用户注册功能,包括数据库表结构、gRPC 服务和业务逻辑
This commit is contained in:
33
backend/services/user-svc/migrations/001_init.sql
Normal file
33
backend/services/user-svc/migrations/001_init.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- 创建 user_main 表
|
||||
CREATE TABLE IF NOT EXISTS user_main (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
deleted BOOLEAN DEFAULT false,
|
||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- 创建 user_login_account 表
|
||||
CREATE TABLE IF NOT EXISTS user_login_account (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id UUID NOT NULL REFERENCES user_main(id),
|
||||
account VARCHAR(255) NOT NULL,
|
||||
deleted BOOLEAN DEFAULT false,
|
||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(account)
|
||||
);
|
||||
|
||||
-- 创建 user_login_password 表
|
||||
CREATE TABLE IF NOT EXISTS user_login_password (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id UUID NOT NULL REFERENCES user_main(id),
|
||||
password VARCHAR(255) NOT NULL,
|
||||
deleted BOOLEAN DEFAULT false,
|
||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX IF NOT EXISTS idx_user_login_account_user_id ON user_login_account(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_login_account_account ON user_login_account(account);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_login_password_user_id ON user_login_password(user_id);
|
||||
Reference in New Issue
Block a user