feat(training): 打通新人培训真实数据闭环
This commit is contained in:
1 parent
3f13bb5b46
commit
19f43e8018
13 files changed
+1144
-162
No files matched your search
@@ -25,6 +25,7 @@ def register_blueprints(app: Flask) -> None:
|
||||
from app.api.integration import integration_bp
|
||||
from app.api.internal_jobs import internal_jobs_bp
|
||||
from app.api.speech import speech_bp
|
||||
from app.api.training import training_admin_bp, training_user_bp
|
||||
|
||||
# [STEP 2] 已分包骨架(Wave 3:kb、schedule 等)
|
||||
from app.api.kb import knowledge_base_bp
|
||||
@@ -40,6 +41,7 @@ def register_blueprints(app: Flask) -> None:
|
||||
app.register_blueprint(admin_bp, url_prefix='/api/admin')
|
||||
app.register_blueprint(agents_bp, url_prefix='/api/agents')
|
||||
app.register_blueprint(user_bp, url_prefix='/api/user')
|
||||
app.register_blueprint(training_user_bp, url_prefix='/api/user')
|
||||
app.register_blueprint(knowledge_base_bp, url_prefix='/api/kb')
|
||||
app.register_blueprint(integration_bp, url_prefix='/api/integration')
|
||||
app.register_blueprint(schedule_admin_bp, url_prefix='/api/admin')
|
||||
@@ -50,3 +52,4 @@ def register_blueprints(app: Flask) -> None:
|
||||
app.register_blueprint(shipping_notice_bp, url_prefix='/api/shipping-notice')
|
||||
app.register_blueprint(file_check_bp, url_prefix='/api/file-check')
|
||||
app.register_blueprint(speech_bp, url_prefix='/api/speech')
|
||||
app.register_blueprint(training_admin_bp, url_prefix='/api/admin')
|
||||
@@ -0,0 +1,121 @@
|
||||
"""
|
||||
backend/app/api/training.py
|
||||
|
||||
用途:提供新人培训用户侧进度接口与管理端统计导出接口。
|
||||
依赖:JWT 当前用户解析、training_service、Flask Blueprint/send_file。
|
||||
逻辑:员工端负责读写个人培训进度;管理端负责真实记录查询、统计与 Excel 导出。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
from flask import Blueprint, jsonify, request, send_file
|
||||
|
||||
from app.core.auth.jwt import get_current_user
|
||||
from app.core.errors import ForbiddenError, UnauthorizedError
|
||||
from app.services.training_service import (
|
||||
export_training_records_excel,
|
||||
get_user_training_record,
|
||||
list_training_records,
|
||||
serialize_training_record,
|
||||
summarize_training_records,
|
||||
upsert_user_training_record,
|
||||
)
|
||||
|
||||
training_user_bp = Blueprint("training_user", __name__)
|
||||
training_admin_bp = Blueprint("training_admin", __name__)
|
||||
|
||||
|
||||
def _require_user():
|
||||
"""确保当前请求存在登录用户。"""
|
||||
user = get_current_user()
|
||||
if not user:
|
||||
raise UnauthorizedError()
|
||||
return user
|
||||
|
||||
|
||||
def _require_training_admin():
|
||||
"""确保当前用户具备培训管理权限。"""
|
||||
user = _require_user()
|
||||
if user.role not in {"admin", "hr"}:
|
||||
raise ForbiddenError("Training admin privilege required")
|
||||
return user
|
||||
|
||||
|
||||
@training_user_bp.route("/training-record", methods=["GET"])
|
||||
def get_my_training_record():
|
||||
"""读取当前用户的培训进度;未创建时返回 null data。"""
|
||||
user = _require_user()
|
||||
record = get_user_training_record(user.id)
|
||||
return jsonify(serialize_training_record(record) if record else None)
|
||||
|
||||
|
||||
@training_user_bp.route("/training-record/progress", methods=["PUT"])
|
||||
def save_my_training_record():
|
||||
"""保存当前用户培训进度,用于视频完成、答题推进与结算归档。"""
|
||||
user = _require_user()
|
||||
payload = request.get_json() or {}
|
||||
record = upsert_user_training_record(user, payload)
|
||||
return jsonify(serialize_training_record(record))
|
||||
|
||||
|
||||
@training_admin_bp.route("/training-records", methods=["GET"])
|
||||
def list_admin_training_records():
|
||||
"""列出培训记录,支持关键字、部门、状态筛选。"""
|
||||
_require_training_admin()
|
||||
keyword = request.args.get("keyword")
|
||||
department = request.args.get("department")
|
||||
status = request.args.get("status")
|
||||
|
||||
result = list_training_records(keyword=keyword, department=department, status=status)
|
||||
all_records = list_training_records()
|
||||
department_options = sorted({str(item.department or "").strip() for item in all_records.records if str(item.department or "").strip()})
|
||||
|
||||
page = max(1, request.args.get("page", type=int) or 1)
|
||||
page_size = max(1, min(200, request.args.get("page_size", type=int) or max(result.total, 1)))
|
||||
start = (page - 1) * page_size
|
||||
end = start + page_size
|
||||
items = result.records[start:end]
|
||||
pages = max(1, (result.total + page_size - 1) // page_size) if result.total else 1
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"items": [serialize_training_record(item) for item in items],
|
||||
"total": result.total,
|
||||
"page": page,
|
||||
"page_size": page_size,
|
||||
"pages": pages,
|
||||
"department_options": department_options,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@training_admin_bp.route("/training-records/stats", methods=["GET"])
|
||||
def get_admin_training_stats():
|
||||
"""返回培训记录聚合统计,供 HR 面板展示。"""
|
||||
_require_training_admin()
|
||||
result = list_training_records(
|
||||
keyword=request.args.get("keyword"),
|
||||
department=request.args.get("department"),
|
||||
status=request.args.get("status"),
|
||||
)
|
||||
return jsonify(summarize_training_records(result.records))
|
||||
|
||||
|
||||
@training_admin_bp.route("/training-records/export", methods=["GET"])
|
||||
def export_admin_training_records():
|
||||
"""导出培训记录为 Excel。"""
|
||||
_require_training_admin()
|
||||
result = list_training_records(
|
||||
keyword=request.args.get("keyword"),
|
||||
department=request.args.get("department"),
|
||||
status=request.args.get("status"),
|
||||
)
|
||||
file_data, file_name = export_training_records_excel(result.records)
|
||||
return send_file(
|
||||
BytesIO(file_data),
|
||||
as_attachment=True,
|
||||
download_name=file_name,
|
||||
mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
)
|
||||
@@ -23,6 +23,7 @@ from app.models.shipping import (
|
||||
ShippingTaskEvent,
|
||||
ShippingTaskInventoryLink,
|
||||
)
|
||||
from app.models.training import TrainingRecord
|
||||
from app.models.user import LoginAudit, User, UserDefaultAgent, UserFavoriteAgent, UserHomepageConfig
|
||||
from app.models.wecom import WecomCallbackAudit, WecomNotifyAudit
|
||||
|
||||
@@ -64,4 +65,5 @@ __all__ = [
|
||||
'ShippingTaskInventoryLink',
|
||||
'ShippingInventoryMapping',
|
||||
'AgentGuide',
|
||||
'TrainingRecord',
|
||||
]
|
||||
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
backend/app/models/training.py
|
||||
|
||||
用途:定义新人入职培训记录模型,承载学员当前培训进度、成绩结算与 HR 统计来源。
|
||||
依赖:models.base.Base、SQLAlchemy 映射、users 主表外键。
|
||||
逻辑:每个用户维护一条当前培训记录;前端学习流与管理端统计都基于该表读写。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import Boolean, Date, DateTime, ForeignKey, Integer, JSON, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class TrainingRecord(Base):
|
||||
"""新人入职培训当前记录。"""
|
||||
|
||||
__tablename__ = "training_records"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), unique=True, index=True, nullable=False)
|
||||
employee_id: Mapped[Optional[str]] = mapped_column(String(50), nullable=True, index=True)
|
||||
name: Mapped[Optional[str]] = mapped_column(String(100), nullable=True, index=True)
|
||||
department: Mapped[Optional[str]] = mapped_column(String(100), nullable=True, index=True)
|
||||
join_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True, index=True)
|
||||
stage: Mapped[str] = mapped_column(String(20), nullable=False, default="video", index=True)
|
||||
current_question_index: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
score: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
passed: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True)
|
||||
attempt_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
answer_details: Mapped[list[dict] | None] = mapped_column(JSON, nullable=True)
|
||||
started_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
completion_time: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True, index=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow, index=True)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime,
|
||||
nullable=False,
|
||||
default=datetime.utcnow,
|
||||
onupdate=datetime.utcnow,
|
||||
index=True,
|
||||
)
|
||||
|
||||
user = relationship("User", back_populates="training_record")
|
||||
@@ -78,6 +78,11 @@ class User(Base):
|
||||
|
||||
reset_token: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
reset_token_expiry: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
training_record: Mapped[Optional['TrainingRecord']] = relationship(
|
||||
'TrainingRecord',
|
||||
back_populates='user',
|
||||
uselist=False,
|
||||
)
|
||||
|
||||
def set_password(self, password: str) -> None:
|
||||
"""设置密码哈希。"""
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
"""
|
||||
backend/app/services/training_service.py
|
||||
|
||||
用途:封装新人培训记录的序列化、进度保存、列表筛选、统计与导出能力。
|
||||
依赖:app.models.TrainingRecord/User、app.extensions.db、openpyxl。
|
||||
逻辑:API 层仅做鉴权与参数解析;本模块负责把前端培训状态转成数据库记录并提供 HR 侧聚合结果。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import date, datetime
|
||||
from io import BytesIO
|
||||
from typing import Any, Iterable, Optional
|
||||
|
||||
from openpyxl import Workbook
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.core.errors import ValidationError
|
||||
from app.extensions import db
|
||||
from app.models import TrainingRecord, User
|
||||
|
||||
TRAINING_STAGES = {"video", "summary", "exam", "result"}
|
||||
|
||||
|
||||
def _parse_iso_date(value: Any) -> Optional[date]:
|
||||
text = str(value or "").strip()
|
||||
if not text:
|
||||
return None
|
||||
try:
|
||||
return date.fromisoformat(text)
|
||||
except ValueError as exc:
|
||||
raise ValidationError("join_date must be YYYY-MM-DD", details={"field": "join_date"}) from exc
|
||||
|
||||
|
||||
def _normalize_answer_details(value: Any) -> list[dict]:
|
||||
if value in (None, ""):
|
||||
return []
|
||||
if not isinstance(value, list):
|
||||
raise ValidationError("answer_details must be an array", details={"field": "answer_details"})
|
||||
normalized: list[dict] = []
|
||||
for index, item in enumerate(value):
|
||||
if not isinstance(item, dict):
|
||||
raise ValidationError(
|
||||
"answer_details item must be an object",
|
||||
details={"field": "answer_details", "index": index},
|
||||
)
|
||||
normalized.append(
|
||||
{
|
||||
"question_id": str(item.get("question_id") or item.get("questionId") or ""),
|
||||
"selected_option_id": str(item.get("selected_option_id") or item.get("selectedOptionId") or ""),
|
||||
"correct": bool(item.get("correct", False)),
|
||||
}
|
||||
)
|
||||
return normalized
|
||||
|
||||
|
||||
def _derive_status(record: TrainingRecord) -> str:
|
||||
if bool(record.passed):
|
||||
return "passed"
|
||||
if record.stage == "result":
|
||||
return "failed"
|
||||
return "in_progress"
|
||||
|
||||
|
||||
def serialize_training_record(record: TrainingRecord) -> dict[str, Any]:
|
||||
"""将培训记录序列化为前端可直接消费的结构。"""
|
||||
return {
|
||||
"id": record.id,
|
||||
"user_id": record.user_id,
|
||||
"employee_id": record.employee_id,
|
||||
"name": record.name,
|
||||
"department": record.department,
|
||||
"join_date": record.join_date.isoformat() if record.join_date else None,
|
||||
"stage": record.stage,
|
||||
"current_question_index": int(record.current_question_index or 0),
|
||||
"score": int(record.score or 0),
|
||||
"passed": bool(record.passed),
|
||||
"attempt_count": int(record.attempt_count or 0),
|
||||
"answer_details": list(record.answer_details or []),
|
||||
"started_at": record.started_at.isoformat() if record.started_at else None,
|
||||
"completion_time": record.completion_time.isoformat() if record.completion_time else None,
|
||||
"created_at": record.created_at.isoformat() if record.created_at else None,
|
||||
"updated_at": record.updated_at.isoformat() if record.updated_at else None,
|
||||
"status": _derive_status(record),
|
||||
}
|
||||
|
||||
|
||||
def _apply_user_snapshot(record: TrainingRecord, user: User) -> None:
|
||||
record.employee_id = (user.employee_id or "").strip() or None
|
||||
record.name = (user.real_name or "").strip() or (user.username or "").strip() or None
|
||||
record.department = (user.department or "").strip() or None
|
||||
|
||||
|
||||
def get_user_training_record(user_id: int) -> Optional[TrainingRecord]:
|
||||
"""查询指定用户当前培训记录。"""
|
||||
stmt = select(TrainingRecord).where(TrainingRecord.user_id == user_id)
|
||||
return db.session.execute(stmt).scalar_one_or_none()
|
||||
|
||||
|
||||
def upsert_user_training_record(user: User, payload: dict[str, Any]) -> TrainingRecord:
|
||||
"""
|
||||
保存当前用户培训进度。
|
||||
|
||||
Args:
|
||||
user: 当前登录用户。
|
||||
payload: 前端上传的培训进度快照。
|
||||
Returns:
|
||||
已保存的 TrainingRecord。
|
||||
"""
|
||||
stage = str(payload.get("stage") or "video").strip() or "video"
|
||||
if stage not in TRAINING_STAGES:
|
||||
raise ValidationError("stage is invalid", details={"field": "stage", "allowed": sorted(TRAINING_STAGES)})
|
||||
|
||||
current_question_index = int(payload.get("current_question_index") or payload.get("currentQuestionIndex") or 0)
|
||||
score = int(payload.get("score") or 0)
|
||||
attempt_count = int(payload.get("attempt_count") or payload.get("attemptCount") or 0)
|
||||
if current_question_index < 0:
|
||||
raise ValidationError("current_question_index must be >= 0", details={"field": "current_question_index"})
|
||||
if score < 0:
|
||||
raise ValidationError("score must be >= 0", details={"field": "score"})
|
||||
if attempt_count < 0:
|
||||
raise ValidationError("attempt_count must be >= 0", details={"field": "attempt_count"})
|
||||
|
||||
answer_details = _normalize_answer_details(payload.get("answer_details") or payload.get("answerDetails"))
|
||||
passed = bool(payload.get("passed")) or (stage == "result" and score >= 90)
|
||||
join_date = _parse_iso_date(payload.get("join_date") or payload.get("joinDate"))
|
||||
|
||||
record = get_user_training_record(user.id)
|
||||
if not record:
|
||||
record = TrainingRecord(
|
||||
user_id=user.id,
|
||||
join_date=join_date or date.today(),
|
||||
started_at=datetime.utcnow(),
|
||||
)
|
||||
db.session.add(record)
|
||||
elif join_date:
|
||||
record.join_date = join_date
|
||||
|
||||
_apply_user_snapshot(record, user)
|
||||
record.stage = stage
|
||||
record.current_question_index = current_question_index
|
||||
record.score = score
|
||||
record.passed = passed
|
||||
record.attempt_count = attempt_count
|
||||
record.answer_details = answer_details
|
||||
|
||||
if stage == "result":
|
||||
record.completion_time = datetime.utcnow()
|
||||
if not record.started_at:
|
||||
record.started_at = datetime.utcnow()
|
||||
else:
|
||||
record.completion_time = None
|
||||
if stage in {"summary", "exam"} and not record.started_at:
|
||||
record.started_at = datetime.utcnow()
|
||||
|
||||
db.session.commit()
|
||||
return record
|
||||
|
||||
|
||||
@dataclass
|
||||
class TrainingListResult:
|
||||
records: list[TrainingRecord]
|
||||
total: int
|
||||
|
||||
|
||||
def list_training_records(*, keyword: str | None = None, department: str | None = None, status: str | None = None) -> TrainingListResult:
|
||||
"""按筛选条件列出培训记录。"""
|
||||
query = db.session.query(TrainingRecord).order_by(TrainingRecord.updated_at.desc(), TrainingRecord.id.desc())
|
||||
records = query.all()
|
||||
|
||||
keyword_text = str(keyword or "").strip().lower()
|
||||
department_text = str(department or "").strip()
|
||||
status_text = str(status or "").strip()
|
||||
|
||||
filtered: list[TrainingRecord] = []
|
||||
for record in records:
|
||||
record_status = _derive_status(record)
|
||||
if keyword_text:
|
||||
searchable = " ".join(
|
||||
[
|
||||
str(record.name or ""),
|
||||
str(record.employee_id or ""),
|
||||
]
|
||||
).lower()
|
||||
if keyword_text not in searchable:
|
||||
continue
|
||||
if department_text and department_text != "all" and (record.department or "") != department_text:
|
||||
continue
|
||||
if status_text and status_text != "all" and record_status != status_text:
|
||||
continue
|
||||
filtered.append(record)
|
||||
|
||||
return TrainingListResult(records=filtered, total=len(filtered))
|
||||
|
||||
|
||||
def summarize_training_records(records: Iterable[TrainingRecord]) -> dict[str, int]:
|
||||
"""统计培训记录聚合指标。"""
|
||||
data = list(records)
|
||||
total = len(data)
|
||||
passed = sum(1 for item in data if _derive_status(item) == "passed")
|
||||
failed = sum(1 for item in data if _derive_status(item) == "failed")
|
||||
in_progress = sum(1 for item in data if _derive_status(item) == "in_progress")
|
||||
scored_items = [int(item.score or 0) for item in data if item.score is not None]
|
||||
average_score = round(sum(scored_items) / len(scored_items)) if scored_items else 0
|
||||
return {
|
||||
"total": total,
|
||||
"passed": passed,
|
||||
"failed": failed,
|
||||
"in_progress": in_progress,
|
||||
"pass_rate": round((passed / total) * 100) if total else 0,
|
||||
"average_score": average_score,
|
||||
}
|
||||
|
||||
|
||||
def export_training_records_excel(records: Iterable[TrainingRecord]) -> tuple[bytes, str]:
|
||||
"""将培训记录导出为 Excel 文件。"""
|
||||
workbook = Workbook()
|
||||
worksheet = workbook.active
|
||||
worksheet.title = "training"
|
||||
worksheet.append(["入职日期", "完成日期", "部门", "姓名", "工号", "分数", "考试次数", "状态"])
|
||||
|
||||
for record in records:
|
||||
worksheet.append(
|
||||
[
|
||||
record.join_date.isoformat() if record.join_date else "",
|
||||
record.completion_time.date().isoformat() if record.completion_time else "",
|
||||
record.department or "",
|
||||
record.name or "",
|
||||
record.employee_id or "",
|
||||
record.score if record.score is not None else "",
|
||||
record.attempt_count or 0,
|
||||
_derive_status(record),
|
||||
]
|
||||
)
|
||||
|
||||
buffer = BytesIO()
|
||||
workbook.save(buffer)
|
||||
filename = f"training_records_{datetime.utcnow().date().isoformat()}.xlsx"
|
||||
return buffer.getvalue(), filename
|
||||
@@ -0,0 +1,74 @@
|
||||
"""Add training records table.
|
||||
|
||||
Purpose:
|
||||
Persist onboarding training progress, final score and HR export source data.
|
||||
Dependencies:
|
||||
Alembic revision fb2c3d4e5f6a.
|
||||
Flow:
|
||||
Frontend learner flow updates one current record per user; admin endpoints
|
||||
read the same table for stats and Excel export.
|
||||
|
||||
Revision ID: fc3d4e5f6a7b
|
||||
Revises: fb2c3d4e5f6a
|
||||
Create Date: 2026-06-30 22:30:00.000000
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "fc3d4e5f6a7b"
|
||||
down_revision = "fb2c3d4e5f6a"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
"""Create training_records table."""
|
||||
op.create_table(
|
||||
"training_records",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("user_id", sa.Integer(), nullable=False),
|
||||
sa.Column("employee_id", sa.String(length=50), nullable=True),
|
||||
sa.Column("name", sa.String(length=100), nullable=True),
|
||||
sa.Column("department", sa.String(length=100), nullable=True),
|
||||
sa.Column("join_date", sa.Date(), nullable=True),
|
||||
sa.Column("stage", sa.String(length=20), nullable=False),
|
||||
sa.Column("current_question_index", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("score", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("passed", sa.Boolean(), nullable=False, server_default=sa.text("false")),
|
||||
sa.Column("attempt_count", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("answer_details", sa.JSON(), nullable=True),
|
||||
sa.Column("started_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("completion_time", sa.DateTime(), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("user_id", name="uq_training_records_user_id"),
|
||||
)
|
||||
op.create_index("ix_training_records_user_id", "training_records", ["user_id"], unique=True)
|
||||
op.create_index("ix_training_records_employee_id", "training_records", ["employee_id"], unique=False)
|
||||
op.create_index("ix_training_records_name", "training_records", ["name"], unique=False)
|
||||
op.create_index("ix_training_records_department", "training_records", ["department"], unique=False)
|
||||
op.create_index("ix_training_records_join_date", "training_records", ["join_date"], unique=False)
|
||||
op.create_index("ix_training_records_stage", "training_records", ["stage"], unique=False)
|
||||
op.create_index("ix_training_records_passed", "training_records", ["passed"], unique=False)
|
||||
op.create_index("ix_training_records_completion_time", "training_records", ["completion_time"], unique=False)
|
||||
op.create_index("ix_training_records_created_at", "training_records", ["created_at"], unique=False)
|
||||
op.create_index("ix_training_records_updated_at", "training_records", ["updated_at"], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
"""Drop training_records table."""
|
||||
op.drop_index("ix_training_records_updated_at", table_name="training_records")
|
||||
op.drop_index("ix_training_records_created_at", table_name="training_records")
|
||||
op.drop_index("ix_training_records_completion_time", table_name="training_records")
|
||||
op.drop_index("ix_training_records_passed", table_name="training_records")
|
||||
op.drop_index("ix_training_records_stage", table_name="training_records")
|
||||
op.drop_index("ix_training_records_join_date", table_name="training_records")
|
||||
op.drop_index("ix_training_records_department", table_name="training_records")
|
||||
op.drop_index("ix_training_records_name", table_name="training_records")
|
||||
op.drop_index("ix_training_records_employee_id", table_name="training_records")
|
||||
op.drop_index("ix_training_records_user_id", table_name="training_records")
|
||||
op.drop_table("training_records")
|
||||
Reference in new issue
Block a user