feat(schedule):cron支持图形,RoHS检核增加进度显示

This commit is contained in:
hugo committed 2026-06-15 13:42:15 +08:00
1 parent 6d0e78be81
commit f5aac9c893
46 files changed
+1987 -221

No files matched your search

@@ -0,0 +1,51 @@
"""add schedule_timezone to schedule_tasks
Revision ID: c9d0e1f2a3b4
Revises: b8c9d0e1f2a3
Create Date: 2026-06-12 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
revision = "c9d0e1f2a3b4"
down_revision = "b8c9d0e1f2a3"
branch_labels = None
depends_on = None
def upgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "schedule_tasks" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("schedule_tasks")}
if "schedule_timezone" not in columns:
with op.batch_alter_table("schedule_tasks", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"schedule_timezone",
sa.String(length=64),
nullable=True,
)
)
op.execute("UPDATE schedule_tasks SET schedule_timezone = 'Asia/Shanghai' WHERE schedule_timezone IS NULL")
with op.batch_alter_table("schedule_tasks", schema=None) as batch_op:
batch_op.alter_column(
"schedule_timezone",
existing_type=sa.String(length=64),
server_default=sa.text("'Asia/Shanghai'"),
nullable=False,
)
def downgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "schedule_tasks" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("schedule_tasks")}
if "schedule_timezone" in columns:
with op.batch_alter_table("schedule_tasks", schema=None) as batch_op:
batch_op.drop_column("schedule_timezone")
@@ -0,0 +1,46 @@
"""add run_id to chat_sessions
Revision ID: d0e2f3a4b5c6
Revises: c9d0e1f2a3b4
Create Date: 2026-06-12 12:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
revision = "d0e2f3a4b5c6"
down_revision = "c9d0e1f2a3b4"
branch_labels = None
depends_on = None
def upgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "chat_sessions" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("chat_sessions")}
if "run_id" not in columns:
with op.batch_alter_table("chat_sessions", schema=None) as batch_op:
batch_op.add_column(sa.Column("run_id", sa.Integer(), nullable=True))
batch_op.create_foreign_key(
"fk_chat_sessions_run_id_schedule_runs",
"schedule_runs",
["run_id"],
["id"],
)
batch_op.create_index("ix_chat_sessions_run_id", ["run_id"], unique=False)
def downgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "chat_sessions" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("chat_sessions")}
if "run_id" in columns:
with op.batch_alter_table("chat_sessions", schema=None) as batch_op:
batch_op.drop_index("ix_chat_sessions_run_id")
batch_op.drop_constraint("fk_chat_sessions_run_id_schedule_runs", type_="foreignkey")
batch_op.drop_column("run_id")
@@ -0,0 +1,46 @@
"""add run_id to chat_logs
Revision ID: e1f2a3b4c5d7
Revises: d0e2f3a4b5c6
Create Date: 2026-06-12 14:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
revision = "e1f2a3b4c5d7"
down_revision = "d0e2f3a4b5c6"
branch_labels = None
depends_on = None
def upgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "chat_logs" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("chat_logs")}
if "run_id" not in columns:
with op.batch_alter_table("chat_logs", schema=None) as batch_op:
batch_op.add_column(sa.Column("run_id", sa.Integer(), nullable=True))
batch_op.create_foreign_key(
"fk_chat_logs_run_id_schedule_runs",
"schedule_runs",
["run_id"],
["id"],
)
batch_op.create_index("ix_chat_logs_run_id", ["run_id"], unique=False)
def downgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "chat_logs" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("chat_logs")}
if "run_id" in columns:
with op.batch_alter_table("chat_logs", schema=None) as batch_op:
batch_op.drop_index("ix_chat_logs_run_id")
batch_op.drop_constraint("fk_chat_logs_run_id_schedule_runs", type_="foreignkey")
batch_op.drop_column("run_id")
@@ -0,0 +1,48 @@
"""drop run_id from chat_sessions
Revision ID: f2a3b4c5d6e8
Revises: e1f2a3b4c5d7
Create Date: 2026-06-12 16:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
revision = "f2a3b4c5d6e8"
down_revision = "e1f2a3b4c5d7"
branch_labels = None
depends_on = None
def upgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "chat_sessions" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("chat_sessions")}
if "run_id" not in columns:
return
with op.batch_alter_table("chat_sessions", schema=None) as batch_op:
batch_op.drop_index("ix_chat_sessions_run_id")
batch_op.drop_constraint("fk_chat_sessions_run_id_schedule_runs", type_="foreignkey")
batch_op.drop_column("run_id")
def downgrade():
bind = op.get_bind()
insp = sa.inspect(bind)
if "chat_sessions" not in set(insp.get_table_names()):
return
columns = {col["name"] for col in insp.get_columns("chat_sessions")}
if "run_id" in columns:
return
with op.batch_alter_table("chat_sessions", schema=None) as batch_op:
batch_op.add_column(sa.Column("run_id", sa.Integer(), nullable=True))
batch_op.create_foreign_key(
"fk_chat_sessions_run_id_schedule_runs",
"schedule_runs",
["run_id"],
["id"],
)
batch_op.create_index("ix_chat_sessions_run_id", ["run_id"], unique=False)