feat: миграция с булевых переменных на status для target_channel

This commit is contained in:
Artem Tsyrulnikov
2025-12-01 13:34:26 +03:00
parent f7754b707d
commit d117776e65
16 changed files with 56 additions and 67 deletions

View File

@@ -25,22 +25,12 @@ class TargetChannel(domain.Base):
username: Mapped[str | None] = mapped_column(index=True)
status: Mapped[TargetChannelStatus] = mapped_column(default=TargetChannelStatus.ACTIVE)
# Relationship with user
user_id: Mapped[uuid.UUID] = mapped_column(ForeignKey('user.id'), index=True)
user: Mapped['User'] = relationship(back_populates='target_channels')
# M2M relationship with external channels
external_channels: Mapped[list['ExternalChannel']] = relationship(
secondary='target_external_channel',
back_populates='target_channels',
)
creatives: Mapped[list['Creative']] = relationship(back_populates='target_channel')
@property
def is_active(self) -> bool:
return self.status == TargetChannelStatus.ACTIVE
@is_active.setter
def is_active(self, value: bool) -> None:
self.status = TargetChannelStatus.ACTIVE if value else TargetChannelStatus.INACTIVE