20260423_0004_add_node_artifacts.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """add node artifacts
  2. Revision ID: 20260423_0004
  3. Revises: 20260423_0003
  4. Create Date: 2026-04-23 17:30:00
  5. """
  6. from collections.abc import Sequence
  7. import sqlalchemy as sa
  8. from alembic import op
  9. revision: str = "20260423_0004"
  10. down_revision: str | None = "20260423_0003"
  11. branch_labels: Sequence[str] | None = None
  12. depends_on: Sequence[str] | None = None
  13. def upgrade() -> None:
  14. op.create_table(
  15. "node_artifact",
  16. sa.Column("run_id", sa.String(length=36), nullable=False),
  17. sa.Column("node_run_id", sa.String(length=36), nullable=False),
  18. sa.Column("node_id", sa.String(length=128), nullable=False),
  19. sa.Column("artifact_type", sa.String(length=64), nullable=False),
  20. sa.Column("name", sa.String(length=128), nullable=False),
  21. sa.Column("mime_type", sa.String(length=128), nullable=True),
  22. sa.Column("content_text", sa.Text(), nullable=True),
  23. sa.Column("content_json", sa.JSON(), nullable=True),
  24. sa.Column("storage_uri", sa.String(length=512), nullable=True),
  25. sa.Column("size_bytes", sa.Integer(), nullable=True),
  26. sa.Column("id", sa.String(length=36), nullable=False),
  27. sa.Column("created_by", sa.String(length=36), nullable=True),
  28. sa.Column("updated_by", sa.String(length=36), nullable=True),
  29. sa.Column("created_time", sa.DateTime(), nullable=False),
  30. sa.Column("updated_time", sa.DateTime(), nullable=False),
  31. sa.Column("deleted_time", sa.DateTime(), nullable=True),
  32. sa.Column("version", sa.Integer(), nullable=False),
  33. sa.PrimaryKeyConstraint("id"))
  34. op.create_index("ix_node_artifact_run_id", "node_artifact", ["run_id"], unique=False)
  35. op.create_index("ix_node_artifact_node_run_id", "node_artifact", ["node_run_id"], unique=False)
  36. op.create_index("ix_node_artifact_node_id", "node_artifact", ["node_id"], unique=False)
  37. op.create_index("ix_node_artifact_artifact_type", "node_artifact", ["artifact_type"], unique=False)
  38. def downgrade() -> None:
  39. op.drop_index("ix_node_artifact_artifact_type", table_name="node_artifact")
  40. op.drop_index("ix_node_artifact_node_id", table_name="node_artifact")
  41. op.drop_index("ix_node_artifact_node_run_id", table_name="node_artifact")
  42. op.drop_index("ix_node_artifact_run_id", table_name="node_artifact")
  43. op.drop_table("node_artifact")