"""Add granular permissions to RoomMemberPermission

Revision ID: be1f7bdd10e1
Revises: 64b5c28510b0
Create Date: 2025-05-24 12:32:19.239241

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import inspect


# revision identifiers, used by Alembic.
revision = 'be1f7bdd10e1'
down_revision = '64b5c28510b0'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    inspector = inspect(conn)
    columns = [col['name'] for col in inspector.get_columns('room_member_permissions')]
    
    with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
        if 'can_download' not in columns:
            batch_op.add_column(sa.Column('can_download', sa.Boolean(), nullable=False, server_default=sa.false()))
        if 'can_rename' not in columns:
            batch_op.add_column(sa.Column('can_rename', sa.Boolean(), nullable=False, server_default=sa.false()))
        if 'can_move' not in columns:
            batch_op.add_column(sa.Column('can_move', sa.Boolean(), nullable=False, server_default=sa.false()))

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('room_member_permissions', schema=None) as batch_op:
        batch_op.drop_column('can_move')
        batch_op.drop_column('can_rename')
        batch_op.drop_column('can_download')

    # ### end Alembic commands ###
