修复 FilamentAdmin 访问时出现的 HTTP 500 内部服务器错误:
HTTP request returned status code 500: Internal Server Errorsqlalchemy.exc.ProgrammingError: relation "prompt_templates" does not existQuestion Bank API 的 /prompts 端点尝试查询 prompt_templates 表,但该表在数据库中不存在,导致 SQL 执行失败,返回 HTTP 500 错误。
操作: 执行 /Volumes/T9/code/math/apis/QuestionBankService/create_prompt_table.py 脚本
结果: 成功创建 prompt_templates 表,包含以下字段:
id (UUID, 主键)template_name (String(100), 唯一)template_type (String(50))template_content (Text)variables (Text)version (Integer)is_active (String(10))description (Text)tags (String(200))created_at (DateTime)updated_at (DateTime)成功插入 5 个默认模板:
题目生成_基础版
掌握度评估_因式分解
技能熟练度分析
AI题目生成_增强版
智能题目审核
所有 API 端点现在都正常工作:
✅ GET /health - HTTP 200
✅ GET /questions?page=1&per_page=5 - HTTP 200
✅ GET /prompts?page=1&per_page=5 - HTTP 200
✅ GET /questions/statistics - HTTP 200
进入 QuestionBankService 目录
cd /Volumes/T9/code/math/apis/QuestionBankService
将创建脚本复制到容器
docker cp create_prompt_table.py api-question-bank:/app/
在容器中执行脚本
docker exec -u 0 api-question-bank python /app/create_prompt_table.py
清理 Laravel 缓存
cd /Volumes/T9/code/math/apis/FilamentAdmin
php artisan config:clear
php artisan cache:clear
php artisan view:clear
确认表创建成功:
SELECT * FROM prompt_templates;
-- 返回 5 行记录,表明默认模板已插入
GET /prompts?page=1&per_page=5
[
{
"id": "3597f1e3-a304-441e-a372-f20748d07915",
"template_name": "智能题目审核",
"template_type": "质量审核",
"template_content": "对生成的数学题目进行智能审核...",
"variables": "{\"question_code\": \"题目编号\", ...}",
"version": 1,
"is_active": null,
"description": "AI题目质量审核模板...",
"tags": "审核,质量,AI",
"created_at": "2025-11-17T05:11:44.657556",
"updated_at": "2025-11-17T05:11:44.657556"
},
...
]
2025-11-17 13:11
Claude Code
所有 HTTP 500 错误已完全解决:
prompt_templates 表已创建现在可以正常访问 FilamentAdmin 管理后台,所有功能应该都能正常工作。