market-assistant/backend/pipeline/migrations/0013_rebuild_pipelinejobcheckpoint.py
2026-04-14 17:12:03 +08:00

35 lines
1.2 KiB
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.

# 0012 曾标记为已应用,但部分环境上 checkpoint 表仍为旧版 schemastage/page_done 等)。
# 与当前 PipelineJobCheckpointphase/payload/hint_zh对齐删表后按 0012 预期 DDL 重建。
from django.db import migrations
_REBUILD_SQL = """
DROP TABLE IF EXISTS pipeline_pipelinejobcheckpoint;
CREATE TABLE "pipeline_pipelinejobcheckpoint" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"phase" varchar(32) NOT NULL,
"payload" text NOT NULL CHECK ((JSON_VALID("payload") OR "payload" IS NULL)),
"hint_zh" text NOT NULL,
"updated_at" datetime NOT NULL,
"job_id" bigint NOT NULL UNIQUE REFERENCES "pipeline_pipelinejob" ("id") DEFERRABLE INITIALLY DEFERRED
);
CREATE INDEX "pipeline_pipelinejobcheckpoint_phase_12e50a62" ON "pipeline_pipelinejobcheckpoint" ("phase");
"""
class Migration(migrations.Migration):
dependencies = [
("pipeline", "0012_job_pause_checkpoint"),
]
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[],
database_operations=[
migrations.RunSQL(_REBUILD_SQL, reverse_sql=migrations.RunSQL.noop),
],
),
]