Add subcription feature 2
This commit is contained in:
@@ -204,8 +204,8 @@ def upgrade() -> None:
|
||||
sa.Column('trial_ends_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('cancelled_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('cancellation_effective_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('stripe_subscription_id', sa.String(255), nullable=True),
|
||||
sa.Column('stripe_customer_id', sa.String(255), nullable=True),
|
||||
sa.Column('subscription_id', sa.String(255), nullable=True),
|
||||
sa.Column('customer_id', sa.String(255), nullable=True),
|
||||
# Basic resource limits
|
||||
sa.Column('max_users', sa.Integer(), nullable=True),
|
||||
sa.Column('max_locations', sa.Integer(), nullable=True),
|
||||
@@ -284,24 +284,24 @@ def upgrade() -> None:
|
||||
WHERE status = 'active'
|
||||
""")
|
||||
|
||||
# Index 5: Stripe subscription lookup (for webhook processing)
|
||||
if not _index_exists(connection, 'idx_subscriptions_stripe_sub_id'):
|
||||
# Index 5: Subscription ID lookup (for webhook processing)
|
||||
if not _index_exists(connection, 'idx_subscriptions_subscription_id'):
|
||||
op.create_index(
|
||||
'idx_subscriptions_stripe_sub_id',
|
||||
'idx_subscriptions_subscription_id',
|
||||
'subscriptions',
|
||||
['stripe_subscription_id'],
|
||||
['subscription_id'],
|
||||
unique=False,
|
||||
postgresql_where=sa.text("stripe_subscription_id IS NOT NULL")
|
||||
postgresql_where=sa.text("subscription_id IS NOT NULL")
|
||||
)
|
||||
|
||||
# Index 6: Stripe customer lookup (for customer-related operations)
|
||||
if not _index_exists(connection, 'idx_subscriptions_stripe_customer_id'):
|
||||
# Index 6: Customer ID lookup (for customer-related operations)
|
||||
if not _index_exists(connection, 'idx_subscriptions_customer_id'):
|
||||
op.create_index(
|
||||
'idx_subscriptions_stripe_customer_id',
|
||||
'idx_subscriptions_customer_id',
|
||||
'subscriptions',
|
||||
['stripe_customer_id'],
|
||||
['customer_id'],
|
||||
unique=False,
|
||||
postgresql_where=sa.text("stripe_customer_id IS NOT NULL")
|
||||
postgresql_where=sa.text("customer_id IS NOT NULL")
|
||||
)
|
||||
|
||||
# Index 7: User ID for tenant linking
|
||||
@@ -481,8 +481,8 @@ def downgrade() -> None:
|
||||
# Drop subscriptions table indexes first
|
||||
op.drop_index('idx_subscriptions_linking_status', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_user_id', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_stripe_customer_id', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_stripe_sub_id', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_customer_id', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_subscription_id', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_active_tenant', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_status_billing', table_name='subscriptions')
|
||||
op.drop_index('idx_subscriptions_tenant_covering', table_name='subscriptions')
|
||||
|
||||
Reference in New Issue
Block a user