"""Added project_key table

Revision ID: 9959d986bb48
Revises: 37444aa582fe
Create Date: 2026-03-12 13:22:14.298517

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '9959d986bb48'
down_revision: Union[str, Sequence[str], None] = 'c3d4e5f6a7b8'
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('project_key',
    sa.Column('project_key', sa.String(length=128), nullable=False),
    sa.Column('profile_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
    sa.ForeignKeyConstraint(['profile_id'], ['profile.id'], name=op.f('project_key_profile_id_fkey'), ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id', name=op.f('project_key_pkey')),
    sa.UniqueConstraint('project_key', name='uq_project_key')
    )
    op.create_index(op.f('project_key_id_idx'), 'project_key', ['id'], unique=False)
    op.create_index(op.f('project_key_profile_id_idx'), 'project_key', ['profile_id'], unique=False)
    op.create_index(op.f('project_key_project_key_idx'), 'project_key', ['project_key'], unique=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('project_key_project_key_idx'), table_name='project_key')
    op.drop_index(op.f('project_key_profile_id_idx'), table_name='project_key')
    op.drop_index(op.f('project_key_id_idx'), table_name='project_key')
    op.drop_table('project_key')
    # ### end Alembic commands ###
