"""empty message

Revision ID: 8a8cf5a585ce
Revises: 
Create Date: 2020-11-11 08:55:36.615379

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8a8cf5a585ce'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('supported_service',
    sa.Column('service_id', sa.Integer(), nullable=False),
    sa.Column('service_name', sa.String(), nullable=True),
    sa.Column('service_hash', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('service_id')
    )
    op.create_table('user',
    sa.Column('discord_user_id', sa.String(), nullable=False),
    sa.Column('discord_user_id_hash', sa.String(), nullable=True),
    sa.Column('github_event_announce', sa.Boolean(), nullable=True),
    sa.Column('github_entity_reaction', sa.Boolean(), nullable=True),
    sa.Column('github_gist_append_url', sa.String(), nullable=True),
    sa.Column('stackexchange_assistant_opt_in', sa.Boolean(), nullable=True),
    sa.Column('stackexchange_assistant_topics', sa.String(), nullable=True),
    sa.Column('stackexchange_publisher_opt_in', sa.Boolean(), nullable=True),
    sa.Column('sb_verification_token', sa.String(), nullable=True),
    sa.Column('sb_verification_token_hash', sa.String(), nullable=True),
    sa.Column('sb_status_id', sa.Integer(), nullable=True),
    sa.Column('creation_date', sa.DateTime(), nullable=True),
    sa.Column('last_updated', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('discord_user_id')
    )
    op.create_table('affiliated_guild',
    sa.Column('guild_id', sa.String(), nullable=False),
    sa.Column('guild_hash', sa.String(), nullable=False),
    sa.Column('authorized', sa.Boolean(), nullable=True),
    sa.Column('authorizing_user', sa.String(), nullable=True),
    sa.Column('authorization_date', sa.DateTime(), nullable=True),
    sa.Column('last_updated', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['authorizing_user'], ['user.discord_user_id'], ),
    sa.PrimaryKeyConstraint('guild_id')
    )
    op.create_table('user_oauth',
    sa.Column('discord_user_id', sa.String(), nullable=False),
    sa.Column('service_id', sa.Integer(), nullable=False),
    sa.Column('service_user_id', sa.String(), nullable=True),
    sa.Column('service_user_name', sa.String(), nullable=True),
    sa.Column('authorized', sa.Boolean(), nullable=True),
    sa.Column('access_token', sa.String(), nullable=True),
    sa.Column('refresh_token', sa.String(), nullable=True),
    sa.Column('scope', sa.String(), nullable=True),
    sa.Column('first_grant_date', sa.DateTime(), nullable=True),
    sa.Column('token_expiry_date', sa.DateTime(), nullable=True),
    sa.Column('last_revision_date', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['discord_user_id'], ['user.discord_user_id'], ),
    sa.ForeignKeyConstraint(['service_id'], ['supported_service.service_id'], ),
    sa.PrimaryKeyConstraint('discord_user_id', 'service_id')
    )
    op.create_table('service_verification',
    sa.Column('verification_id', sa.Integer(), nullable=False),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.Column('guild_id', sa.String(), nullable=True),
    sa.Column('verified_role_id', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['guild_id'], ['affiliated_guild.guild_id'], ),
    sa.ForeignKeyConstraint(['service_id'], ['supported_service.service_id'], ),
    sa.PrimaryKeyConstraint('verification_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('service_verification')
    op.drop_table('user_oauth')
    op.drop_table('affiliated_guild')
    op.drop_table('user')
    op.drop_table('supported_service')
    # ### end Alembic commands ###
