"""update-resource-policy-tables

Revision ID: b86b341fd9c9
Revises: 5ba7fde56ddb
Create Date: 2023-07-18 17:47:42.452974

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "b86b341fd9c9"
down_revision = "5ba7fde56ddb"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("keypair_resource_policies", "max_vfolder_count")
    op.drop_column("keypair_resource_policies", "max_vfolder_size")
    op.add_column(
        "project_resource_policies",
        sa.Column("max_vfolder_count", sa.Integer(), server_default="0", nullable=False),
    )
    op.alter_column(
        "project_resource_policies",
        "max_vfolder_size",
        server_default="-1",
        new_column_name="max_quota_scope_size",
    )
    op.add_column(
        "user_resource_policies",
        sa.Column("max_vfolder_count", sa.Integer(), server_default="0", nullable=False),
    )
    op.alter_column(
        "user_resource_policies",
        "max_vfolder_size",
        server_default="-1",
        new_column_name="max_quota_scope_size",
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "user_resource_policies", "max_quota_scope_size", new_column_name="max_vfolder_size"
    )
    op.drop_column("user_resource_policies", "max_vfolder_count")
    op.alter_column(
        "project_resource_policies", "max_quota_scope_size", new_column_name="max_vfolder_size"
    )
    op.drop_column("project_resource_policies", "max_vfolder_count")
    op.add_column(
        "keypair_resource_policies",
        sa.Column(
            "max_vfolder_size", sa.BIGINT(), server_default="0", autoincrement=False, nullable=False
        ),
    )
    op.add_column(
        "keypair_resource_policies",
        sa.Column(
            "max_vfolder_count",
            sa.INTEGER(),
            server_default="10",
            autoincrement=False,
            nullable=False,
        ),
    )
    # ### end Alembic commands ###
