"""Add parent_id to comments for threading

Revision ID: 95fdb1be53a6
Revises: add_sso_subject_to_users
Create Date: 2026-01-09 12:00:37.601204

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '95fdb1be53a6'
down_revision = 'add_sso_subject_to_users'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('comments', schema=None) as batch_op:
        batch_op.add_column(sa.Column('parent_id', sa.Integer(), nullable=True))
        batch_op.create_foreign_key('fk_comments_parent_id', 'comments', ['parent_id'], ['id'])

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('comments', schema=None) as batch_op:
        batch_op.drop_constraint('fk_comments_parent_id', type_='foreignkey')
        batch_op.drop_column('parent_id')

    # ### end Alembic commands ###
