"""update persona

Revision ID: cc623457d683
Revises: b3d76536d9d8
Create Date: 2025-09-01 15:09:56.466223

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = 'cc623457d683'
down_revision: Union[str, None] = 'b3d76536d9d8'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('store_personas',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('store_id', sa.BigInteger(), nullable=False),
    sa.Column('branch_id', sa.BigInteger(), nullable=True),
    sa.Column('industry', sa.String(length=100), nullable=True),
    sa.Column('audience_type', sa.String(length=100), nullable=True),
    sa.Column('brand_voice', sa.String(length=100), nullable=True),
    sa.Column('content_style', sa.String(length=100), nullable=True),
    sa.Column('analysis_summary', sa.Text(), nullable=True),
    sa.Column('confidence_score', sa.BigInteger(), nullable=True),
    sa.Column('last_analyzed', sa.DateTime(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.Column('is_active', sa.BigInteger(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('persona_profile')
    op.drop_table('persona_performance')
    op.drop_table('persona_audience')
    op.drop_table('persona_context')
    op.drop_table('personas')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('personas',
    sa.Column('id', sa.BIGINT(), server_default=sa.text("nextval('personas_id_seq'::regclass)"), autoincrement=True, nullable=False),
    sa.Column('store_id', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('branch_id', sa.BIGINT(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('status', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id', name='personas_pkey'),
    postgresql_ignore_search_path=False
    )
    op.create_table('persona_context',
    sa.Column('persona_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('content_categories', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('content_themes', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('hashtag_strategy', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('posting_cadence', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('seasonal_events', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('narrative_brand', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('narrative_audience', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('narrative_voice', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('embeddings', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['persona_id'], ['personas.id'], name='persona_context_persona_id_fkey'),
    sa.PrimaryKeyConstraint('persona_id', name='persona_context_pkey')
    )
    op.create_table('persona_audience',
    sa.Column('persona_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('locales', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('languages', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['persona_id'], ['personas.id'], name='persona_audience_persona_id_fkey'),
    sa.PrimaryKeyConstraint('persona_id', name='persona_audience_pkey')
    )
    op.create_table('persona_performance',
    sa.Column('persona_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('engagement_data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('sentiment_metrics', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('growth_metrics', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('best_performing_posts', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('interests', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('segments', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('best_posting_windows', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('best_formats', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('best_hashtags', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('best_ctas', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('baselines', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['persona_id'], ['personas.id'], name='persona_performance_persona_id_fkey'),
    sa.PrimaryKeyConstraint('persona_id', name='persona_performance_pkey')
    )
    op.create_table('persona_profile',
    sa.Column('persona_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('brand_summary', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('voice_rules', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('goals', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('competitors', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('brand_assets', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.Column('constraints', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['persona_id'], ['personas.id'], name='persona_profile_persona_id_fkey'),
    sa.PrimaryKeyConstraint('persona_id', name='persona_profile_pkey')
    )
    op.drop_table('store_personas')
    # ### end Alembic commands ###
