feat: 实现数据库迁移、搜索和分页功能

- 添加数据库迁移系统和初始用户表迁移
- 实现搜索功能模块和API
- 实现分页功能支持
- 添加相关测试文件
- 更新项目配置和文档
This commit is contained in:
2025-08-05 23:41:40 +08:00
parent c18f345475
commit cf01d557b9
26 changed files with 3578 additions and 27 deletions

View File

@@ -0,0 +1,17 @@
-- 初始用户表创建
-- Migration: 001_initial_users_table
-- Description: 创建用户表和基础索引
CREATE TABLE IF NOT EXISTS users (
id TEXT PRIMARY KEY,
username TEXT UNIQUE NOT NULL,
email TEXT NOT NULL,
password_hash TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
-- 创建索引以提高查询性能
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
CREATE INDEX IF NOT EXISTS idx_users_created_at ON users(created_at);

View File

@@ -0,0 +1,15 @@
-- 添加用户表索引优化
-- Migration: 002_add_user_indexes
-- Description: 为用户表添加性能优化索引
-- 为邮箱字段添加索引(如果不存在)
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
-- 为创建时间添加索引(用于排序查询)
CREATE INDEX IF NOT EXISTS idx_users_created_at ON users(created_at);
-- 为更新时间添加索引
CREATE INDEX IF NOT EXISTS idx_users_updated_at ON users(updated_at);
-- 添加复合索引用于常见查询模式
CREATE INDEX IF NOT EXISTS idx_users_username_email ON users(username, email);