from typing import TYPE_CHECKING from uuid import UUID from tortoise import fields from .base import TimestampedModel if TYPE_CHECKING: from .target_channel import TargetChannel from .workspace import Workspace class ExternalChannel(TimestampedModel): id = fields.UUIDField(pk=True) telegram_id = fields.BigIntField(index=True) title = fields.CharField(max_length=255) username = fields.CharField(max_length=255, null=True, index=True) description = fields.TextField(null=True) subscribers_count = fields.IntField(null=True) workspace: fields.ForeignKeyRelation['Workspace'] = fields.ForeignKeyField( 'models.Workspace', related_name='external_channels', on_delete=fields.CASCADE, index=True ) if TYPE_CHECKING: target_channels: fields.ManyToManyRelation['TargetChannel'] workspace_id: UUID class Meta: table = 'external_channel'