54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
"""add compose_attachments
|
|||
|
|
|
||
|
|
Files uploaded for outgoing mail (the compose "Attach" action). Referenced by a
|
||
|
|
draft's payload.attachment_ids and assembled into the MIME at send time.
|
||
|
|
|
||
|
|
Revision ID: 0005
|
||
|
|
Revises: 0004
|
||
|
|
Create Date: 2026-07-17
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from collections.abc import Sequence
|
||
|
|
|
||
|
|
import sqlalchemy as sa
|
||
|
|
from alembic import op
|
||
|
|
|
||
|
|
revision: str = "0005"
|
||
|
|
down_revision: str | None = "0004"
|
||
|
|
branch_labels: str | Sequence[str] | None = None
|
||
|
|
depends_on: str | Sequence[str] | None = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.create_table(
|
||
|
|
"compose_attachments",
|
||
|
|
sa.Column(
|
||
|
|
"id",
|
||
|
|
sa.dialects.postgresql.UUID(as_uuid=True),
|
||
|
|
primary_key=True,
|
||
|
|
server_default=sa.text("gen_random_uuid()"),
|
||
|
|
),
|
||
|
|
sa.Column(
|
||
|
|
"user_id",
|
||
|
|
sa.dialects.postgresql.UUID(as_uuid=True),
|
||
|
|
sa.ForeignKey("users.id", ondelete="CASCADE"),
|
||
|
|
nullable=False,
|
||
|
|
),
|
||
|
|
sa.Column("filename", sa.Text(), nullable=False),
|
||
|
|
sa.Column("mime_type", sa.Text(), nullable=False),
|
||
|
|
sa.Column("size_bytes", sa.Integer(), nullable=False),
|
||
|
|
sa.Column("blob_sha256", sa.Text(), nullable=False),
|
||
|
|
sa.Column(
|
||
|
|
"created_at",
|
||
|
|
sa.TIMESTAMP(timezone=True),
|
||
|
|
nullable=False,
|
||
|
|
server_default=sa.text("now()"),
|
||
|
|
),
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.drop_table("compose_attachments")
|