"""init

Revision ID: 265fa6cc6e8e
Revises: 
Create Date: 2020-10-06 10:46:27.992570

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


# revision identifiers, used by Alembic.
revision = '265fa6cc6e8e'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('activity',
    sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
    sa.Column('verb', sa.Unicode(length=255), nullable=True),
    sa.Column('transaction_id', sa.BigInteger(), nullable=False),
    sa.Column('data', sqlalchemy_utils.types.json.JSONType(), nullable=True),
    sa.Column('object_type', sa.String(length=255), nullable=True),
    sa.Column('object_id', sa.BigInteger(), nullable=True),
    sa.Column('object_tx_id', sa.BigInteger(), nullable=True),
    sa.Column('target_type', sa.String(length=255), nullable=True),
    sa.Column('target_id', sa.BigInteger(), nullable=True),
    sa.Column('target_tx_id', sa.BigInteger(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_activity_transaction_id'), 'activity', ['transaction_id'], unique=False)
    op.create_table('interest',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('plataform', sa.Enum('AAVE', 'COMPOUND', name='platform'), nullable=True),
    sa.Column('interest', sa.Float(precision=2), nullable=True),
    sa.Column('date', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('interest_version',
    sa.Column('created_at', sa.DateTime(), autoincrement=False, nullable=True),
    sa.Column('updated_at', sa.DateTime(), autoincrement=False, nullable=True),
    sa.Column('id', sa.BigInteger(), autoincrement=False, nullable=False),
    sa.Column('plataform', sa.Enum('AAVE', 'COMPOUND', name='platform'), autoincrement=False, nullable=True),
    sa.Column('interest', sa.Float(precision=2), autoincrement=False, nullable=True),
    sa.Column('date', sa.DateTime(), autoincrement=False, nullable=True),
    sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
    sa.Column('operation_type', sa.SmallInteger(), nullable=False),
    sa.PrimaryKeyConstraint('id', 'transaction_id')
    )
    op.create_index(op.f('ix_interest_version_operation_type'), 'interest_version', ['operation_type'], unique=False)
    op.create_index(op.f('ix_interest_version_transaction_id'), 'interest_version', ['transaction_id'], unique=False)
    op.create_table('transaction',
    sa.Column('issued_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False),
    sa.Column('remote_addr', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('transaction')
    op.drop_index(op.f('ix_interest_version_transaction_id'), table_name='interest_version')
    op.drop_index(op.f('ix_interest_version_operation_type'), table_name='interest_version')
    op.drop_table('interest_version')
    op.drop_table('interest')
    op.drop_index(op.f('ix_activity_transaction_id'), table_name='activity')
    op.drop_table('activity')
    # ### end Alembic commands ###
