Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions alembic/versions/deffbec94147_fix_emailattachment_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Fix EmailAttachment model.

Revision ID: deffbec94147
Revises: cc1fb6b21dc7
Create Date: 2026-04-22 05:45:13.102115

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel


# revision identifiers, used by Alembic.
revision: str = 'deffbec94147'
down_revision: Union[str, Sequence[str], None] = 'cc1fb6b21dc7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint('uq_email_attachment_webhook_email_id_attachment_id', 'email_attachment', ['webhook', 'email_id', 'attachment_id'])
# ### end Alembic commands ###


def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('uq_email_attachment_webhook_email_id_attachment_id', 'email_attachment', type_='unique')
# ### end Alembic commands ###
12 changes: 9 additions & 3 deletions app/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any

from pydantic import EmailStr, StrictBool, field_serializer, field_validator
from sqlmodel import JSON, Column, Field, SQLModel
from sqlmodel import JSON, Column, Field, SQLModel, UniqueConstraint

from app.settings import get_settings

Expand Down Expand Up @@ -78,8 +78,14 @@ class EmailAttachment(SQLModel, table=True):
s3_bucket: str = Field(max_length=64)
s3_key: str = Field(max_length=256)

class Config: # pyright: ignore[reportIncompatibleVariableOverride]
unique_together = [('webhook', 'email_id', 'attachment_id')]
__table_args__ = (
UniqueConstraint(
'webhook',
'email_id',
'attachment_id',
name='uq_email_attachment_webhook_email_id_attachment_id',
),
)

@field_serializer('created_at')
def serialize_created_at(self, value: datetime) -> str:
Expand Down
28 changes: 14 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ urls = { Repository = "https://github.com/lucas-six/fastapi-template/" }
dev = ["mypy>=1.18.2", "ruff>=0.14.6"]

[tool.setuptools]
py-modules = ["app"]
py-modules = ["app", "task"]

# [[tool.uv.index]]
# url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
Expand Down Expand Up @@ -170,19 +170,19 @@ module = "redis.*"
ignore_missing_imports = true

[tool.pyright]
include = ["app/**/*.py"]
exclude = [
".git",
"**/__pycache__",
".venv",
"**/*.egg-info",
".ruff_cache",
".mypy_cache",
".pytest_cache",
".tox",
"alembic/env.py",
"alembic/versions/*",
]
include = ["app", "task"]
# exclude = [
# ".git",
# "**/__pycache__",
# ".venv",
# "**/*.egg-info",
# ".ruff_cache",
# ".mypy_cache",
# ".pytest_cache",
# ".tox",
# "alembic/env.py",
# "alembic/versions/*",
# ]
reportGeneralTypeIssues = "none"
reportUnboundVariable = "none"
reportFunctionMemberAccess = "none"
Expand Down
Loading