This commit is contained in:
Iliyan Angelov
2025-12-05 17:43:03 +02:00
parent e1988fe37a
commit 13c91f95f4
51 changed files with 11933 additions and 289 deletions

View File

@@ -0,0 +1,55 @@
"""add_newsletter_subscribers_table
Revision ID: 316d876b1b71
Revises: add_enterprise_homepage_fields
Create Date: 2025-12-05 15:33:09.120967
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '316d876b1b71'
down_revision = 'add_enterprise_homepage_fields'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Check if table exists
from sqlalchemy import inspect
conn = op.get_bind()
inspector = inspect(conn)
tables = inspector.get_table_names()
if 'newsletter_subscribers' not in tables:
# Create newsletter_subscribers table
op.create_table(
'newsletter_subscribers',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('email', sa.String(255), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(255), nullable=True),
sa.Column('subscribed_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False, server_default='1'),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
op.create_index(op.f('ix_newsletter_subscribers_email'), 'newsletter_subscribers', ['email'], unique=False)
op.create_index(op.f('ix_newsletter_subscribers_id'), 'newsletter_subscribers', ['id'], unique=False)
op.create_index(op.f('ix_newsletter_subscribers_is_active'), 'newsletter_subscribers', ['is_active'], unique=False)
op.create_index(op.f('ix_newsletter_subscribers_subscribed_at'), 'newsletter_subscribers', ['subscribed_at'], unique=False)
op.create_index(op.f('ix_newsletter_subscribers_user_id'), 'newsletter_subscribers', ['user_id'], unique=False)
def downgrade() -> None:
op.drop_index(op.f('ix_newsletter_subscribers_user_id'), table_name='newsletter_subscribers')
op.drop_index(op.f('ix_newsletter_subscribers_subscribed_at'), table_name='newsletter_subscribers')
op.drop_index(op.f('ix_newsletter_subscribers_is_active'), table_name='newsletter_subscribers')
op.drop_index(op.f('ix_newsletter_subscribers_id'), table_name='newsletter_subscribers')
op.drop_index(op.f('ix_newsletter_subscribers_email'), table_name='newsletter_subscribers')
op.drop_table('newsletter_subscribers')

View File

@@ -0,0 +1,40 @@
"""add_recipient_type_to_campaigns
Revision ID: 87e29a777cb3
Revises: 316d876b1b71
Create Date: 2025-12-05 15:36:11.095669
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '87e29a777cb3'
down_revision = '316d876b1b71'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Add recipient_type column to email_campaigns table
from sqlalchemy import inspect
conn = op.get_bind()
inspector = inspect(conn)
# Check if column exists
columns = [col['name'] for col in inspector.get_columns('email_campaigns')]
if 'recipient_type' not in columns:
op.add_column('email_campaigns', sa.Column('recipient_type', sa.String(50), nullable=True, server_default='users'))
def downgrade() -> None:
# Remove recipient_type column
from sqlalchemy import inspect
conn = op.get_bind()
inspector = inspect(conn)
columns = [col['name'] for col in inspector.get_columns('email_campaigns')]
if 'recipient_type' in columns:
op.drop_column('email_campaigns', 'recipient_type')

View File

@@ -0,0 +1,127 @@
from alembic import op
import sqlalchemy as sa
from sqlalchemy import inspect
revision = 'add_enterprise_homepage_fields'
down_revision = 'service_detail_001' # Latest migration head
branch_labels = None
depends_on = None
def column_exists(table_name, column_name, connection):
"""Check if a column exists in a table."""
inspector = inspect(connection)
columns = [col['name'] for col in inspector.get_columns(table_name)]
return column_name in columns
def upgrade() -> None:
connection = op.get_bind()
# Helper function to add column if it doesn't exist
def add_column_if_not_exists(table_name, column, column_name):
if not column_exists(table_name, column_name, connection):
op.add_column(table_name, column)
# Hero video fields - use TEXT to avoid row size limit
add_column_if_not_exists('page_contents', sa.Column('hero_video_url', sa.Text(), nullable=True), 'hero_video_url')
add_column_if_not_exists('page_contents', sa.Column('hero_video_poster', sa.Text(), nullable=True), 'hero_video_poster')
# Features section fields - use TEXT for subtitles
add_column_if_not_exists('page_contents', sa.Column('features_section_title', sa.Text(), nullable=True), 'features_section_title')
add_column_if_not_exists('page_contents', sa.Column('features_section_subtitle', sa.Text(), nullable=True), 'features_section_subtitle')
# Stats section fields - use TEXT for subtitles
add_column_if_not_exists('page_contents', sa.Column('stats_section_title', sa.Text(), nullable=True), 'stats_section_title')
add_column_if_not_exists('page_contents', sa.Column('stats_section_subtitle', sa.Text(), nullable=True), 'stats_section_subtitle')
# Rooms section fields - use TEXT for all string fields
add_column_if_not_exists('page_contents', sa.Column('rooms_section_title', sa.Text(), nullable=True), 'rooms_section_title')
add_column_if_not_exists('page_contents', sa.Column('rooms_section_subtitle', sa.Text(), nullable=True), 'rooms_section_subtitle')
add_column_if_not_exists('page_contents', sa.Column('rooms_section_button_text', sa.Text(), nullable=True), 'rooms_section_button_text')
add_column_if_not_exists('page_contents', sa.Column('rooms_section_button_link', sa.Text(), nullable=True), 'rooms_section_button_link')
add_column_if_not_exists('page_contents', sa.Column('rooms_section_enabled', sa.Boolean(), nullable=True, server_default='1'), 'rooms_section_enabled')
# Services section fields - use TEXT for all string fields
add_column_if_not_exists('page_contents', sa.Column('services_section_button_text', sa.Text(), nullable=True), 'services_section_button_text')
add_column_if_not_exists('page_contents', sa.Column('services_section_button_link', sa.Text(), nullable=True), 'services_section_button_link')
add_column_if_not_exists('page_contents', sa.Column('services_section_limit', sa.Integer(), nullable=True), 'services_section_limit')
# Sections enabled (JSON field for toggling sections)
add_column_if_not_exists('page_contents', sa.Column('sections_enabled', sa.Text(), nullable=True), 'sections_enabled')
# Newsletter section fields - use TEXT for all string fields
add_column_if_not_exists('page_contents', sa.Column('newsletter_section_title', sa.Text(), nullable=True), 'newsletter_section_title')
add_column_if_not_exists('page_contents', sa.Column('newsletter_section_subtitle', sa.Text(), nullable=True), 'newsletter_section_subtitle')
add_column_if_not_exists('page_contents', sa.Column('newsletter_placeholder', sa.Text(), nullable=True), 'newsletter_placeholder')
add_column_if_not_exists('page_contents', sa.Column('newsletter_button_text', sa.Text(), nullable=True), 'newsletter_button_text')
add_column_if_not_exists('page_contents', sa.Column('newsletter_enabled', sa.Boolean(), nullable=True, server_default='0'), 'newsletter_enabled')
# Trust badges section fields - use TEXT for subtitles
add_column_if_not_exists('page_contents', sa.Column('trust_badges_section_title', sa.Text(), nullable=True), 'trust_badges_section_title')
add_column_if_not_exists('page_contents', sa.Column('trust_badges_section_subtitle', sa.Text(), nullable=True), 'trust_badges_section_subtitle')
add_column_if_not_exists('page_contents', sa.Column('trust_badges', sa.Text(), nullable=True), 'trust_badges')
add_column_if_not_exists('page_contents', sa.Column('trust_badges_enabled', sa.Boolean(), nullable=True, server_default='0'), 'trust_badges_enabled')
# Promotions section fields - use TEXT for subtitles
add_column_if_not_exists('page_contents', sa.Column('promotions_section_title', sa.Text(), nullable=True), 'promotions_section_title')
add_column_if_not_exists('page_contents', sa.Column('promotions_section_subtitle', sa.Text(), nullable=True), 'promotions_section_subtitle')
add_column_if_not_exists('page_contents', sa.Column('promotions', sa.Text(), nullable=True), 'promotions')
add_column_if_not_exists('page_contents', sa.Column('promotions_enabled', sa.Boolean(), nullable=True, server_default='0'), 'promotions_enabled')
# Blog section fields - use TEXT for subtitles
add_column_if_not_exists('page_contents', sa.Column('blog_section_title', sa.Text(), nullable=True), 'blog_section_title')
add_column_if_not_exists('page_contents', sa.Column('blog_section_subtitle', sa.Text(), nullable=True), 'blog_section_subtitle')
add_column_if_not_exists('page_contents', sa.Column('blog_posts_limit', sa.Integer(), nullable=True), 'blog_posts_limit')
add_column_if_not_exists('page_contents', sa.Column('blog_enabled', sa.Boolean(), nullable=True, server_default='0'), 'blog_enabled')
def downgrade() -> None:
# Blog section fields
op.drop_column('page_contents', 'blog_enabled')
op.drop_column('page_contents', 'blog_posts_limit')
op.drop_column('page_contents', 'blog_section_subtitle')
op.drop_column('page_contents', 'blog_section_title')
# Promotions section fields
op.drop_column('page_contents', 'promotions_enabled')
op.drop_column('page_contents', 'promotions')
op.drop_column('page_contents', 'promotions_section_subtitle')
op.drop_column('page_contents', 'promotions_section_title')
# Trust badges section fields
op.drop_column('page_contents', 'trust_badges_enabled')
op.drop_column('page_contents', 'trust_badges')
op.drop_column('page_contents', 'trust_badges_section_subtitle')
op.drop_column('page_contents', 'trust_badges_section_title')
# Newsletter section fields
op.drop_column('page_contents', 'newsletter_enabled')
op.drop_column('page_contents', 'newsletter_button_text')
op.drop_column('page_contents', 'newsletter_placeholder')
op.drop_column('page_contents', 'newsletter_section_subtitle')
op.drop_column('page_contents', 'newsletter_section_title')
# Sections enabled
op.drop_column('page_contents', 'sections_enabled')
# Services section fields
op.drop_column('page_contents', 'services_section_limit')
op.drop_column('page_contents', 'services_section_button_link')
op.drop_column('page_contents', 'services_section_button_text')
# Rooms section fields
op.drop_column('page_contents', 'rooms_section_enabled')
op.drop_column('page_contents', 'rooms_section_button_link')
op.drop_column('page_contents', 'rooms_section_button_text')
op.drop_column('page_contents', 'rooms_section_subtitle')
op.drop_column('page_contents', 'rooms_section_title')
# Stats section fields
op.drop_column('page_contents', 'stats_section_subtitle')
op.drop_column('page_contents', 'stats_section_title')
# Features section fields
op.drop_column('page_contents', 'features_section_subtitle')
op.drop_column('page_contents', 'features_section_title')
# Hero video fields
op.drop_column('page_contents', 'hero_video_poster')
op.drop_column('page_contents', 'hero_video_url')