"""add api keys table

Revision ID: 1d6ac45d4224
Revises: 8766bdadc553
Create Date: 2017-05-03 21:51:08.965952

"""

# revision identifiers, used by Alembic.
revision = '1d6ac45d4224'
down_revision = '8766bdadc553'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.schema import Sequence, CreateSequence

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('api_keys',
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('token', sa.Text(), nullable=True),
    sa.Column('notes', sa.Text(), nullable=True),
    sa.Column('enabled', sa.Boolean(), nullable=True),
    sa.Column('user_id', sa.BigInteger(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.execute(CreateSequence(Sequence('api_key_id_seq')))
    op.create_index(op.f('ix_api_keys_token'), 'api_keys', ['token'], unique=False)
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_api_keys_token'), table_name='api_keys')
    op.drop_table('api_keys')
    ### end Alembic commands ###
