"""empty message

Revision ID: d4392342465f
Revises: 9014cca7097c
Create Date: 2021-08-17 18:53:27.134187

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

# revision identifiers, used by Alembic.
revision = 'd4392342465f'
down_revision = '9014cca7097c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('custom_domain', sa.Column('ownership_txt_token', sa.String(length=128), nullable=True))
    op.add_column('custom_domain', sa.Column('ownership_verified', sa.Boolean(), server_default='0', nullable=False))
    op.create_index('ix_unique_domain', 'custom_domain', ['domain'], unique=True,
                    postgresql_where=sa.text('ownership_verified'))

    # set ownership_verified=True for domain that has verified=True
    op.execute('UPDATE custom_domain SET ownership_verified = true WHERE verified = true')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('ix_unique_domain', table_name='custom_domain')
    op.drop_column('custom_domain', 'ownership_verified')
    op.drop_column('custom_domain', 'ownership_txt_token')
    # ### end Alembic commands ###
