"""add notifications, feedback, subscription, and p3 tables Revision ID: 003 Revises: 002 Create Date: 2026-05-09 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql revision: str = '003' down_revision: Union[str, None] = '002' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table('notifications', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('title', sa.String(length=255), nullable=False), sa.Column('content', sa.Text(), nullable=False), sa.Column('notification_type', sa.String(length=50), nullable=True), sa.Column('reference_type', sa.String(length=50), nullable=True), sa.Column('reference_id', sa.String(length=255), nullable=True), sa.Column('is_read', sa.Boolean(), nullable=True), sa.Column('metadata', postgresql.JSONB(astext_type=sa.Text()), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_notifications_user_id'), 'notifications', ['user_id'], unique=False) op.create_table('feedbacks', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('category', sa.String(length=50), nullable=True), sa.Column('content', sa.Text(), nullable=False), sa.Column('contact', sa.String(length=100), nullable=True), sa.Column('status', sa.String(length=20), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_feedbacks_user_id'), 'feedbacks', ['user_id'], unique=False) op.create_table('subscriptions', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('plan', sa.String(length=50), nullable=False), sa.Column('status', sa.String(length=20), nullable=True), sa.Column('started_at', sa.DateTime(), nullable=True), sa.Column('expires_at', sa.DateTime(), nullable=True), sa.Column('auto_renew', sa.Boolean(), nullable=True), sa.Column('payment_provider', sa.String(length=50), nullable=True), sa.Column('payment_id', sa.String(length=255), nullable=True), sa.Column('amount', sa.Float(), nullable=True), sa.Column('currency', sa.String(length=10), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_subscriptions_user_id'), 'subscriptions', ['user_id'], unique=False) op.create_table('preference_analyses', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('task_type', sa.String(length=50), nullable=False), sa.Column('preferred_tone', sa.String(length=50), nullable=True), sa.Column('preferred_style', sa.String(length=50), nullable=True), sa.Column('common_replacements', postgresql.JSONB(astext_type=sa.Text()), nullable=True), sa.Column('avg_formality_score', sa.Float(), nullable=True), sa.Column('greeting_style', sa.String(length=100), nullable=True), sa.Column('sign_off_style', sa.String(length=100), nullable=True), sa.Column('analysis_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), sa.Column('confidence', sa.Float(), nullable=True), sa.Column('interaction_count', sa.Integer(), nullable=True), sa.Column('last_analysis_at', sa.DateTime(), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_preference_analyses_user_id'), 'preference_analyses', ['user_id'], unique=False) op.create_table('marketing_effects', sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('content_hash', sa.String(length=64), nullable=False), sa.Column('product_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('product_name', sa.String(length=255), nullable=True), sa.Column('channel', sa.String(length=50), nullable=True), sa.Column('event_type', sa.String(length=50), nullable=False), sa.Column('target_audience', sa.String(length=255), nullable=True), sa.Column('metadata', postgresql.JSONB(astext_type=sa.Text()), nullable=True), sa.Column('created_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_marketing_effects_user_id'), 'marketing_effects', ['user_id'], unique=False) op.create_index(op.f('ix_marketing_effects_content_hash'), 'marketing_effects', ['content_hash'], unique=False) def downgrade() -> None: op.drop_table('marketing_effects') op.drop_table('preference_analyses') op.drop_table('subscriptions') op.drop_table('feedbacks') op.drop_table('notifications')