bot rafactor and bugfix
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from sqlalchemy import ForeignKey, String, func, DateTime
|
||||
from sqlalchemy import ForeignKey, String, func, DateTime, Column
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from app.db.session import Base
|
||||
|
||||
@@ -8,6 +8,7 @@ class Bot(Base):
|
||||
__tablename__ = "bots"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
bot_id: Mapped[int] = mapped_column() # Telegram bot ID
|
||||
owner_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"))
|
||||
name: Mapped[str] = mapped_column(String(64))
|
||||
username: Mapped[str | None] = mapped_column(String(64))
|
||||
@@ -15,3 +16,4 @@ class Bot(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
owner = relationship("User")
|
||||
channels = relationship("Channel", back_populates="bot")
|
||||
|
||||
Reference in New Issue
Block a user