Files
docqube_backend/alembic/versions/4a9dc50ce4af_drop_price_display.py
2026-09-08 11:00:05 +05:30

34 lines
1.2 KiB
Python

"""drop_price_display
Revision ID: 4a9dc50ce4af
Revises: 2b4c62c1cf35
Create Date: 2026-08-20 11:40:33.072200
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '4a9dc50ce4af'
down_revision: Union[str, None] = '2b4c62c1cf35'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute("UPDATE plans SET price_amount = CAST(SUBSTRING(price_display FROM '[\d.]+') AS NUMERIC) WHERE price_display IS NOT NULL AND price_display != 'Contact Us' AND price_amount IS NULL")
op.drop_column('plans', 'price_display')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('plans', sa.Column('price_display', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
op.execute("UPDATE plans SET price_display = '$' || price_amount WHERE price_amount IS NOT NULL")
op.execute("UPDATE plans SET price_display = 'Contact Us' WHERE price_amount IS NULL")
# ### end Alembic commands ###