
This has exposed an interesting amount of bugs and stopped throwing type errors every 5 seconds It's worth noting that not all models are fully typed, that is, we have `Mapped[Any]` in some places where a narrower type would be nice. Upgrading to SQLA2 we don't *need* this, but it is helpful and makes error checking reliable.
15 lines
493 B
Python
15 lines
493 B
Python
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from sqlalchemy.sql.sqltypes import String
|
|
from sqlalchemy.schema import Index
|
|
from files.classes.base import Base
|
|
|
|
class BannedDomain(Base):
|
|
__tablename__ = "banneddomains"
|
|
domain: Mapped[str] = mapped_column(String, primary_key=True)
|
|
reason: Mapped[str | None] = mapped_column(String, nullable=False)
|
|
Index(
|
|
'domains_domain_trgm_idx',
|
|
domain,
|
|
postgresql_using='gin',
|
|
postgresql_ops={'description':'gin_trgm_ops'}
|
|
)
|