"""adding query_policies to meta

Revision ID: f7a4949eed19
Revises: 848b623755a4
Create Date: 2025-01-22 11:37:26.347777

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel
import sqlmodel.sql.sqltypes
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = 'f7a4949eed19'
down_revision: Union[str, None] = '848b623755a4'
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! ###
    with op.batch_alter_table('entries', schema=None) as batch_op:
        batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}'))

    with op.batch_alter_table('permissions', schema=None) as batch_op:
        batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}'))

    with op.batch_alter_table('roles', schema=None) as batch_op:
        batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}'))

    with op.batch_alter_table('spaces', schema=None) as batch_op:
        batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}'))

    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}'))

    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.drop_column('query_policies')

    with op.batch_alter_table('spaces', schema=None) as batch_op:
        batch_op.drop_column('query_policies')

    with op.batch_alter_table('roles', schema=None) as batch_op:
        batch_op.drop_column('query_policies')

    with op.batch_alter_table('permissions', schema=None) as batch_op:
        batch_op.drop_column('query_policies')

    with op.batch_alter_table('entries', schema=None) as batch_op:
        batch_op.drop_column('query_policies')

    # ### end Alembic commands ###
