"""oauth

Revision ID: be5fc4065b01
Revises: c29fdc8588d9
Create Date: 2016-06-05 02:50:56.629956

"""

# revision identifiers, used by Alembic.
revision = 'be5fc4065b01'
down_revision = 'c29fdc8588d9'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
from sqlalchemy.dialects import postgresql


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('oauth_client',
                    sa.Column(
                        'id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
                    sa.Column(
                        'client_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=True),
                    sa.Column(
                        'client_secret', sa.String(length=64), nullable=True),
                    sa.Column('client_type', sa.Enum(
                        'confidential', 'public', name='client_type'), nullable=True),
                    sa.Column('active', sa.Boolean, default=True),
                    sa.Column('name', sa.String(length=100), nullable=True),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_table('oauth_access_token',
                    sa.Column(
                        'id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
                    sa.Column(
                        'client_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=True),
                    sa.Column(
                        'access_token', sa.String(length=64), nullable=True),
                    sa.Column(
                        'token_type', sa.Enum('Bearer', name='token_type'), nullable=True),
                    sa.Column(
                        'expiry_date', sa.DateTime(timezone=True), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['client_id'], ['oauth_client.id'], ),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('access_token')
                    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('oauth_access_token')
    op.drop_table('oauth_client')
    ### end Alembic commands ###
