"""Add redirect_uris column to Client

Revision ID: 1df8009b83c5
Revises: 0e7f8edd4e21
Create Date: 2022-03-27 17:28:18.679116

"""
import sqlalchemy as sa
from alembic import op

import fief

# revision identifiers, used by Alembic.
revision = "1df8009b83c5"
down_revision = "0e7f8edd4e21"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("fief_clients", sa.Column("redirect_uris", sa.JSON(), nullable=True))
    op.execute("UPDATE fief_clients SET redirect_uris = '[]'")
    op.alter_column(
        "fief_clients", "redirect_uris", nullable=False, existing_type=sa.JSON()
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("fief_clients", "redirect_uris")
    # ### end Alembic commands ###
