"""empty message

Revision ID: 892aba57b356
Revises: 
Create Date: 2025-11-22 18:19:36.694430

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import pgvector.sqlalchemy
from sqlalchemy import Text
from sqlalchemy.dialects.postgresql import JSONB, UUID
import template_project.adapters.data_gateways.tables
from template_project.adapters.data_gateways.tables import StringArrayType


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


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('key_skills',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('users',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('access_token',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('user_id', sa.UUID(), nullable=False),
    sa.Column('revoked', sa.Boolean(), nullable=False),
    sa.Column('expires_in', sa.DateTime(timezone=True), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('auth_identities',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('user_id', sa.UUID(), nullable=False),
    sa.Column('method', sa.Enum('EMAIL', 'YANDEX', name='auth_method'), nullable=False),
    sa.Column('identifier', sa.String(), nullable=False),
    sa.Column('secret_key', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('method', 'identifier', name='uq_auth_method_identifier')
    )
    op.create_table('notification_devices',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('user_id', sa.UUID(), nullable=False),
    sa.Column('device_id', sa.String(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id', 'device_id', name='uq_user_device')
    )
    op.create_table('profiles',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('user_id', sa.UUID(), nullable=False),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('display_name', sa.String(), nullable=True),
    sa.Column('first_name', sa.String(), nullable=True),
    sa.Column('last_name', sa.String(), nullable=True),
    sa.Column('avatar_url', sa.String(), nullable=True),
    sa.Column('phone', sa.String(), nullable=True),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id')
    )
    op.create_table('resume',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.Column('user_id', sa.UUID(), nullable=False),
    sa.Column('position', sa.String(), nullable=False),
    sa.Column('location', sa.String(), nullable=False),
    sa.Column('about_me', sa.String(), nullable=False),
    sa.Column('key_skills', StringArrayType(astext_type=Text()), server_default=sa.text("'[]'::jsonb"), nullable=False),
    sa.Column('experience_type', sa.String(), nullable=False),
    sa.Column('down_resume_id', sa.UUID(), nullable=True),
    sa.Column('up_resume_id', sa.UUID(), nullable=True),
    sa.ForeignKeyConstraint(['down_resume_id'], ['resume.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['up_resume_id'], ['resume.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('resume_education',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.Column('resume_id', sa.UUID(), nullable=False),
    sa.Column('place', sa.String(), nullable=False),
    sa.Column('grade', sa.Enum('BASIC_GENERAL_EDUCATION', 'SECONDARY_GENERAL_EDUCATION', 'SECONDARY_PROFESSIONAL_EDUCATION', 'BACHELOR', 'SPECIALIST', 'MASTER', 'POSTGRADUATE_STUDIES', 'OTHER', name='education_grade'), nullable=False),
    sa.Column('specialization', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('resume_embedding',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.Column('resume_id', sa.UUID(), nullable=False),
    sa.Column('vector', pgvector.sqlalchemy.vector.VECTOR(), nullable=False),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('resume_experience',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.Column('resume_id', sa.UUID(), nullable=False),
    sa.Column('place', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=False),
    sa.Column('months_duration', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('resume_prediction',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.Column('resume_id', sa.UUID(), nullable=False),
    sa.Column('from_salary', sa.Numeric(), nullable=False),
    sa.Column('to_salary', sa.Numeric(), nullable=False),
    sa.Column('recommended_skills', template_project.adapters.data_gateways.tables.StringArrayType(astext_type=Text()), server_default=sa.text("'[]'::jsonb"), nullable=False),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('resume_project',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
    sa.Column('resume_id', sa.UUID(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['resume_id'], ['resume.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('resume_project')
    op.drop_table('resume_prediction')
    op.drop_table('resume_experience')
    op.drop_table('resume_embedding')
    op.drop_table('resume_education')
    op.drop_table('resume')
    op.drop_table('profiles')
    op.drop_table('notification_devices')
    op.drop_table('auth_identities')
    op.drop_table('access_token')
    op.drop_table('users')
    op.drop_table('key_skills')
    # ### end Alembic commands ###
