Files
zjpb.net/create_user_tables.py
Jowe 2067fb1712 feat: v3.0 - 用户系统和收藏功能
核心功能:
- 用户注册/登录系统(用户名+密码)
- 工具收藏功能(一键收藏/取消收藏)
- 收藏分组管理(文件夹)
- 用户中心(个人资料、收藏列表)

数据库变更:
- 新增 users 表(用户信息)
- 新增 folders 表(收藏分组)
- 新增 collections 表(收藏记录)

安全增强:
- Admin 和 User 完全隔离
- 修复14个管理员路由的权限漏洞
- 所有管理功能添加用户类型检查

新增文件:
- templates/auth/register.html - 注册页面
- templates/auth/login.html - 登录页面
- templates/user/profile.html - 用户中心
- templates/user/collections.html - 收藏列表
- create_user_tables.py - 数据库迁移脚本
- USER_SYSTEM_README.md - 用户系统文档
- CHANGELOG_v3.0.md - 版本更新日志

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 19:19:05 +08:00

37 lines
989 B
Python
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.
"""
数据库迁移脚本:创建用户系统相关表
运行方式python create_user_tables.py
"""
import os
from app import create_app
from models import db, User, Folder, Collection
def create_user_tables():
"""创建用户系统相关的数据库表"""
app = create_app(os.getenv('FLASK_ENV', 'development'))
with app.app_context():
print("开始创建用户系统表...")
try:
# 创建表(如果不存在)
db.create_all()
print("SUCCESS: Database tables created successfully!")
# 显示创建的表信息
print("\nCreated tables:")
print("- users")
print("- folders")
print("- collections")
print("\nMigration completed!")
except Exception as e:
print(f"ERROR: Failed to create tables: {str(e)}")
import traceback
traceback.print_exc()
if __name__ == '__main__':
create_user_tables()