updates
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""add_mfa_fields_to_users
|
||||
|
||||
Revision ID: 08e2f866e131
|
||||
Revises: add_badges_to_page_content
|
||||
Create Date: 2025-11-19 11:13:30.376194
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '08e2f866e131'
|
||||
down_revision = 'add_badges_to_page_content'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add MFA fields to users table
|
||||
op.add_column('users', sa.Column('mfa_enabled', sa.Boolean(), nullable=False, server_default='0'))
|
||||
op.add_column('users', sa.Column('mfa_secret', sa.String(255), nullable=True))
|
||||
op.add_column('users', sa.Column('mfa_backup_codes', sa.Text(), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove MFA fields from users table
|
||||
op.drop_column('users', 'mfa_backup_codes')
|
||||
op.drop_column('users', 'mfa_secret')
|
||||
op.drop_column('users', 'mfa_enabled')
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,51 @@
|
||||
"""add_paypal_payment_method
|
||||
|
||||
Revision ID: d9aff6c5f0d4
|
||||
Revises: 08e2f866e131
|
||||
Create Date: 2025-11-19 12:07:50.703320
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd9aff6c5f0d4'
|
||||
down_revision = '08e2f866e131'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Note: MySQL ENUM modifications can be tricky.
|
||||
# If payments table already has data with existing enum values,
|
||||
# we need to preserve them when adding 'paypal'
|
||||
|
||||
# For MySQL, we need to alter the ENUM column to include the new value
|
||||
# Check if we're using MySQL
|
||||
bind = op.get_bind()
|
||||
if bind.dialect.name == 'mysql':
|
||||
# Alter the ENUM column to include 'paypal'
|
||||
# This preserves existing values and adds 'paypal'
|
||||
op.execute(
|
||||
"ALTER TABLE payments MODIFY COLUMN payment_method ENUM('cash', 'credit_card', 'debit_card', 'bank_transfer', 'e_wallet', 'stripe', 'paypal') NOT NULL"
|
||||
)
|
||||
else:
|
||||
# For other databases (PostgreSQL, SQLite), enum changes are handled differently
|
||||
# For SQLite, this might not be needed as it doesn't enforce enum constraints
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Remove 'paypal' from the ENUM (be careful if there are existing paypal payments)
|
||||
bind = op.get_bind()
|
||||
if bind.dialect.name == 'mysql':
|
||||
# First, check if there are any paypal payments - if so, this will fail
|
||||
# In production, you'd want to migrate existing paypal payments first
|
||||
op.execute(
|
||||
"ALTER TABLE payments MODIFY COLUMN payment_method ENUM('cash', 'credit_card', 'debit_card', 'bank_transfer', 'e_wallet', 'stripe') NOT NULL"
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
Reference in New Issue
Block a user