6641eba9df
replace monolithic migration with ordered scripts, include profiles/sessions in migration, and verify full downgrade/upgrade cycle for clean Supabase bootstrap
59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
from enum import Enum
|
|
|
|
from sqlalchemy import Integer, String
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from core.db.base import Base, TimestampMixin
|
|
|
|
|
|
class SubscriptionStatus(str, Enum):
|
|
ACTIVE = "active"
|
|
PAUSED = "paused"
|
|
UNSUBSCRIBED = "unsubscribed"
|
|
|
|
|
|
class NotifyLevel(str, Enum):
|
|
ALL = "all"
|
|
MENTIONS = "mentions"
|
|
NONE = "none"
|
|
|
|
|
|
class ScheduleSubscription(TimestampMixin, Base):
|
|
__tablename__: str = "schedule_subscriptions"
|
|
__table_args__ = {"extend_existing": True}
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
|
|
)
|
|
item_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
nullable=False,
|
|
)
|
|
subscriber_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
nullable=False,
|
|
)
|
|
permission: Mapped[int] = mapped_column(
|
|
Integer,
|
|
nullable=False,
|
|
default=1,
|
|
)
|
|
notify_level: Mapped[NotifyLevel] = mapped_column(
|
|
String(20),
|
|
nullable=False,
|
|
default=NotifyLevel.ALL,
|
|
)
|
|
status: Mapped[SubscriptionStatus] = mapped_column(
|
|
String(20),
|
|
nullable=False,
|
|
default=SubscriptionStatus.ACTIVE,
|
|
)
|
|
created_by: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
nullable=True,
|
|
)
|