"""Sync shuttle fields Revision ID: 3fe72cd3f722 Revises: 5caf8ba3ed4d Create Date: 2026-02-15 16:20:02.326548 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = '3fe72cd3f722' down_revision: Union[str, None] = '5caf8ba3ed4d' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # 1. Reparar valores nulos existentes en driver_profiles antes de restringir op.execute("UPDATE driver_profiles SET speaks_english = FALSE WHERE speaks_english IS NULL") op.alter_column('driver_profiles', 'speaks_english', existing_type=sa.BOOLEAN(), nullable=False) # 2. Asegurar campos de Shuttles (solo si no existen, usando try/except o verificando primero) # Nota: Alembic no los detectó, pero los forzamos por si acaso with op.get_context().autocommit_block(): op.execute("ALTER TABLE shuttles ADD COLUMN IF NOT EXISTS company_name VARCHAR") op.execute("ALTER TABLE shuttles ADD COLUMN IF NOT EXISTS trip_type VARCHAR DEFAULT 'one_way'") op.execute("ALTER TABLE shuttles ADD COLUMN IF NOT EXISTS price_private_trip FLOAT") op.execute("ALTER TABLE shuttles ADD COLUMN IF NOT EXISTS departure_times VARCHAR") op.execute("ALTER TABLE shuttles ADD COLUMN IF NOT EXISTS contact_whatsapp VARCHAR") op.execute("ALTER TABLE shuttles ADD COLUMN IF NOT EXISTS estimated_duration VARCHAR") def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.alter_column('driver_profiles', 'speaks_english', existing_type=sa.BOOLEAN(), nullable=True) # ### end Alembic commands ###