feat: handle unsubscribe
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""add subscription status and unsubscribed_at
|
||||
|
||||
Revision ID: 3b8259700b61
|
||||
Revises: f05f85d10837
|
||||
Create Date: 2025-11-25 18:45:04.642105
|
||||
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '3b8259700b61'
|
||||
down_revision: str | None = 'f05f85d10837'
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
# Создаём enum тип явно
|
||||
subscription_status = sa.Enum('ACTIVE', 'UNSUBSCRIBED', name='subscriptionstatus')
|
||||
subscription_status.create(op.get_bind(), checkfirst=True)
|
||||
|
||||
op.add_column(
|
||||
'subscription',
|
||||
sa.Column('status', subscription_status, nullable=False, server_default='ACTIVE'),
|
||||
)
|
||||
op.add_column('subscription', sa.Column('unsubscribed_at', sa.DateTime(timezone=True), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('subscription', 'unsubscribed_at')
|
||||
op.drop_column('subscription', 'status')
|
||||
|
||||
# Удаляем enum тип
|
||||
sa.Enum(name='subscriptionstatus').drop(op.get_bind(), checkfirst=True)
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user