"""empty message

Revision ID: 211dcf5ba407
Revises: 
Create Date: 2025-12-16 15:12:41.200547

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '211dcf5ba407'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('email_verifications',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('email', sa.String(length=120), nullable=False),
    sa.Column('code', sa.String(length=6), nullable=False),
    sa.Column('attempts', sa.Integer(), nullable=True),
    sa.Column('is_used', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('expires_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('email_verifications', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_email_verifications_email'), ['email'], unique=False)

    op.create_table('users',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('first_name', sa.String(length=50), nullable=False),
    sa.Column('last_name', sa.String(length=50), nullable=False),
    sa.Column('username', sa.String(length=50), nullable=False),
    sa.Column('email', sa.String(length=120), nullable=False),
    sa.Column('phone_number', sa.String(length=20), nullable=True),
    sa.Column('date_of_birth', sa.Date(), nullable=True),
    sa.Column('address', sa.Text(), nullable=True),
    sa.Column('city', sa.String(length=100), nullable=True),
    sa.Column('country', sa.String(length=100), nullable=True),
    sa.Column('password_hash', sa.String(length=255), nullable=False),
    sa.Column('is_email_verified', sa.Boolean(), nullable=True),
    sa.Column('role', sa.Enum('CUSTOMER', 'OWNER', 'ADMIN', name='userrole'), nullable=False),
    sa.Column('profile_image', sa.String(length=255), nullable=True),
    sa.Column('is_active', sa.Boolean(), nullable=True),
    sa.Column('is_verified', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('phone_number')
    )
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_users_email'), ['email'], unique=True)
        batch_op.create_index(batch_op.f('ix_users_username'), ['username'], unique=True)

    op.create_table('cars',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('owner_id', sa.String(length=36), nullable=False),
    sa.Column('title', sa.String(length=200), nullable=False),
    sa.Column('description', sa.Text(), nullable=False),
    sa.Column('make', sa.String(length=50), nullable=False),
    sa.Column('model', sa.String(length=50), nullable=False),
    sa.Column('year', sa.Integer(), nullable=False),
    sa.Column('category', sa.String(length=50), nullable=True),
    sa.Column('color', sa.String(length=30), nullable=True),
    sa.Column('license_plate', sa.String(length=20), nullable=False),
    sa.Column('seats', sa.Integer(), nullable=False),
    sa.Column('transmission', sa.Enum('MANUAL', 'AUTOMATIC', name='transmissiontype'), nullable=False),
    sa.Column('fuel_type', sa.Enum('PETROL', 'DIESEL', 'ELECTRIC', 'HYBRID', name='fueltype'), nullable=False),
    sa.Column('mileage', sa.Integer(), nullable=True),
    sa.Column('engine_capacity', sa.String(length=20), nullable=True),
    sa.Column('price_per_day', sa.Numeric(precision=10, scale=2), nullable=False),
    sa.Column('price_per_week', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('price_per_month', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('price_per_year', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('currency', sa.String(length=3), nullable=False),
    sa.Column('security_deposit', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('city', sa.String(length=100), nullable=False),
    sa.Column('country', sa.String(length=100), nullable=False),
    sa.Column('pickup_location', sa.Text(), nullable=True),
    sa.Column('latitude', sa.Float(), nullable=True),
    sa.Column('longitude', sa.Float(), nullable=True),
    sa.Column('features', sa.JSON(), nullable=True),
    sa.Column('insurance_included', sa.Boolean(), nullable=False),
    sa.Column('fuel_policy', sa.String(length=50), nullable=True),
    sa.Column('minimum_age', sa.Integer(), nullable=False),
    sa.Column('driving_license_required', sa.Boolean(), nullable=False),
    sa.Column('rental_terms', sa.Text(), nullable=True),
    sa.Column('is_available', sa.Boolean(), nullable=False),
    sa.Column('is_verified', sa.Boolean(), nullable=False),
    sa.Column('status', sa.Enum('ACTIVE', 'INACTIVE', 'UNDER_REVIEW', 'MAINTENANCE', name='carstatus'), nullable=False),
    sa.Column('rating_average', sa.Float(), nullable=False),
    sa.Column('review_count', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('cars', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_cars_city'), ['city'], unique=False)
        batch_op.create_index(batch_op.f('ix_cars_country'), ['country'], unique=False)
        batch_op.create_index(batch_op.f('ix_cars_license_plate'), ['license_plate'], unique=True)
        batch_op.create_index(batch_op.f('ix_cars_make'), ['make'], unique=False)
        batch_op.create_index(batch_op.f('ix_cars_owner_id'), ['owner_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_cars_year'), ['year'], unique=False)

    op.create_table('houses',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('owner_id', sa.String(length=36), nullable=False),
    sa.Column('title', sa.String(length=200), nullable=False),
    sa.Column('description', sa.Text(), nullable=False),
    sa.Column('category', sa.String(length=50), nullable=True),
    sa.Column('price_per_day', sa.Numeric(precision=10, scale=2), nullable=False),
    sa.Column('price_per_week', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('price_per_month', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('price_per_year', sa.Numeric(precision=10, scale=2), nullable=True),
    sa.Column('currency', sa.String(length=3), nullable=False),
    sa.Column('address', sa.Text(), nullable=False),
    sa.Column('city', sa.String(length=100), nullable=False),
    sa.Column('country', sa.String(length=100), nullable=False),
    sa.Column('latitude', sa.Float(), nullable=True),
    sa.Column('longitude', sa.Float(), nullable=True),
    sa.Column('bedrooms', sa.Integer(), nullable=False),
    sa.Column('bathrooms', sa.Integer(), nullable=False),
    sa.Column('max_guests', sa.Integer(), nullable=False),
    sa.Column('square_feet', sa.Integer(), nullable=True),
    sa.Column('floor_number', sa.Integer(), nullable=True),
    sa.Column('features', sa.JSON(), nullable=True),
    sa.Column('house_rules', sa.Text(), nullable=True),
    sa.Column('is_available', sa.Boolean(), nullable=False),
    sa.Column('is_verified', sa.Boolean(), nullable=False),
    sa.Column('status', sa.Enum('ACTIVE', 'INACTIVE', 'UNDER_REVIEW', name='housestatus'), nullable=False),
    sa.Column('rating_average', sa.Float(), nullable=False),
    sa.Column('review_count', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('houses', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_houses_city'), ['city'], unique=False)
        batch_op.create_index(batch_op.f('ix_houses_country'), ['country'], unique=False)
        batch_op.create_index(batch_op.f('ix_houses_owner_id'), ['owner_id'], unique=False)

    op.create_table('car_images',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('car_id', sa.String(length=36), nullable=False),
    sa.Column('image_url', sa.String(length=500), nullable=False),
    sa.Column('is_primary', sa.Boolean(), nullable=False),
    sa.Column('display_order', sa.Integer(), nullable=False),
    sa.Column('caption', sa.String(length=200), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['car_id'], ['cars.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('car_images', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_car_images_car_id'), ['car_id'], unique=False)

    op.create_table('house_images',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('house_id', sa.String(length=36), nullable=False),
    sa.Column('image_url', sa.String(length=500), nullable=False),
    sa.Column('is_primary', sa.Boolean(), nullable=False),
    sa.Column('display_order', sa.Integer(), nullable=False),
    sa.Column('caption', sa.String(length=200), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['house_id'], ['houses.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('house_images', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_house_images_house_id'), ['house_id'], unique=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('house_images', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_house_images_house_id'))

    op.drop_table('house_images')
    with op.batch_alter_table('car_images', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_car_images_car_id'))

    op.drop_table('car_images')
    with op.batch_alter_table('houses', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_houses_owner_id'))
        batch_op.drop_index(batch_op.f('ix_houses_country'))
        batch_op.drop_index(batch_op.f('ix_houses_city'))

    op.drop_table('houses')
    with op.batch_alter_table('cars', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_cars_year'))
        batch_op.drop_index(batch_op.f('ix_cars_owner_id'))
        batch_op.drop_index(batch_op.f('ix_cars_make'))
        batch_op.drop_index(batch_op.f('ix_cars_license_plate'))
        batch_op.drop_index(batch_op.f('ix_cars_country'))
        batch_op.drop_index(batch_op.f('ix_cars_city'))

    op.drop_table('cars')
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_users_username'))
        batch_op.drop_index(batch_op.f('ix_users_email'))

    op.drop_table('users')
    with op.batch_alter_table('email_verifications', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_email_verifications_email'))

    op.drop_table('email_verifications')
    # ### end Alembic commands ###
