pricing
This commit is contained in:
55
migrations/versions/add_quota_fields_to_pricing_plans.py
Normal file
55
migrations/versions/add_quota_fields_to_pricing_plans.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""add quota fields to pricing plans
|
||||
|
||||
Revision ID: add_quota_fields
|
||||
Revises: add_pricing_plans_table
|
||||
Create Date: 2024-12-19 12:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'add_quota_fields'
|
||||
down_revision = 'add_pricing_plans_table'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
|
||||
# Check if columns already exist
|
||||
result = conn.execute(text("""
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'pricing_plans'
|
||||
AND column_name IN ('room_quota', 'conversation_quota', 'storage_quota_gb', 'manager_quota', 'admin_quota')
|
||||
"""))
|
||||
existing_columns = [row[0] for row in result.fetchall()]
|
||||
|
||||
# Add quota columns if they don't exist
|
||||
if 'room_quota' not in existing_columns:
|
||||
op.add_column('pricing_plans', sa.Column('room_quota', sa.Integer(), nullable=True, server_default='0'))
|
||||
|
||||
if 'conversation_quota' not in existing_columns:
|
||||
op.add_column('pricing_plans', sa.Column('conversation_quota', sa.Integer(), nullable=True, server_default='0'))
|
||||
|
||||
if 'storage_quota_gb' not in existing_columns:
|
||||
op.add_column('pricing_plans', sa.Column('storage_quota_gb', sa.Integer(), nullable=True, server_default='0'))
|
||||
|
||||
if 'manager_quota' not in existing_columns:
|
||||
op.add_column('pricing_plans', sa.Column('manager_quota', sa.Integer(), nullable=True, server_default='0'))
|
||||
|
||||
if 'admin_quota' not in existing_columns:
|
||||
op.add_column('pricing_plans', sa.Column('admin_quota', sa.Integer(), nullable=True, server_default='0'))
|
||||
|
||||
|
||||
def downgrade():
|
||||
# Remove quota columns
|
||||
op.drop_column('pricing_plans', 'admin_quota')
|
||||
op.drop_column('pricing_plans', 'manager_quota')
|
||||
op.drop_column('pricing_plans', 'storage_quota_gb')
|
||||
op.drop_column('pricing_plans', 'conversation_quota')
|
||||
op.drop_column('pricing_plans', 'room_quota')
|
||||
Reference in New Issue
Block a user