feat: subs and views
This commit is contained in:
51
migration/versions/e7ab0b38a8bf_add_subscriptions_table.py
Normal file
51
migration/versions/e7ab0b38a8bf_add_subscriptions_table.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""add subscriptions table
|
||||
|
||||
Revision ID: e7ab0b38a8bf
|
||||
Revises: 6517eda4a92e
|
||||
Create Date: 2025-11-10 16:48:25.310928
|
||||
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'e7ab0b38a8bf'
|
||||
down_revision: str | None = '6517eda4a92e'
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'subscriptions',
|
||||
sa.Column('purchase_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('user_telegram_id', sa.BigInteger(), nullable=False),
|
||||
sa.Column('username', sa.String(), nullable=True),
|
||||
sa.Column('invite_link', sa.String(), nullable=False),
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(
|
||||
['purchase_id'],
|
||||
['purchases.id'],
|
||||
),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
op.create_index(op.f('ix_subscriptions_invite_link'), 'subscriptions', ['invite_link'], unique=False)
|
||||
op.create_index(op.f('ix_subscriptions_purchase_id'), 'subscriptions', ['purchase_id'], unique=False)
|
||||
op.create_index(op.f('ix_subscriptions_user_telegram_id'), 'subscriptions', ['user_telegram_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_subscriptions_user_telegram_id'), table_name='subscriptions')
|
||||
op.drop_index(op.f('ix_subscriptions_purchase_id'), table_name='subscriptions')
|
||||
op.drop_index(op.f('ix_subscriptions_invite_link'), table_name='subscriptions')
|
||||
op.drop_table('subscriptions')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user