Jul 13 - Fix missing table

This commit is contained in:
2026-07-13 17:28:14 -04:00
parent 9ba7595920
commit b17e4bb209
@@ -0,0 +1,52 @@
"""reviews table (Phase 7)
Revision ID: b7f3c9a2d451
Revises: 482a73a8c5bb
Create Date: 2026-07-13 17:30:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b7f3c9a2d451'
down_revision = '482a73a8c5bb'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('reviews',
sa.Column('id', sa.BigInteger().with_variant(sa.Integer(), 'sqlite'), autoincrement=True, nullable=False),
sa.Column('listing_id', sa.BigInteger().with_variant(sa.Integer(), 'sqlite'), nullable=False),
sa.Column('author_id', sa.BigInteger().with_variant(sa.Integer(), 'sqlite'), nullable=False),
sa.Column('seller_id', sa.BigInteger().with_variant(sa.Integer(), 'sqlite'), nullable=False),
sa.Column('rating', sa.SmallInteger(), nullable=False),
sa.Column('body', sa.Text(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['listing_id'], ['listings.id'], ),
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
sa.ForeignKeyConstraint(['seller_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('listing_id', 'author_id', name='uq_review_listing_author'),
sa.CheckConstraint('rating BETWEEN 1 AND 5', name='ck_review_rating')
)
with op.batch_alter_table('reviews', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_reviews_listing_id'), ['listing_id'], unique=False)
batch_op.create_index(batch_op.f('ix_reviews_author_id'), ['author_id'], unique=False)
batch_op.create_index(batch_op.f('ix_reviews_seller_id'), ['seller_id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('reviews', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_reviews_seller_id'))
batch_op.drop_index(batch_op.f('ix_reviews_author_id'))
batch_op.drop_index(batch_op.f('ix_reviews_listing_id'))
op.drop_table('reviews')
# ### end Alembic commands ###