Add migration for Hotel

This commit is contained in:
Backend IM Bot 2025-03-25 23:17:54 +00:00
parent fc76c60e4a
commit e079422f2f

View File

@ -0,0 +1,46 @@
"""create hotels table
Revision ID: b2c3d4e5f6g7
Revises:
Create Date: 2024-01-09 10:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import func
import uuid
# revision identifiers
revision = 'b2c3d4e5f6g7'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'hotels',
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
sa.Column('name', sa.String(), nullable=False, index=True),
sa.Column('description', sa.Text()),
sa.Column('location', sa.String(), nullable=False),
sa.Column('address', sa.String(), nullable=False),
sa.Column('rating', sa.Float(), nullable=False),
sa.Column('price_per_night', sa.Float(), nullable=False),
sa.Column('amenities', sa.Text()),
sa.Column('images', sa.Text()),
sa.Column('contact_number', sa.String()),
sa.Column('email', sa.String()),
sa.Column('website', sa.String()),
sa.Column('total_rooms', sa.Integer()),
sa.Column('is_active', sa.Boolean(), default=True),
sa.Column('latitude', sa.Float()),
sa.Column('longitude', sa.Float()),
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
sa.PrimaryKeyConstraint('id')
)
op.create_index('ix_hotels_name', 'hotels', ['name'])
def downgrade():
op.drop_index('ix_hotels_name', 'hotels')
op.drop_table('hotels')