Files
Hotel-Booking/Backend/alembic/versions/b1c4d7c154ec_add_enterprise_promotion_conditions.py
Iliyan Angelov 7667eb5eda update
2025-12-05 22:12:32 +02:00

63 lines
3.3 KiB
Python

"""add_enterprise_promotion_conditions
Revision ID: b1c4d7c154ec
Revises: 87e29a777cb3
Create Date: 2025-12-05 20:22:39.893584
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = 'b1c4d7c154ec'
down_revision = '87e29a777cb3'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Add enterprise promotion condition columns
op.add_column('promotions', sa.Column('min_stay_days', sa.Integer(), nullable=True, comment='Minimum number of nights required for booking'))
op.add_column('promotions', sa.Column('max_stay_days', sa.Integer(), nullable=True, comment='Maximum number of nights allowed for booking'))
op.add_column('promotions', sa.Column('advance_booking_days', sa.Integer(), nullable=True, comment='Minimum days in advance the booking must be made'))
op.add_column('promotions', sa.Column('max_advance_booking_days', sa.Integer(), nullable=True, comment='Maximum days in advance the booking can be made'))
# Day of week restrictions (stored as JSON)
op.add_column('promotions', sa.Column('allowed_check_in_days', sa.JSON(), nullable=True, comment='Allowed check-in days of week (0-6, Mon-Sun)'))
op.add_column('promotions', sa.Column('allowed_check_out_days', sa.JSON(), nullable=True, comment='Allowed check-out days of week (0-6, Mon-Sun)'))
# Room type restrictions (stored as JSON arrays)
op.add_column('promotions', sa.Column('allowed_room_type_ids', sa.JSON(), nullable=True, comment='Allowed room type IDs (JSON array)'))
op.add_column('promotions', sa.Column('excluded_room_type_ids', sa.JSON(), nullable=True, comment='Excluded room type IDs (JSON array)'))
# Guest count restrictions
op.add_column('promotions', sa.Column('min_guests', sa.Integer(), nullable=True, comment='Minimum number of guests required'))
op.add_column('promotions', sa.Column('max_guests', sa.Integer(), nullable=True, comment='Maximum number of guests allowed'))
# Customer type restrictions
op.add_column('promotions', sa.Column('first_time_customer_only', sa.Boolean(), nullable=False, server_default='0', comment='Only for first-time customers'))
op.add_column('promotions', sa.Column('repeat_customer_only', sa.Boolean(), nullable=False, server_default='0', comment='Only for returning customers'))
# Blackout dates (stored as JSON array)
op.add_column('promotions', sa.Column('blackout_dates', sa.JSON(), nullable=True, comment='Blackout dates when promotion doesn\'t apply (JSON array of YYYY-MM-DD)'))
def downgrade() -> None:
# Remove all added columns
op.drop_column('promotions', 'blackout_dates')
op.drop_column('promotions', 'repeat_customer_only')
op.drop_column('promotions', 'first_time_customer_only')
op.drop_column('promotions', 'max_guests')
op.drop_column('promotions', 'min_guests')
op.drop_column('promotions', 'excluded_room_type_ids')
op.drop_column('promotions', 'allowed_room_type_ids')
op.drop_column('promotions', 'allowed_check_out_days')
op.drop_column('promotions', 'allowed_check_in_days')
op.drop_column('promotions', 'max_advance_booking_days')
op.drop_column('promotions', 'advance_booking_days')
op.drop_column('promotions', 'max_stay_days')
op.drop_column('promotions', 'min_stay_days')