<gh_stars>10-100
"""Initial migration.

Revision ID: <PASSWORD>
Revises: 
Create Date: 2018-02-07 21:05:49.629867

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

# revision identifiers, used by Alembic.
revision = '<PASSWORD>'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('oauth_clients',
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('client_id', sa.String(length=40), nullable=False),
    sa.Column('client_secret', sa.String(length=55), nullable=False),
    sa.Column('redirect_uris', postgresql.ARRAY(sa.String()), nullable=True),
    sa.Column('is_confidential', sa.Boolean(), nullable=True),
    sa.Column('default_scopes', postgresql.ARRAY(sa.String()), nullable=True),
    sa.PrimaryKeyConstraint('client_id')
    )
    op.create_index(op.f('ix_oauth_clients_client_secret'), 'oauth_clients', ['client_secret'], unique=True)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('pebble_auth_uid', sa.String(length=24), nullable=True),
    sa.Column('pebble_dev_portal_uid', sa.String(length=24), nullable=True),
    sa.Column('pebble_token', sa.String(), nullable=True),
    sa.Column('has_logged_in', sa.Boolean(), server_default='false', nullable=False),
    sa.Column('account_type', sa.Integer(), server_default='0', nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_pebble_token'), 'users', ['pebble_token'], unique=False)
    op.create_table('issued_tokens',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('client_id', sa.String(length=40), nullable=False),
    sa.Column('scopes', postgresql.ARRAY(sa.String()), nullable=True),
    sa.Column('expires', sa.DateTime(), nullable=True),
    sa.Column('access_token', sa.String(), nullable=True),
    sa.Column('refresh_token', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['client_id'], ['oauth_clients.client_id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('access_token'),
    sa.UniqueConstraint('refresh_token')
    )
    op.create_table('user_identities',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('idp', sa.String(), nullable=True),
    sa.Column('idp_user_id', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('user_identity_idp_id_index', 'user_identities', ['idp', 'idp_user_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('user_identity_idp_id_index', table_name='user_identities')
    op.drop_table('user_identities')
    op.drop_table('issued_tokens')
    op.drop_index(op.f('ix_users_pebble_token'), table_name='users')
    op.drop_table('users')
    op.drop_index(op.f('ix_oauth_clients_client_secret'), table_name='oauth_clients')
    op.drop_table('oauth_clients')
    # ### end Alembic commands ###

"""Initial migration.

Revision ID: <PASSWORD>
Revises: 
Create Date: 2018-02-07 21:05:49.629867

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

# revision identifiers, used by Alembic.
revision = '<PASSWORD>'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('oauth_clients',
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('client_id', sa.String(length=40), nullable=False),
    sa.Column('client_secret', sa.String(length=55), nullable=False),
    sa.Column('redirect_uris', postgresql.ARRAY(sa.String()), nullable=True),
    sa.Column('is_confidential', sa.Boolean(), nullable=True),
    sa.Column('default_scopes', postgresql.ARRAY(sa.String()), nullable=True),
    sa.PrimaryKeyConstraint('client_id')
    )
    op.create_index(op.f('ix_oauth_clients_client_secret'), 'oauth_clients', ['client_secret'], unique=True)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('pebble_auth_uid', sa.String(length=24), nullable=True),
    sa.Column('pebble_dev_portal_uid', sa.String(length=24), nullable=True),
    sa.Column('pebble_token', sa.String(), nullable=True),
    sa.Column('has_logged_in', sa.Boolean(), server_default='false', nullable=False),
    sa.Column('account_type', sa.Integer(), server_default='0', nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_pebble_token'), 'users', ['pebble_token'], unique=False)
    op.create_table('issued_tokens',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('client_id', sa.String(length=40), nullable=False),
    sa.Column('scopes', postgresql.ARRAY(sa.String()), nullable=True),
    sa.Column('expires', sa.DateTime(), nullable=True),
    sa.Column('access_token', sa.String(), nullable=True),
    sa.Column('refresh_token', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['client_id'], ['oauth_clients.client_id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('access_token'),
    sa.UniqueConstraint('refresh_token')
    )
    op.create_table('user_identities',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('idp', sa.String(), nullable=True),
    sa.Column('idp_user_id', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('user_identity_idp_id_index', 'user_identities', ['idp', 'idp_user_id'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('user_identity_idp_id_index', table_name='user_identities')
    op.drop_table('user_identities')
    op.drop_table('issued_tokens')
    op.drop_index(op.f('ix_users_pebble_token'), table_name='users')
    op.drop_table('users')
    op.drop_index(op.f('ix_oauth_clients_client_secret'), table_name='oauth_clients')
    op.drop_table('oauth_clients')
    # ### end Alembic commands ###
Initial migration.  Revision ID: <PASSWORD> Revises:  Create Date: 2018-02-07 21:05:49.629867 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###