sync update from LAN repo (source master @ 6e3f02a2)

This commit is contained in:
gozeros committed 2026-11-17 11:28:22 +08:00
1 parent 66a443e915
commit 6c25c89d93
431 files changed
+68511 -2240

No files matched your search

@@ -0,0 +1,82 @@
"""Add configurable visual-dashboard projects and data snapshots.
Revision ID: 20261110_01
Revises: 20261102_02
Create Date: 2026-11-10
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from deerflow.persistence.types import PortableLongText
revision = "20261110_01"
down_revision = "20261102_02"
branch_labels = None
depends_on = None
_PROJECTS = "visual_dashboard_projects"
_SNAPSHOTS = "visual_dashboard_snapshots"
def upgrade() -> None:
inspector = sa.inspect(op.get_bind())
if not inspector.has_table(_PROJECTS):
op.create_table(
_PROJECTS,
sa.Column("id", sa.String(length=64), primary_key=True),
sa.Column("slug", sa.String(length=64), nullable=False),
sa.Column("name", sa.String(length=191), nullable=False),
sa.Column("remarks", sa.String(length=512), nullable=True),
sa.Column("draft_canvas_json", PortableLongText(), nullable=False),
sa.Column("draft_bindings_json", PortableLongText(), nullable=False),
sa.Column("published_canvas_json", PortableLongText(), nullable=True),
sa.Column("published_bindings_json", PortableLongText(), nullable=True),
sa.Column("agent_id", sa.String(length=64), nullable=True),
sa.Column("chain_id", sa.String(length=64), nullable=True),
sa.Column("draft_revision", sa.Integer(), nullable=False),
sa.Column("published_revision", sa.Integer(), nullable=True),
sa.Column("created_by", sa.String(length=64), nullable=True),
sa.Column("updated_by", sa.String(length=64), nullable=True),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.UniqueConstraint("slug", name="uq_visual_dashboard_projects_slug"),
)
if not inspector.has_table(_SNAPSHOTS):
op.create_table(
_SNAPSHOTS,
sa.Column("id", sa.String(length=64), primary_key=True),
sa.Column("dashboard_id", sa.String(length=64), nullable=False),
sa.Column("task_id", sa.String(length=128), nullable=False),
sa.Column("data_key", sa.String(length=96), nullable=False),
sa.Column("payload_json", PortableLongText(), nullable=False),
sa.Column("schema_version", sa.String(length=32), nullable=False),
sa.Column("source_type", sa.String(length=32), nullable=False),
sa.Column("source_ref", sa.String(length=128), nullable=True),
sa.Column("refresh_status", sa.String(length=24), nullable=False),
sa.Column("error_message", PortableLongText(), nullable=True),
sa.Column("updated_by", sa.String(length=64), nullable=True),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.UniqueConstraint(
"dashboard_id",
"task_id",
"data_key",
name="uq_visual_dashboard_snapshots_key",
),
)
op.create_index(
"ix_visual_dashboard_snapshots_dashboard_id",
_SNAPSHOTS,
["dashboard_id"],
)
def downgrade() -> None:
inspector = sa.inspect(op.get_bind())
if inspector.has_table(_SNAPSHOTS):
op.drop_table(_SNAPSHOTS)
if inspector.has_table(_PROJECTS):
op.drop_table(_PROJECTS)
@@ -0,0 +1,79 @@
"""Replace the unused visual-dashboard tables with GoView projects and templates.
Revision ID: 20261110_02
Revises: 20261110_01
Create Date: 2026-11-10
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from deerflow.persistence.types import PortableLongText
revision = "20261110_02"
down_revision = "20261110_01"
branch_labels = None
depends_on = None
_OLD_SNAPSHOTS = "visual_dashboard_snapshots"
_OLD_PROJECTS = "visual_dashboard_projects"
_PROJECTS = "goview_projects"
_CONTENTS = "goview_project_contents"
_TEMPLATES = "goview_templates"
def upgrade() -> None:
inspector = sa.inspect(op.get_bind())
if inspector.has_table(_OLD_SNAPSHOTS):
op.drop_table(_OLD_SNAPSHOTS)
if inspector.has_table(_OLD_PROJECTS):
op.drop_table(_OLD_PROJECTS)
inspector = sa.inspect(op.get_bind())
if not inspector.has_table(_PROJECTS):
op.create_table(
_PROJECTS,
sa.Column("id", sa.String(length=64), primary_key=True),
sa.Column("project_name", sa.String(length=255), nullable=False),
sa.Column("remarks", sa.String(length=512), nullable=True),
sa.Column("state", sa.Integer(), nullable=False),
sa.Column("index_image", sa.String(length=1024), nullable=True),
sa.Column("owner_id", sa.String(length=64), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
)
op.create_index("ix_goview_projects_owner_id", _PROJECTS, ["owner_id"])
if not inspector.has_table(_CONTENTS):
op.create_table(
_CONTENTS,
sa.Column("project_id", sa.String(length=64), primary_key=True),
sa.Column("content_json", PortableLongText(), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
)
if not inspector.has_table(_TEMPLATES):
op.create_table(
_TEMPLATES,
sa.Column("id", sa.String(length=64), primary_key=True),
sa.Column("name", sa.String(length=255), nullable=False),
sa.Column("description", sa.String(length=512), nullable=True),
sa.Column("cover_image", sa.String(length=1024), nullable=True),
sa.Column("content_json", PortableLongText(), nullable=False),
sa.Column("owner_id", sa.String(length=64), nullable=True),
sa.Column("scope", sa.String(length=16), nullable=False),
sa.Column("is_builtin", sa.Boolean(), nullable=False),
sa.Column("sort_order", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
)
op.create_index("ix_goview_templates_owner_id", _TEMPLATES, ["owner_id"])
def downgrade() -> None:
inspector = sa.inspect(op.get_bind())
if inspector.has_table(_TEMPLATES):
op.drop_table(_TEMPLATES)
if inspector.has_table(_CONTENTS):
op.drop_table(_CONTENTS)
if inspector.has_table(_PROJECTS):
op.drop_table(_PROJECTS)
@@ -0,0 +1,33 @@
"""Drop the unused visual-dashboard tables left behind by 20261110_02.
Revision ID: 20261110_03
Revises: 20261110_02
Create Date: 2026-11-10
``20261110_02`` already drops these tables. This revision repeats the drop so a
database that reached ``20261110_02`` while the tables were still registered on
``Base.metadata`` does not keep them after ``create_all``.
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
revision = "20261110_03"
down_revision = "20261110_02"
branch_labels = None
depends_on = None
def upgrade() -> None:
bind = op.get_bind()
inspector = sa.inspect(bind)
if inspector.has_table("visual_dashboard_snapshots"):
op.drop_table("visual_dashboard_snapshots")
if inspector.has_table("visual_dashboard_projects"):
op.drop_table("visual_dashboard_projects")
def downgrade() -> None:
return None