"""empty message

Revision ID: 6dc3f2e63558
Revises: 8ebeb4c2e02f
Create Date: 2020-02-03 19:44:19.149282

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "6dc3f2e63558"
down_revision = "8ebeb4c2e02f"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    # Remove meaningless permissions - a permission not granted to any user is not useful.
    conn.execute("DELETE FROM permissions WHERE granted_to_user is NULL")
    op.alter_column(
        "permissions", "granted_to_user", existing_type=sa.INTEGER(), nullable=False
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "permissions", "granted_to_user", existing_type=sa.INTEGER(), nullable=True
    )
    # ### end Alembic commands ###
