feat(安全培训): 新增员工安全培训相关功能
This commit is contained in:
1 parent
cbc3cb959f
commit
8e5c57790c
50 files changed
+3769
-87
No files matched your search
@@ -0,0 +1,28 @@
|
||||
"""add_training_type
|
||||
|
||||
Revision ID: 3d65de4125ed
|
||||
Revises: e5f7a9b1c3d4
|
||||
Create Date: 2026-08-04 18:23:04.203981
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3d65de4125ed'
|
||||
down_revision = 'e5f7a9b1c3d4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('training_records', sa.Column('training_type', sa.String(length=50), nullable=False, server_default='onboarding'))
|
||||
op.create_index(op.f('ix_training_records_training_type'), 'training_records', ['training_type'], unique=False)
|
||||
op.create_unique_constraint('uq_user_training_type', 'training_records', ['user_id', 'training_type'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint('uq_user_training_type', 'training_records', type_='unique')
|
||||
op.drop_index(op.f('ix_training_records_training_type'), table_name='training_records')
|
||||
op.drop_column('training_records', 'training_type')
|
||||
@@ -0,0 +1,25 @@
|
||||
"""drop_training_user_unique
|
||||
|
||||
Revision ID: 4f92c6b1a3de
|
||||
Revises: 8b71d2e4a9c1
|
||||
Create Date: 2026-08-06 19:05:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4f92c6b1a3de'
|
||||
down_revision = '8b71d2e4a9c1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("DROP INDEX IF EXISTS ix_training_records_user_id;")
|
||||
op.execute("ALTER TABLE training_records DROP CONSTRAINT IF EXISTS uq_training_records_user_id;")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("ALTER TABLE training_records ADD CONSTRAINT uq_training_records_user_id UNIQUE (user_id);")
|
||||
op.execute("CREATE UNIQUE INDEX IF NOT EXISTS ix_training_records_user_id ON training_records (user_id);")
|
||||
@@ -0,0 +1,24 @@
|
||||
"""merge multiple heads
|
||||
|
||||
Revision ID: 69f452bb049f
|
||||
Revises: 4f92c6b1a3de, a0b1c2d3e4f5
|
||||
Create Date: 2026-08-07 12:05:26.063430
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '69f452bb049f'
|
||||
down_revision = ('4f92c6b1a3de', 'a0b1c2d3e4f5')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -0,0 +1,56 @@
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "7a8b9c0d1e2f"
|
||||
down_revision = "69f452bb049f"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
"training_configs",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("training_type", sa.String(length=50), nullable=False),
|
||||
sa.Column("name", sa.String(length=100), nullable=False),
|
||||
sa.Column("version", sa.String(length=64), nullable=False),
|
||||
sa.Column("status", sa.String(length=20), nullable=False),
|
||||
sa.Column("pass_score", sa.Integer(), nullable=False),
|
||||
sa.Column("settings", sa.JSON(), nullable=True),
|
||||
sa.Column("created_by_id", sa.Integer(), nullable=True),
|
||||
sa.Column("updated_by_id", sa.Integer(), nullable=True),
|
||||
sa.Column("published_at", sa.DateTime(), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["created_by_id"], ["users.id"]),
|
||||
sa.ForeignKeyConstraint(["updated_by_id"], ["users.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index("ix_training_configs_training_type", "training_configs", ["training_type"], unique=False)
|
||||
op.create_index("ix_training_configs_status", "training_configs", ["status"], unique=False)
|
||||
op.create_table(
|
||||
"training_config_resources",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("config_id", sa.Integer(), nullable=False),
|
||||
sa.Column("resource_type", sa.String(length=32), nullable=False),
|
||||
sa.Column("agent_guide_id", sa.Integer(), nullable=True),
|
||||
sa.Column("kb_document_version_id", sa.Integer(), nullable=True),
|
||||
sa.Column("inline_questions", sa.JSON(), nullable=True),
|
||||
sa.Column("title", sa.String(length=255), nullable=True),
|
||||
sa.Column("sort_order", sa.Integer(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["agent_guide_id"], ["agent_guides.id"]),
|
||||
sa.ForeignKeyConstraint(["config_id"], ["training_configs.id"], ondelete="CASCADE"),
|
||||
sa.ForeignKeyConstraint(["kb_document_version_id"], ["kb_document_versions.id"]),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index("ix_training_config_resources_config_id", "training_config_resources", ["config_id"], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index("ix_training_config_resources_config_id", table_name="training_config_resources")
|
||||
op.drop_table("training_config_resources")
|
||||
op.drop_index("ix_training_configs_status", table_name="training_configs")
|
||||
op.drop_index("ix_training_configs_training_type", table_name="training_configs")
|
||||
op.drop_table("training_configs")
|
||||
@@ -0,0 +1,56 @@
|
||||
"""add training runtime fields
|
||||
|
||||
Revision ID: 8b71d2e4a9c1
|
||||
Revises: 3d65de4125ed
|
||||
Create Date: 2026-08-06 16:20:00.000000
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "8b71d2e4a9c1"
|
||||
down_revision = "3d65de4125ed"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column(
|
||||
"training_records",
|
||||
sa.Column("training_version", sa.String(length=64), nullable=False, server_default="onboarding-v1"),
|
||||
)
|
||||
op.add_column(
|
||||
"training_records",
|
||||
sa.Column("exam_mode", sa.String(length=20), nullable=False, server_default="unified"),
|
||||
)
|
||||
op.add_column(
|
||||
"training_records",
|
||||
sa.Column("safety_stage", sa.String(length=20), nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"training_records",
|
||||
sa.Column("safety_progress", sa.JSON(), nullable=True),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_training_records_training_version"),
|
||||
"training_records",
|
||||
["training_version"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_training_records_safety_stage"),
|
||||
"training_records",
|
||||
["safety_stage"],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f("ix_training_records_safety_stage"), table_name="training_records")
|
||||
op.drop_index(op.f("ix_training_records_training_version"), table_name="training_records")
|
||||
op.drop_column("training_records", "safety_progress")
|
||||
op.drop_column("training_records", "safety_stage")
|
||||
op.drop_column("training_records", "exam_mode")
|
||||
op.drop_column("training_records", "training_version")
|
||||
+319
@@ -0,0 +1,319 @@
|
||||
"""
|
||||
backend/migrations/versions/b6c8d0e2f4a6_migrate_legacy_onboarding_training_config.py
|
||||
|
||||
用途:把员工培训 Agent 的旧版 extra_config.training_config 搬迁为 onboarding 培训配置。
|
||||
依赖:agents、agent_guides、training_configs、training_config_resources 表及 SQLAlchemy JSON 类型。
|
||||
逻辑:仅在 onboarding 尚不存在时选择最匹配的旧 Agent,复制结构化内容并关联其启用的入职视频与试题 PDF;降级不删除业务数据。
|
||||
|
||||
Revision ID: b6c8d0e2f4a6
|
||||
Revises: 7a8b9c0d1e2f
|
||||
Create Date: 2026-08-10 00:00:00.000000
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "b6c8d0e2f4a6"
|
||||
down_revision = "7a8b9c0d1e2f"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
ONBOARDING_TYPE = "onboarding"
|
||||
ONBOARDING_VERSION = "onboarding-v1"
|
||||
ONBOARDING_NAME = "入职培训"
|
||||
CONTENT_KEYS = (
|
||||
"summary_points",
|
||||
"summary_checklist",
|
||||
"employee_chat_suggested_questions",
|
||||
"hr_chat_suggested_questions",
|
||||
"question_bank",
|
||||
)
|
||||
|
||||
|
||||
def _as_dict(value: Any) -> dict[str, Any]:
|
||||
"""
|
||||
将数据库 JSON 值规范为字典,隔离历史空值或异常结构。
|
||||
|
||||
Args:
|
||||
value: SQLAlchemy 从 agents.extra_config 读取的 JSON 值。
|
||||
|
||||
Returns:
|
||||
dict[str, Any]: 字典原值;非字典统一返回空字典。
|
||||
"""
|
||||
return value if isinstance(value, dict) else {}
|
||||
|
||||
|
||||
def _has_meaningful_value(value: Any) -> bool:
|
||||
"""
|
||||
判断旧培训字段是否包含可供员工端使用的实质内容。
|
||||
|
||||
Args:
|
||||
value: 摘要、建议问题或题库等任意 JSON 值;空白字符串和空容器不算内容。
|
||||
|
||||
Returns:
|
||||
bool: 存在非空文本、非空容器或其它有效标量时返回 True。
|
||||
"""
|
||||
if value is None or value is False:
|
||||
return False
|
||||
if isinstance(value, str):
|
||||
return bool(value.strip())
|
||||
if isinstance(value, (list, tuple, set, dict)):
|
||||
return bool(value)
|
||||
return True
|
||||
|
||||
|
||||
def _legacy_training_config(extra_config: Any) -> dict[str, Any]:
|
||||
"""
|
||||
从 Agent extra_config 中读取旧版培训配置。
|
||||
|
||||
Args:
|
||||
extra_config: agents.extra_config JSON 值。
|
||||
|
||||
Returns:
|
||||
dict[str, Any]: training_config 字典;缺失或结构异常时返回空字典。
|
||||
"""
|
||||
return _as_dict(_as_dict(extra_config).get("training_config"))
|
||||
|
||||
|
||||
def _agent_rank(agent: sa.RowMapping) -> tuple[int, int, int, int]:
|
||||
"""
|
||||
对包含旧培训配置的 Agent 排序,优先选择启用的入职/员工培训应用。
|
||||
|
||||
Args:
|
||||
agent: 含 id、name、is_active、extra_config 的数据库行映射。
|
||||
|
||||
Returns:
|
||||
tuple[int, int, int, int]: 可降序比较的匹配分;最后以较小主键稳定决策。
|
||||
"""
|
||||
extra = _as_dict(agent["extra_config"])
|
||||
name = str(agent["name"] or "").replace(" ", "")
|
||||
onboarding_name = int("入职" in name or "员工培训" in name)
|
||||
non_safety_name = int("安全" not in name)
|
||||
workspace_enabled = int(extra.get("training_workspace_enabled") in (True, "true", "True", 1))
|
||||
active = int(bool(agent["is_active"]))
|
||||
return onboarding_name, non_safety_name, workspace_enabled + active, -int(agent["id"])
|
||||
|
||||
|
||||
def _select_legacy_agent(connection: sa.Connection, agents: sa.Table) -> sa.RowMapping | None:
|
||||
"""
|
||||
选择承载员工培训旧配置的 Agent,不依赖 PostgreSQL 专属 JSON 查询语法。
|
||||
|
||||
Args:
|
||||
connection: Alembic 当前事务连接。
|
||||
agents: 迁移内声明的 agents 轻量表对象。
|
||||
|
||||
Returns:
|
||||
RowMapping | None: 最匹配且含 training_config 的 Agent;没有候选时返回 None。
|
||||
"""
|
||||
rows = connection.execute(
|
||||
sa.select(agents.c.id, agents.c.name, agents.c.is_active, agents.c.extra_config)
|
||||
).mappings().all()
|
||||
candidates = [row for row in rows if _legacy_training_config(row["extra_config"])]
|
||||
return max(candidates, key=_agent_rank) if candidates else None
|
||||
|
||||
|
||||
def _normalize_pass_score(value: Any) -> int:
|
||||
"""
|
||||
将旧及格线约束到百分制范围,异常值回退为 90。
|
||||
|
||||
Args:
|
||||
value: training_config.pass_score 旧值。
|
||||
|
||||
Returns:
|
||||
int: 0 至 100 之间的整数。
|
||||
"""
|
||||
try:
|
||||
return max(0, min(100, int(value)))
|
||||
except (TypeError, ValueError):
|
||||
return 90
|
||||
|
||||
|
||||
def _build_settings(legacy_config: dict[str, Any]) -> dict[str, Any]:
|
||||
"""
|
||||
复制培训复盘和员工/HR 建议问题到新配置 settings。
|
||||
|
||||
Args:
|
||||
legacy_config: 旧 extra_config.training_config 字典。
|
||||
|
||||
Returns:
|
||||
dict[str, Any]: 保留原 JSON 结构的四类员工端配置。
|
||||
"""
|
||||
return {
|
||||
key: legacy_config[key]
|
||||
for key in CONTENT_KEYS
|
||||
if key != "question_bank" and key in legacy_config
|
||||
}
|
||||
|
||||
|
||||
def _insert_guide_resources(
|
||||
connection: sa.Connection,
|
||||
guides: sa.Table,
|
||||
resources: sa.Table,
|
||||
*,
|
||||
agent_id: int,
|
||||
config_id: int,
|
||||
now: datetime,
|
||||
) -> None:
|
||||
"""
|
||||
关联所选 Agent 已启用的入职视频与培训试题 PDF 指南。
|
||||
|
||||
Args:
|
||||
connection: Alembic 当前事务连接。
|
||||
guides: agent_guides 轻量表对象。
|
||||
resources: training_config_resources 轻量表对象。
|
||||
agent_id: 被选中员工培训 Agent 主键。
|
||||
config_id: 新建 onboarding 配置主键。
|
||||
now: 本次迁移统一使用的 UTC 时间。
|
||||
|
||||
Returns:
|
||||
None: 资源直接写入当前迁移事务。
|
||||
"""
|
||||
guide_rows = connection.execute(
|
||||
sa.select(guides.c.id, guides.c.file_name, guides.c.guide_usage, guides.c.sort_order)
|
||||
.where(
|
||||
guides.c.agent_id == agent_id,
|
||||
guides.c.status == 1,
|
||||
sa.or_(
|
||||
sa.and_(guides.c.guide_usage == "training_video", guides.c.file_type == "video"),
|
||||
sa.and_(guides.c.guide_usage == "training_exam_pdf", guides.c.file_type == "pdf"),
|
||||
),
|
||||
)
|
||||
.order_by(guides.c.sort_order.asc(), guides.c.id.asc())
|
||||
).mappings().all()
|
||||
for index, guide in enumerate(guide_rows):
|
||||
connection.execute(
|
||||
resources.insert().values(
|
||||
config_id=config_id,
|
||||
resource_type="agent_guide",
|
||||
agent_guide_id=guide["id"],
|
||||
title=guide["file_name"],
|
||||
sort_order=index,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""
|
||||
幂等创建 onboarding-v1,并从员工培训 Agent 搬迁旧配置与启用资料。
|
||||
|
||||
核心逻辑:已有任意 onboarding 配置立即跳过;否则选择旧 Agent,复制配置,
|
||||
有摘要、建议问题或题库时发布,没有实质内容时保留草稿状态。
|
||||
|
||||
Returns:
|
||||
None: 数据变更由 Alembic 当前事务提交。
|
||||
"""
|
||||
metadata = sa.MetaData()
|
||||
agents = sa.Table(
|
||||
"agents",
|
||||
metadata,
|
||||
sa.Column("id", sa.Integer),
|
||||
sa.Column("name", sa.String),
|
||||
sa.Column("extra_config", sa.JSON),
|
||||
sa.Column("is_active", sa.Boolean),
|
||||
)
|
||||
guides = sa.Table(
|
||||
"agent_guides",
|
||||
metadata,
|
||||
sa.Column("id", sa.Integer),
|
||||
sa.Column("agent_id", sa.Integer),
|
||||
sa.Column("file_name", sa.String),
|
||||
sa.Column("file_type", sa.String),
|
||||
sa.Column("guide_usage", sa.String),
|
||||
sa.Column("sort_order", sa.Integer),
|
||||
sa.Column("status", sa.Integer),
|
||||
)
|
||||
configs = sa.Table(
|
||||
"training_configs",
|
||||
metadata,
|
||||
sa.Column("id", sa.Integer, primary_key=True),
|
||||
sa.Column("training_type", sa.String),
|
||||
sa.Column("name", sa.String),
|
||||
sa.Column("version", sa.String),
|
||||
sa.Column("status", sa.String),
|
||||
sa.Column("pass_score", sa.Integer),
|
||||
sa.Column("settings", sa.JSON),
|
||||
sa.Column("published_at", sa.DateTime),
|
||||
sa.Column("created_at", sa.DateTime),
|
||||
sa.Column("updated_at", sa.DateTime),
|
||||
)
|
||||
resources = sa.Table(
|
||||
"training_config_resources",
|
||||
metadata,
|
||||
sa.Column("config_id", sa.Integer),
|
||||
sa.Column("resource_type", sa.String),
|
||||
sa.Column("agent_guide_id", sa.Integer),
|
||||
sa.Column("inline_questions", sa.JSON),
|
||||
sa.Column("title", sa.String),
|
||||
sa.Column("sort_order", sa.Integer),
|
||||
sa.Column("created_at", sa.DateTime),
|
||||
sa.Column("updated_at", sa.DateTime),
|
||||
)
|
||||
connection = op.get_bind()
|
||||
|
||||
existing_id = connection.scalar(
|
||||
sa.select(configs.c.id).where(configs.c.training_type == ONBOARDING_TYPE).limit(1)
|
||||
)
|
||||
if existing_id is not None:
|
||||
return
|
||||
|
||||
agent = _select_legacy_agent(connection, agents)
|
||||
legacy_config = _legacy_training_config(agent["extra_config"]) if agent is not None else {}
|
||||
has_content = any(_has_meaningful_value(legacy_config.get(key)) for key in CONTENT_KEYS)
|
||||
now = datetime.utcnow()
|
||||
config_id = connection.execute(
|
||||
configs.insert()
|
||||
.values(
|
||||
training_type=ONBOARDING_TYPE,
|
||||
name=ONBOARDING_NAME,
|
||||
version=ONBOARDING_VERSION,
|
||||
status="published" if has_content else "draft",
|
||||
pass_score=_normalize_pass_score(legacy_config.get("pass_score")),
|
||||
settings=_build_settings(legacy_config),
|
||||
published_at=now if has_content else None,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
.returning(configs.c.id)
|
||||
).scalar_one()
|
||||
|
||||
if agent is not None:
|
||||
_insert_guide_resources(
|
||||
connection,
|
||||
guides,
|
||||
resources,
|
||||
agent_id=int(agent["id"]),
|
||||
config_id=int(config_id),
|
||||
now=now,
|
||||
)
|
||||
question_bank = legacy_config.get("question_bank")
|
||||
if _has_meaningful_value(question_bank):
|
||||
connection.execute(
|
||||
resources.insert().values(
|
||||
config_id=config_id,
|
||||
resource_type="inline_questions",
|
||||
inline_questions=question_bank,
|
||||
title="入职培训题库",
|
||||
sort_order=1000,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""
|
||||
保留已搬迁或后续人工维护的 onboarding 业务数据。
|
||||
|
||||
Returns:
|
||||
None: 数据迁移不可安全区分自动创建和同名人工配置,因此不执行删除。
|
||||
"""
|
||||
return None
|
||||
@@ -0,0 +1,25 @@
|
||||
"""add required_duration to training_config_resources
|
||||
|
||||
Revision ID: b786eb92538e
|
||||
Revises: c1e2f3a4b5c6
|
||||
Create Date: 2026-08-11 17:03:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b786eb92538e'
|
||||
down_revision = 'c1e2f3a4b5c6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('training_config_resources', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('required_duration', sa.Integer(), nullable=False, server_default='0'))
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('training_config_resources', schema=None) as batch_op:
|
||||
batch_op.drop_column('required_duration')
|
||||
@@ -0,0 +1,38 @@
|
||||
"""新增培训资料级别字段。"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "c1e2f3a4b5c6"
|
||||
down_revision = "b6c8d0e2f4a6"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column("training_config_resources", sa.Column("training_level", sa.String(length=20), nullable=True))
|
||||
op.create_index("ix_training_config_resources_training_level", "training_config_resources", ["training_level"])
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE training_config_resources AS resource
|
||||
SET training_level = CASE guide.guide_usage
|
||||
WHEN 'training_safety_department_video' THEN 'department'
|
||||
WHEN 'training_safety_team_video' THEN 'team'
|
||||
ELSE 'company'
|
||||
END
|
||||
FROM agent_guides AS guide
|
||||
WHERE resource.agent_guide_id = guide.id
|
||||
AND resource.resource_type = 'agent_guide'
|
||||
AND resource.training_level IS NULL
|
||||
"""
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE training_config_resources SET training_level = 'company' "
|
||||
"WHERE resource_type = 'kb_document_version' AND training_level IS NULL"
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index("ix_training_config_resources_training_level", table_name="training_config_resources")
|
||||
op.drop_column("training_config_resources", "training_level")
|
||||
Reference in new issue
Block a user