This commit is contained in:
Iliyan Angelov
2025-11-17 18:26:30 +02:00
parent 48353cde9c
commit 0c59fe1173
2535 changed files with 278997 additions and 2480 deletions

View File

@@ -0,0 +1,29 @@
"""add_capacity_room_size_view_to_rooms
Revision ID: 6a126cc5b23c
Revises: add_stripe_payment_method
Create Date: 2025-11-17 16:25:09.581786
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6a126cc5b23c'
down_revision = 'add_stripe_payment_method'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Add the three new columns to rooms table
op.add_column('rooms', sa.Column('capacity', sa.Integer(), nullable=True))
op.add_column('rooms', sa.Column('room_size', sa.String(length=50), nullable=True))
op.add_column('rooms', sa.Column('view', sa.String(length=100), nullable=True))
def downgrade() -> None:
# Remove the three columns from rooms table
op.drop_column('rooms', 'view')
op.drop_column('rooms', 'room_size')
op.drop_column('rooms', 'capacity')

View File

@@ -0,0 +1,60 @@
"""add_system_settings_table
Revision ID: 96c23dad405d
Revises: 59baf2338f8a
Create Date: 2025-11-17 11:51:28.369031
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = '96c23dad405d'
down_revision = '59baf2338f8a'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Create system_settings table (if it doesn't exist)
from sqlalchemy import inspect
bind = op.get_bind()
inspector = inspect(bind)
tables = inspector.get_table_names()
if 'system_settings' not in tables:
op.create_table('system_settings',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('key', sa.String(length=100), nullable=False),
sa.Column('value', sa.Text(), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=False),
sa.Column('updated_by_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['updated_by_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_system_settings_id'), 'system_settings', ['id'], unique=False)
op.create_index(op.f('ix_system_settings_key'), 'system_settings', ['key'], unique=True)
# Add currency column to users table (if it doesn't exist)
columns = [col['name'] for col in inspector.get_columns('users')]
if 'currency' not in columns:
op.add_column('users', sa.Column('currency', sa.String(length=3), nullable=False, server_default='VND'))
# ### end Alembic commands ###
def downgrade() -> None:
# Drop currency column from users table
try:
op.drop_column('users', 'currency')
except Exception:
# Column might not exist, skip
pass
# Drop system_settings table
op.drop_index(op.f('ix_system_settings_key'), table_name='system_settings')
op.drop_index(op.f('ix_system_settings_id'), table_name='system_settings')
op.drop_table('system_settings')
# ### end Alembic commands ###

View File

@@ -0,0 +1,50 @@
"""add_stripe_payment_method
Revision ID: add_stripe_payment_method
Revises: 96c23dad405d
Create Date: 2025-01-17 12:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = 'add_stripe_payment_method'
down_revision = '96c23dad405d'
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 'stripe'
# 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 'stripe'
# This preserves existing values and adds 'stripe'
op.execute(
"ALTER TABLE payments MODIFY COLUMN payment_method ENUM('cash', 'credit_card', 'debit_card', 'bank_transfer', 'e_wallet', 'stripe') 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 'stripe' from the ENUM (be careful if there are existing stripe payments)
bind = op.get_bind()
if bind.dialect.name == 'mysql':
# First, check if there are any stripe payments - if so, this will fail
# In production, you'd want to migrate existing stripe payments first
op.execute(
"ALTER TABLE payments MODIFY COLUMN payment_method ENUM('cash', 'credit_card', 'debit_card', 'bank_transfer', 'e_wallet') NOT NULL"
)
# ### end Alembic commands ###