- ListingDecision model with unique constraint on (user_id, listing_id, listing_type)
- Alembic migration for listingdecision table
- DecisionRepository with dialect-aware upsert (MySQL/SQLite)
- DecisionService with input validation
- Decision API routes: PUT/GET/DELETE on /api/decisions
- GET /api/listing/{id}/detail endpoint extracting full property info from additional_info
- Add listing ID to GeoJSON feature properties
- Decision filtering on GeoJSON stream endpoint (decision_filter param)
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
"""add listing decision
|
|
|
|
Revision ID: d7e8f9a0b1c2
|
|
Revises: c5d6e7f8a9b0
|
|
Create Date: 2026-02-21 12:00:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'd7e8f9a0b1c2'
|
|
down_revision: Union[str, None] = 'c5d6e7f8a9b0'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Create listingdecision table."""
|
|
op.create_table('listingdecision',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('listing_id', sa.Integer(), nullable=False),
|
|
sa.Column('listing_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('decision', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True,
|
|
server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True,
|
|
server_default=sa.func.now()),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id']),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('user_id', 'listing_id', 'listing_type',
|
|
name='uq_decision_user_listing_type'),
|
|
)
|
|
op.create_index(op.f('ix_listingdecision_user_id'),
|
|
'listingdecision', ['user_id'], unique=False)
|
|
op.create_index(op.f('ix_listingdecision_listing_id'),
|
|
'listingdecision', ['listing_id'], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Drop listingdecision table."""
|
|
op.drop_index(op.f('ix_listingdecision_listing_id'), table_name='listingdecision')
|
|
op.drop_index(op.f('ix_listingdecision_user_id'), table_name='listingdecision')
|
|
op.drop_table('listingdecision')
|