feat: 导入 MemRelay 初始源码

This commit is contained in:
Nixevol
2026-09-23 21:40:46 +08:00
commit 0ade3bb318
167 changed files with 53511 additions and 0 deletions
@@ -0,0 +1,35 @@
"""Persist upload activity provenance."""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = "20260806_0013"
down_revision: str | Sequence[str] | None = "20260806_0012"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
with op.batch_alter_table("upload_tasks") as batch:
batch.add_column(sa.Column("usage_profile_id", sa.String(length=36), nullable=True))
batch.add_column(
sa.Column("origin", sa.String(length=20), nullable=False, server_default="user")
)
batch.create_index("ix_upload_tasks_usage_profile_id", ["usage_profile_id"])
batch.create_foreign_key(
"fk_upload_tasks_usage_profile_id",
"usage_profiles",
["usage_profile_id"],
["id"],
ondelete="SET NULL",
)
def downgrade() -> None:
with op.batch_alter_table("upload_tasks") as batch:
batch.drop_constraint("fk_upload_tasks_usage_profile_id", type_="foreignkey")
batch.drop_index("ix_upload_tasks_usage_profile_id")
batch.drop_column("origin")
batch.drop_column("usage_profile_id")