50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
"""add_trade_proposals_table
|
|
|
|
Revision ID: cfac344e21b4
|
|
Revises: b989aae3e37d
|
|
Create Date: 2026-03-28 22:01:28.188084
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'cfac344e21b4'
|
|
down_revision: Union[str, Sequence[str], None] = 'b989aae3e37d'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('trade_proposals',
|
|
sa.Column('id', sa.UUID(), nullable=False),
|
|
sa.Column('proposer_id', sa.UUID(), nullable=False),
|
|
sa.Column('recipient_id', sa.UUID(), nullable=False),
|
|
sa.Column('offered_card_ids', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
|
|
sa.Column('requested_card_id', sa.UUID(), nullable=False),
|
|
sa.Column('status', sa.String(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
|
sa.ForeignKeyConstraint(['proposer_id'], ['users.id'], ),
|
|
sa.ForeignKeyConstraint(['recipient_id'], ['users.id'], ),
|
|
sa.ForeignKeyConstraint(['requested_card_id'], ['cards.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index('ix_trade_proposals_proposer_status', 'trade_proposals', ['proposer_id', 'status'])
|
|
op.create_index('ix_trade_proposals_recipient_status', 'trade_proposals', ['recipient_id', 'status'])
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index('ix_trade_proposals_proposer_status', 'trade_proposals')
|
|
op.drop_index('ix_trade_proposals_recipient_status', 'trade_proposals')
|
|
op.drop_table('trade_proposals')
|
|
# ### end Alembic commands ###
|