Партии: фото в общем комментарии (до 10), загрузка при завершении
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""Медиа партии: таблица match_attachments (фото в общем комментарии).
|
||||
|
||||
Идемпотентна (как 0006): на свежей БД таблицу создаёт 0001 (create_all); на существующей —
|
||||
create_table здесь.
|
||||
|
||||
Revision ID: 0007_match_attachments
|
||||
Revises: 0006_group_invitations
|
||||
Create Date: 2026-06-17
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0007_match_attachments"
|
||||
down_revision: Union[str, None] = "0006_group_invitations"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
insp = inspect(bind)
|
||||
if "match_attachments" in insp.get_table_names():
|
||||
return
|
||||
op.create_table(
|
||||
"match_attachments",
|
||||
sa.Column("id", sa.Integer(), primary_key=True),
|
||||
sa.Column(
|
||||
"match_id",
|
||||
sa.Integer(),
|
||||
sa.ForeignKey("matches.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column(
|
||||
"uploaded_by",
|
||||
sa.Integer(),
|
||||
sa.ForeignKey("users.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
),
|
||||
sa.Column("kind", sa.String(16), nullable=False, server_default="photo"),
|
||||
sa.Column("storage_path", sa.String(255), nullable=False),
|
||||
sa.Column("mime_type", sa.String(64), nullable=False),
|
||||
sa.Column("size_bytes", sa.Integer(), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
)
|
||||
op.create_index("ix_match_attachments_match_id", "match_attachments", ["match_id"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
insp = inspect(bind)
|
||||
if "match_attachments" in insp.get_table_names():
|
||||
op.drop_table("match_attachments")
|
||||
Reference in New Issue
Block a user